This commit is contained in:
Rodrigo 2021-08-02 10:08:58 +02:00
parent c594c36387
commit 4e23d7d435
10 changed files with 442 additions and 77 deletions

View File

@ -38,7 +38,7 @@ window_pixel_size 1
window_labels_to_draw 1 window_labels_to_draw 1
window_selected_functions { 14, { {cpu, Active Thd}, {appl, Adding}, {task, Adding}, {thread, Last Evt Val}, {node, Adding}, {system, Adding}, {workload, Adding}, {from_obj, All}, {to_obj, All}, {tag_msg, All}, {size_msg, All}, {bw_msg, All}, {evt_type, =}, {evt_value, All} } } window_selected_functions { 14, { {cpu, Active Thd}, {appl, Adding}, {task, Adding}, {thread, Last Evt Val}, {node, Adding}, {system, Adding}, {workload, Adding}, {from_obj, All}, {to_obj, All}, {tag_msg, All}, {size_msg, All}, {bw_msg, All}, {evt_type, =}, {evt_value, All} } }
window_compose_functions { 9, { {compose_cpu, As Is}, {compose_appl, As Is}, {compose_task, As Is}, {compose_thread, As Is}, {compose_node, As Is}, {compose_system, As Is}, {compose_workload, As Is}, {topcompose1, As Is}, {topcompose2, As Is} } } window_compose_functions { 9, { {compose_cpu, As Is}, {compose_appl, As Is}, {compose_task, As Is}, {compose_thread, As Is}, {compose_node, As Is}, {compose_system, As Is}, {compose_workload, As Is}, {topcompose1, As Is}, {topcompose2, As Is} } }
window_filter_module evt_type 1 400 window_filter_module evt_type 1 10
window_filter_module evt_type_label 1 "Unknown" window_filter_module evt_type_label 1 "Unknown"
window_synchronize 1 window_synchronize 1
@ -77,7 +77,7 @@ window_pixel_size 1
window_labels_to_draw 1 window_labels_to_draw 1
window_selected_functions { 14, { {cpu, Active Thd}, {appl, Adding}, {task, Adding}, {thread, Last Evt Val}, {node, Adding}, {system, Adding}, {workload, Adding}, {from_obj, All}, {to_obj, All}, {tag_msg, All}, {size_msg, All}, {bw_msg, All}, {evt_type, =}, {evt_value, All} } } window_selected_functions { 14, { {cpu, Active Thd}, {appl, Adding}, {task, Adding}, {thread, Last Evt Val}, {node, Adding}, {system, Adding}, {workload, Adding}, {from_obj, All}, {to_obj, All}, {tag_msg, All}, {size_msg, All}, {bw_msg, All}, {evt_type, =}, {evt_value, All} } }
window_compose_functions { 9, { {compose_cpu, As Is}, {compose_appl, As Is}, {compose_task, As Is}, {compose_thread, As Is}, {compose_node, As Is}, {compose_system, As Is}, {compose_workload, As Is}, {topcompose1, As Is}, {topcompose2, As Is} } } window_compose_functions { 9, { {compose_cpu, As Is}, {compose_appl, As Is}, {compose_task, As Is}, {compose_thread, As Is}, {compose_node, As Is}, {compose_system, As Is}, {compose_workload, As Is}, {topcompose1, As Is}, {topcompose2, As Is} } }
window_filter_module evt_type 1 200 window_filter_module evt_type 1 20
window_filter_module evt_type_label 1 "Unknown" window_filter_module evt_type_label 1 "Unknown"
window_synchronize 1 window_synchronize 1
@ -116,7 +116,7 @@ window_pixel_size 1
window_labels_to_draw 1 window_labels_to_draw 1
window_selected_functions { 14, { {cpu, Active Thd}, {appl, Adding}, {task, Adding}, {thread, Last Evt Val}, {node, Adding}, {system, Adding}, {workload, Adding}, {from_obj, All}, {to_obj, All}, {tag_msg, All}, {size_msg, All}, {bw_msg, All}, {evt_type, =}, {evt_value, All} } } window_selected_functions { 14, { {cpu, Active Thd}, {appl, Adding}, {task, Adding}, {thread, Last Evt Val}, {node, Adding}, {system, Adding}, {workload, Adding}, {from_obj, All}, {to_obj, All}, {tag_msg, All}, {size_msg, All}, {bw_msg, All}, {evt_type, =}, {evt_value, All} } }
window_compose_functions { 9, { {compose_cpu, As Is}, {compose_appl, As Is}, {compose_task, As Is}, {compose_thread, As Is}, {compose_node, As Is}, {compose_system, As Is}, {compose_workload, As Is}, {topcompose1, As Is}, {topcompose2, As Is} } } window_compose_functions { 9, { {compose_cpu, As Is}, {compose_appl, As Is}, {compose_task, As Is}, {compose_thread, As Is}, {compose_node, As Is}, {compose_system, As Is}, {compose_workload, As Is}, {topcompose1, As Is}, {topcompose2, As Is} } }
window_filter_module evt_type 1 300 window_filter_module evt_type 1 21
window_filter_module evt_type_label 1 "Unknown" window_filter_module evt_type_label 1 "Unknown"
window_synchronize 1 window_synchronize 1

283
cfg/all.cfg Normal file
View File

@ -0,0 +1,283 @@
#ParaverCFG
ConfigFile.Version: 3.4
ConfigFile.NumWindows: 7
################################################################################
< NEW DISPLAYING WINDOW Active PID >
################################################################################
window_name Active PID
window_type single
window_id 1
window_position_x 0
window_position_y 231
window_width 956
window_height 189
window_comm_lines_enabled true
window_flags_enabled true
window_noncolor_mode true
window_logical_filtered true
window_physical_filtered false
window_comm_fromto true
window_comm_tagsize true
window_comm_typeval true
window_units Microseconds
window_maximum_y 7088.000000000000
window_minimum_y 1.000000000000
window_compute_y_max false
window_level thread
window_scale_relative 1.000000000000
window_end_time_relative 1.000000000000
window_object appl { 1, { All } }
window_object task { 0, 1, { All } }
window_object thread { 0, 0, 19, { 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
window_begin_time_relative 0.000000000000
window_open true
window_drawmode draw_maximum
window_drawmode_rows draw_maximum
window_pixel_size 1
window_labels_to_draw 1
window_selected_functions { 14, { {cpu, Active Thd}, {appl, Adding}, {task, Adding}, {thread, Last Evt Val}, {node, Adding}, {system, Adding}, {workload, Adding}, {from_obj, All}, {to_obj, All}, {tag_msg, All}, {size_msg, All}, {bw_msg, All}, {evt_type, =}, {evt_value, All} } }
window_compose_functions { 9, { {compose_cpu, As Is}, {compose_appl, As Is}, {compose_task, As Is}, {compose_thread, As Is}, {compose_node, As Is}, {compose_system, As Is}, {compose_workload, As Is}, {topcompose1, As Is}, {topcompose2, As Is} } }
window_filter_module evt_type 1 10
window_filter_module evt_type_label 1 "Unknown"
window_synchronize 1
################################################################################
< NEW DISPLAYING WINDOW Active Task ID >
################################################################################
window_name Active Task ID
window_type single
window_id 2
window_position_x 0
window_position_y 442
window_width 956
window_height 190
window_comm_lines_enabled true
window_flags_enabled true
window_noncolor_mode true
window_logical_filtered true
window_physical_filtered false
window_comm_fromto true
window_comm_tagsize true
window_comm_typeval true
window_units Microseconds
window_maximum_y 21.000000000000
window_minimum_y 2.000000000000
window_compute_y_max false
window_level thread
window_scale_relative 1.000000000000
window_end_time_relative 1.000000000000
window_object appl { 1, { All } }
window_object task { 0, 1, { All } }
window_object thread { 0, 0, 19, { 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
window_begin_time_relative 0.000000000000
window_open true
window_drawmode draw_maximum
window_drawmode_rows draw_maximum
window_pixel_size 1
window_labels_to_draw 1
window_selected_functions { 14, { {cpu, Active Thd}, {appl, Adding}, {task, Adding}, {thread, Last Evt Val}, {node, Adding}, {system, Adding}, {workload, Adding}, {from_obj, All}, {to_obj, All}, {tag_msg, All}, {size_msg, All}, {bw_msg, All}, {evt_type, =}, {evt_value, All} } }
window_compose_functions { 9, { {compose_cpu, As Is}, {compose_appl, As Is}, {compose_task, As Is}, {compose_thread, As Is}, {compose_node, As Is}, {compose_system, As Is}, {compose_workload, As Is}, {topcompose1, As Is}, {topcompose2, As Is} } }
window_filter_module evt_type 1 20
window_filter_module evt_type_label 1 "Unknown"
window_synchronize 1
################################################################################
< NEW DISPLAYING WINDOW Active Task Type ID >
################################################################################
window_name Active Task Type ID
window_type single
window_id 3
window_position_x 0
window_position_y 654
window_width 956
window_height 190
window_comm_lines_enabled true
window_flags_enabled true
window_noncolor_mode true
window_color_mode window_in_null_gradient_mode
window_logical_filtered true
window_physical_filtered false
window_comm_fromto true
window_comm_tagsize true
window_comm_typeval true
window_units Microseconds
window_maximum_y 21.000000000000
window_minimum_y 2.000000000000
window_compute_y_max false
window_level thread
window_scale_relative 1.000000000000
window_end_time_relative 1.000000000000
window_object appl { 1, { All } }
window_object task { 0, 1, { All } }
window_object thread { 0, 0, 19, { 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
window_begin_time_relative 0.000000000000
window_open true
window_drawmode draw_maximum
window_drawmode_rows draw_maximum
window_pixel_size 1
window_labels_to_draw 1
window_selected_functions { 14, { {cpu, Active Thd}, {appl, Adding}, {task, Adding}, {thread, Last Evt Val}, {node, Adding}, {system, Adding}, {workload, Adding}, {from_obj, All}, {to_obj, All}, {tag_msg, All}, {size_msg, All}, {bw_msg, All}, {evt_type, =}, {evt_value, All} } }
window_compose_functions { 9, { {compose_cpu, As Is}, {compose_appl, As Is}, {compose_task, As Is}, {compose_thread, As Is}, {compose_node, As Is}, {compose_system, As Is}, {compose_workload, As Is}, {topcompose1, As Is}, {topcompose2, As Is} } }
window_filter_module evt_type 1 21
window_filter_module evt_type_label 1 "Unknown"
window_synchronize 1
################################################################################
< NEW DISPLAYING WINDOW Number of threads running per CPU >
################################################################################
window_name Number of threads running per CPU
window_type single
window_id 4
window_position_x 0
window_position_y 866
window_width 956
window_height 190
window_comm_lines_enabled true
window_flags_enabled true
window_noncolor_mode true
window_color_mode window_in_null_gradient_mode
window_logical_filtered true
window_physical_filtered false
window_comm_fromto true
window_comm_tagsize true
window_comm_typeval true
window_units Microseconds
window_maximum_y 5.000000000000
window_minimum_y 1.000000000000
window_compute_y_max false
window_level thread
window_scale_relative 1.000000000000
window_end_time_relative 1.000000000000
window_object appl { 1, { All } }
window_object task { 0, 1, { All } }
window_object thread { 0, 0, 19, { 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
window_begin_time_relative 0.000000000000
window_open true
window_drawmode draw_maximum
window_drawmode_rows draw_maximum
window_pixel_size 1
window_labels_to_draw 1
window_selected_functions { 14, { {cpu, Active Thd}, {appl, Adding}, {task, Adding}, {thread, Last Evt Val}, {node, Adding}, {system, Adding}, {workload, Adding}, {from_obj, All}, {to_obj, All}, {tag_msg, All}, {size_msg, All}, {bw_msg, All}, {evt_type, =}, {evt_value, All} } }
window_compose_functions { 9, { {compose_cpu, As Is}, {compose_appl, As Is}, {compose_task, As Is}, {compose_thread, As Is}, {compose_node, As Is}, {compose_system, As Is}, {compose_workload, As Is}, {topcompose1, As Is}, {topcompose2, As Is} } }
window_filter_module evt_type 1 12
window_filter_module evt_type_label 1 "Unknown"
window_synchronize 1
################################################################################
< NEW DISPLAYING WINDOW T:Thread State >
################################################################################
window_name T:Thread State
window_type single
window_id 5
window_position_x 960
window_position_y 559
window_width 956
window_height 497
window_comm_lines_enabled true
window_flags_enabled true
window_noncolor_mode true
window_logical_filtered true
window_physical_filtered false
window_comm_fromto true
window_comm_tagsize true
window_comm_typeval true
window_units Microseconds
window_maximum_y 5.000000000000
window_minimum_y 1.000000000000
window_compute_y_max false
window_level thread
window_scale_relative 1.000000000000
window_end_time_relative 1.000000000000
window_object appl { 1, { All } }
window_begin_time_relative 0.000000000000
window_open true
window_drawmode draw_maximum
window_drawmode_rows draw_maximum
window_pixel_size 1
window_labels_to_draw 1
window_selected_functions { 14, { {cpu, Active Thd}, {appl, Adding}, {task, Adding}, {thread, Last Evt Val}, {node, Adding}, {system, Adding}, {workload, Adding}, {from_obj, All}, {to_obj, All}, {tag_msg, All}, {size_msg, All}, {bw_msg, All}, {evt_type, =}, {evt_value, All} } }
window_compose_functions { 9, { {compose_cpu, As Is}, {compose_appl, As Is}, {compose_task, As Is}, {compose_thread, As Is}, {compose_node, As Is}, {compose_system, As Is}, {compose_workload, As Is}, {topcompose1, As Is}, {topcompose2, As Is} } }
window_filter_module evt_type 1 60
window_filter_module evt_type_label 1 "Unknown"
window_synchronize 1
################################################################################
< NEW DISPLAYING WINDOW T:Active TID >
################################################################################
window_name T:Active TID
window_type single
window_id 6
window_position_x 960
window_position_y 40
window_width 956
window_height 497
window_comm_lines_enabled true
window_flags_enabled true
window_noncolor_mode true
window_logical_filtered true
window_physical_filtered false
window_comm_fromto true
window_comm_tagsize true
window_comm_typeval true
window_units Microseconds
window_maximum_y 7103.000000000000
window_minimum_y 7086.000000000000
window_compute_y_max false
window_level thread
window_scale_relative 1.000000000000
window_end_time_relative 1.000000000000
window_object appl { 1, { All } }
window_begin_time_relative 0.000000000000
window_open true
window_drawmode draw_maximum
window_drawmode_rows draw_maximum
window_pixel_size 1
window_labels_to_draw 1
window_selected_functions { 14, { {cpu, Active Thd}, {appl, Adding}, {task, Adding}, {thread, Last Evt Val}, {node, Adding}, {system, Adding}, {workload, Adding}, {from_obj, All}, {to_obj, All}, {tag_msg, All}, {size_msg, All}, {bw_msg, All}, {evt_type, =}, {evt_value, All} } }
window_compose_functions { 9, { {compose_cpu, As Is}, {compose_appl, As Is}, {compose_task, As Is}, {compose_thread, As Is}, {compose_node, As Is}, {compose_system, As Is}, {compose_workload, As Is}, {topcompose1, As Is}, {topcompose2, As Is} } }
window_filter_module evt_type 1 61
window_filter_module evt_type_label 1 "Unknown"
window_synchronize 1
################################################################################
< NEW DISPLAYING WINDOW C:Thread TID >
################################################################################
window_name C:Thread TID
window_type single
window_id 7
window_position_x 0
window_position_y 20
window_width 956
window_height 189
window_comm_lines_enabled true
window_flags_enabled true
window_noncolor_mode true
window_logical_filtered true
window_physical_filtered false
window_comm_fromto true
window_comm_tagsize true
window_comm_typeval true
window_units Microseconds
window_maximum_y 7102.000000000000
window_minimum_y 1.000000000000
window_compute_y_max false
window_level thread
window_scale_relative 1.000000000000
window_end_time_relative 1.000000000000
window_object appl { 1, { All } }
window_object task { 0, 1, { All } }
window_object thread { 0, 0, 19, { 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
window_begin_time_relative 0.000000000000
window_open true
window_drawmode draw_maximum
window_drawmode_rows draw_maximum
window_pixel_size 1
window_labels_to_draw 1
window_selected_functions { 14, { {cpu, Active Thd}, {appl, Adding}, {task, Adding}, {thread, Last Evt Val}, {node, Adding}, {system, Adding}, {workload, Adding}, {from_obj, All}, {to_obj, All}, {tag_msg, All}, {size_msg, All}, {bw_msg, All}, {evt_type, =}, {evt_value, All} } }
window_compose_functions { 9, { {compose_cpu, As Is}, {compose_appl, As Is}, {compose_task, As Is}, {compose_thread, As Is}, {compose_node, As Is}, {compose_system, As Is}, {compose_workload, As Is}, {topcompose1, As Is}, {topcompose2, As Is} } }
window_filter_module evt_type 1 11
window_filter_module evt_type_label 1 "Unknown"
window_synchronize 1

8
emu.c
View File

@ -237,14 +237,6 @@ emu_get_thread(struct ovni_emu *emu, int tid)
return thread; return thread;
} }
void
emu_emit_prv(struct ovni_emu *emu, int type, int val)
{
printf("2:0:1:1:%d:%ld:%d:%d\n",
emu->cur_thread->cpu->cpu_id + 2,
emu->delta_time,
type, val);
}
int int

15
emu.h
View File

@ -33,6 +33,7 @@ enum nosv_task_state {
}; };
struct ovni_ethread; struct ovni_ethread;
struct ovni_eproc;
struct nosv_task { struct nosv_task {
int id; int id;
@ -53,6 +54,12 @@ struct ovni_ethread {
/* Emulated thread tid */ /* Emulated thread tid */
pid_t tid; pid_t tid;
int index;
int gindex;
/* The process associated with this thread */
struct ovni_eproc *proc;
/* Stream fd */ /* Stream fd */
int stream_fd; int stream_fd;
@ -74,6 +81,8 @@ struct ovni_ethread {
/* State of each emulated process */ /* State of each emulated process */
struct ovni_eproc { struct ovni_eproc {
int pid; int pid;
int index;
int gindex;
/* Path of the process tracedir */ /* Path of the process tracedir */
char dir[PATH_MAX]; char dir[PATH_MAX];
@ -140,7 +149,7 @@ struct ovni_cpu {
int index; int index;
enum ovni_cpu_state state; enum ovni_cpu_state state;
enum ovni_cpu_type type; //enum ovni_cpu_type type;
size_t last_nthreads; size_t last_nthreads;
@ -171,6 +180,10 @@ struct ovni_emu {
uint64_t lastclock; uint64_t lastclock;
int64_t delta_time; int64_t delta_time;
/* Total counters */
int total_thread;
int total_proc;
struct nosv_task *cur_task; struct nosv_task *cur_task;
}; };

View File

@ -1,8 +1,10 @@
#include <assert.h>
#include "uthash.h"
#include "ovni.h" #include "ovni.h"
#include "ovni_trace.h" #include "ovni_trace.h"
#include "emu.h" #include "emu.h"
#include "uthash.h" #include "prv.h"
#include <assert.h>
enum nosv_prv_type { enum nosv_prv_type {
PRV_TYPE_PROCID PRV_TYPE_PROCID
@ -235,50 +237,37 @@ hook_pre_nosv(struct ovni_emu *emu)
/* --------------------------- emit ------------------------------- */ /* --------------------------- emit ------------------------------- */
static void static void
emit_task_create(struct ovni_emu *emu) emit_task_running(struct ovni_emu *emu, struct nosv_task *task)
{ {
//emu_emit_prv(emu, 200, emu->cur_task->id); prv_ev_autocpu(emu, PTC_TASK_ID, task->id + 1);
prv_ev_autocpu(emu, PTC_TASK_TYPE_ID, task->type_id + 1);
} }
static void static void
emit_task_execute(struct ovni_emu *emu) emit_task_not_running(struct ovni_emu *emu, struct nosv_task *task)
{ {
emu_emit_prv(emu, 200, emu->cur_task->id + 1); prv_ev_autocpu(emu, PTC_TASK_ID, 0);
emu_emit_prv(emu, 300, emu->cur_task->type_id + 1); prv_ev_autocpu(emu, PTC_TASK_TYPE_ID, 0);
emu_emit_prv(emu, 300, emu->cur_task->type_id + 1);
}
static void
emit_task_pause(struct ovni_emu *emu)
{
emu_emit_prv(emu, 200, 0);
emu_emit_prv(emu, 300, 0);
}
static void
emit_task_resume(struct ovni_emu *emu)
{
emu_emit_prv(emu, 200, emu->cur_task->id + 1);
emu_emit_prv(emu, 300, emu->cur_task->type_id + 1);
}
static void
emit_task_end(struct ovni_emu *emu)
{
emu_emit_prv(emu, 200, 0);
emu_emit_prv(emu, 300, 0);
} }
static void static void
emit_task(struct ovni_emu *emu) emit_task(struct ovni_emu *emu)
{ {
struct nosv_task *task;
task = emu->cur_task;
switch(emu->cur_ev->header.value) switch(emu->cur_ev->header.value)
{ {
case 'c': emit_task_create(emu); break; case 'x':
case 'x': emit_task_execute(emu); break; case 'r':
case 'p': emit_task_pause(emu); break; emit_task_running(emu, task);
case 'r': emit_task_resume(emu); break; break;
case 'e': emit_task_end(emu); break; case 'p':
case 'e':
emit_task_not_running(emu, task);
break;
case 'c':
default: default:
break; break;
} }

View File

@ -1,5 +1,6 @@
#include "ovni.h" #include "ovni.h"
#include "emu.h" #include "emu.h"
#include "prv.h"
#include <assert.h> #include <assert.h>
@ -325,43 +326,60 @@ hook_pre_ovni(struct ovni_emu *emu)
//print_threads_state(emu); //print_threads_state(emu);
} }
static void
emit_thread_state(struct ovni_emu *emu)
{
int row, st, tid;
st = emu->cur_thread->state;
row = emu->cur_thread->gindex + 1;
tid = emu->cur_thread->tid;
prv_ev_row(emu, row, PTT_THREAD_STATE, st);
if(st == TH_ST_RUNNING)
prv_ev_row(emu, row, PTT_THREAD_TID, tid);
else
prv_ev_row(emu, row, PTT_THREAD_TID, 0);
}
static void static void
emit_thread_count(struct ovni_emu *emu) emit_thread_count(struct ovni_emu *emu)
{ {
int i, n, cpu = -1; int i, n, row, pid, tid;
int64_t delta_time;
static int64_t t0 = -1;
if(t0 < 0)
t0 = ovni_ev_get_clock(emu->cur_ev);
delta_time = ovni_ev_get_clock(emu->cur_ev) - t0;
/* Check every CPU looking for a change in nthreads */ /* Check every CPU looking for a change in nthreads */
for(i=0; i<emu->ncpus; i++) for(i=0; i<emu->ncpus; i++)
{ {
if(emu->cpu[i].last_nthreads != emu->cpu[i].nthreads) if(emu->cpu[i].last_nthreads != emu->cpu[i].nthreads)
{ {
cpu = i + 1; /* Start at 1 */
row = i + 1;
n = emu->cpu[i].nthreads; n = emu->cpu[i].nthreads;
goto emit; prv_ev_row(emu, row, PTC_NTHREADS, n);
pid = n == 1 ? emu->cpu[i].thread[0]->proc->pid : 1;
prv_ev_row(emu, row, PTC_PROC_PID, pid);
tid = n == 1 ? emu->cpu[i].thread[0]->tid : 1;
prv_ev_row(emu, row, PTC_THREAD_TID, tid);
} }
} }
/* Same with the virtual CPU */ /* Same with the virtual CPU */
if(emu->vcpu.last_nthreads != emu->vcpu.nthreads) if(emu->vcpu.last_nthreads != emu->vcpu.nthreads)
{ {
cpu = 0; /* Place the virtual CPU after the physical CPUs */
row = emu->ncpus + 1;
n = emu->vcpu.nthreads; n = emu->vcpu.nthreads;
goto emit; prv_ev_row(emu, row, PTC_NTHREADS, n);
pid = n == 1 ? emu->vcpu.thread[0]->proc->pid : 1;
prv_ev_row(emu, row, PTC_PROC_PID, pid);
tid = n == 1 ? emu->vcpu.thread[0]->tid : 1;
prv_ev_row(emu, row, PTC_THREAD_TID, tid);
} }
return;
emit:
printf("2:0:1:1:%d:%ld:100:%d\n",
cpu+1, delta_time, n);
} }
static void static void
@ -370,7 +388,7 @@ emit_current_pid(struct ovni_emu *emu)
if(emu->cur_thread->cpu == NULL) if(emu->cur_thread->cpu == NULL)
return; return;
emu_emit_prv(emu, 400, emu->cur_proc->pid); prv_ev_autocpu(emu, PTC_PROC_PID, emu->cur_proc->pid);
} }
void void
@ -379,10 +397,12 @@ hook_emit_ovni(struct ovni_emu *emu)
switch(emu->cur_ev->header.class) switch(emu->cur_ev->header.class)
{ {
case 'H': case 'H':
emit_thread_state(emu);
/* falltrough */
case 'A': case 'A':
case 'C': case 'C':
emit_thread_count(emu); emit_thread_count(emu);
emit_current_pid(emu); //emit_current_pid(emu);
break; break;
default: default:
break; break;

28
ovni.c
View File

@ -470,9 +470,15 @@ find_dir_prefix(struct dirent *dirent, const char *prefix, int *num)
} }
static int static int
load_thread(struct ovni_ethread *thread, int tid, char *filepath) load_thread(struct ovni_ethread *thread, struct ovni_eproc *proc, int index, int tid, char *filepath)
{ {
static int total_threads = 0;
thread->tid = tid; thread->tid = tid;
thread->index = index;
thread->gindex = total_threads++;
thread->state = TH_ST_UNKNOWN;
thread->proc = proc;
thread->stream_fd = open(filepath, O_RDONLY); thread->stream_fd = open(filepath, O_RDONLY);
if(thread->stream_fd == -1) if(thread->stream_fd == -1)
@ -480,14 +486,14 @@ load_thread(struct ovni_ethread *thread, int tid, char *filepath)
perror("open"); perror("open");
return -1; return -1;
} }
thread->state = TH_ST_UNKNOWN;
return 0; return 0;
} }
static int static int
load_proc(struct ovni_eproc *proc, int pid, char *procdir) load_proc(struct ovni_eproc *proc, int index, int pid, char *procdir)
{ {
static int total_procs = 0;
struct dirent *dirent; struct dirent *dirent;
DIR *dir; DIR *dir;
char path[PATH_MAX]; char path[PATH_MAX];
@ -495,6 +501,8 @@ load_proc(struct ovni_eproc *proc, int pid, char *procdir)
int tid; int tid;
proc->pid = pid; proc->pid = pid;
proc->index = index;
proc->gindex = total_procs++;
if((dir = opendir(procdir)) == NULL) if((dir = opendir(procdir)) == NULL)
{ {
@ -520,10 +528,12 @@ load_proc(struct ovni_eproc *proc, int pid, char *procdir)
abort(); abort();
} }
thread = &proc->thread[proc->nthreads++]; thread = &proc->thread[proc->nthreads];
if(load_thread(thread, tid, path) != 0) if(load_thread(thread, proc, proc->nthreads, tid, path) != 0)
return -1; return -1;
proc->nthreads++;
} }
closedir(dir); closedir(dir);
@ -566,10 +576,12 @@ load_loom(struct ovni_loom *loom, int loomid, char *loomdir)
abort(); abort();
} }
proc = &loom->proc[loom->nprocs++]; proc = &loom->proc[loom->nprocs];
if(load_proc(proc, pid, path) != 0) if(load_proc(proc, loom->nprocs, pid, path) != 0)
return -1; return -1;
loom->nprocs++;
} }
closedir(dir); closedir(dir);

4
ovni.h
View File

@ -13,8 +13,8 @@
#define OVNI_MAX_LOOM 4 #define OVNI_MAX_LOOM 4
#define OVNI_TRACEDIR "ovni" #define OVNI_TRACEDIR "ovni"
/* Reserved buffer for event allocation */ /* Reserved buffer for event allocation per thread */
#define OVNI_MAX_EV_BUF (16 * 1024LL * 1024LL * 1024LL) #define OVNI_MAX_EV_BUF (2 * 1024LL * 1024LL) /* 2 MiB */
/* ----------------------- common ------------------------ */ /* ----------------------- common ------------------------ */

32
prv.c Normal file
View File

@ -0,0 +1,32 @@
#include <stdio.h>
#include <assert.h>
#include "ovni.h"
#include "emu.h"
void
prv_ev_row(struct ovni_emu *emu, int row, int type, int val)
{
printf("2:0:1:1:%d:%ld:%d:%d\n",
row, emu->delta_time, type, val);
}
void
prv_ev_autocpu(struct ovni_emu *emu, int type, int val)
{
int row;
struct ovni_cpu *cpu;
assert(emu->cur_thread);
cpu = emu->cur_thread->cpu;
assert(cpu);
assert(cpu->index >= 0);
assert(cpu->cpu_id >= 0);
/* Begin at 1 */
row = cpu->index + 1;
prv_ev_row(emu, row, type, val);
}

24
prv.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef OVNI_PRV_H
#define OVNI_PRV_H
/* All PRV event types */
enum prv_type {
/* Rows are CPUs */
PTC_PROC_PID = 10,
PTC_THREAD_TID = 11,
PTC_NTHREADS = 12,
PTC_TASK_ID = 20,
PTC_TASK_TYPE_ID = 21,
/* Rows are threads */
PTT_THREAD_STATE = 60,
PTT_THREAD_TID = 61,
};
void
prv_ev_autocpu(struct ovni_emu *emu, int type, int val);
void
prv_ev_row(struct ovni_emu *emu, int row, int type, int val);
#endif /* OVNI_PRV_H */