@@ -43,6 +43,8 @@ typedef struct {
43
43
44
44
static GMutex lock ;
45
45
static GHashTable * devices ;
46
+ static struct qemu_plugin_scoreboard * source_pc_scoreboard ;
47
+ static qemu_plugin_u64 source_pc ;
46
48
47
49
/* track the access pattern to a piece of HW */
48
50
static bool pattern ;
@@ -159,7 +161,7 @@ static DeviceCounts *new_count(const char *name, uint64_t base)
159
161
count -> name = name ;
160
162
count -> base = base ;
161
163
if (pattern || source ) {
162
- count -> detail = g_hash_table_new (NULL , NULL );
164
+ count -> detail = g_hash_table_new (g_int64_hash , g_int64_equal );
163
165
}
164
166
g_hash_table_insert (devices , (gpointer ) name , count );
165
167
return count ;
@@ -169,7 +171,7 @@ static IOLocationCounts *new_location(GHashTable *table, uint64_t off_or_pc)
169
171
{
170
172
IOLocationCounts * loc = g_new0 (IOLocationCounts , 1 );
171
173
loc -> off_or_pc = off_or_pc ;
172
- g_hash_table_insert (table , ( gpointer ) off_or_pc , loc );
174
+ g_hash_table_insert (table , & loc -> off_or_pc , loc );
173
175
return loc ;
174
176
}
175
177
@@ -224,12 +226,12 @@ static void vcpu_haddr(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo,
224
226
225
227
/* either track offsets or source of access */
226
228
if (source ) {
227
- off = ( uint64_t ) udata ;
229
+ off = qemu_plugin_u64_get ( source_pc , cpu_index ) ;
228
230
}
229
231
230
232
if (pattern || source ) {
231
233
IOLocationCounts * io_count = g_hash_table_lookup (counts -> detail ,
232
- ( gpointer ) off );
234
+ & off );
233
235
if (!io_count ) {
234
236
io_count = new_location (counts -> detail , off );
235
237
}
@@ -247,10 +249,14 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
247
249
248
250
for (i = 0 ; i < n ; i ++ ) {
249
251
struct qemu_plugin_insn * insn = qemu_plugin_tb_get_insn (tb , i );
250
- gpointer udata = (gpointer ) (source ? qemu_plugin_insn_vaddr (insn ) : 0 );
252
+ if (source ) {
253
+ uint64_t pc = qemu_plugin_insn_vaddr (insn );
254
+ qemu_plugin_register_vcpu_mem_inline_per_vcpu (
255
+ insn , rw , QEMU_PLUGIN_INLINE_STORE_U64 ,
256
+ source_pc , pc );
257
+ }
251
258
qemu_plugin_register_vcpu_mem_cb (insn , vcpu_haddr ,
252
- QEMU_PLUGIN_CB_NO_REGS ,
253
- rw , udata );
259
+ QEMU_PLUGIN_CB_NO_REGS , rw , NULL );
254
260
}
255
261
}
256
262
@@ -306,10 +312,9 @@ int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info,
306
312
return -1 ;
307
313
}
308
314
309
- /* Just warn about overflow */
310
- if (info -> system .smp_vcpus > 64 ||
311
- info -> system .max_vcpus > 64 ) {
312
- fprintf (stderr , "hwprofile: can only track up to 64 CPUs\n" );
315
+ if (source ) {
316
+ source_pc_scoreboard = qemu_plugin_scoreboard_new (sizeof (uint64_t ));
317
+ source_pc = qemu_plugin_scoreboard_u64 (source_pc_scoreboard );
313
318
}
314
319
315
320
plugin_init ();
0 commit comments