@@ -227,12 +227,12 @@ __add_event(struct list_head *list, int *idx,
227
227
bool init_attr ,
228
228
const char * name , const char * metric_id , struct perf_pmu * pmu ,
229
229
struct list_head * config_terms , bool auto_merge_stats ,
230
- const char * cpu_list )
230
+ struct perf_cpu_map * cpu_list )
231
231
{
232
232
struct evsel * evsel ;
233
- struct perf_cpu_map * cpus = pmu ? perf_cpu_map__get (pmu -> cpus ) :
234
- cpu_list ? perf_cpu_map__new (cpu_list ) : NULL ;
233
+ struct perf_cpu_map * cpus = perf_cpu_map__is_empty (cpu_list ) && pmu ? pmu -> cpus : cpu_list ;
235
234
235
+ cpus = perf_cpu_map__get (cpus );
236
236
if (pmu )
237
237
perf_pmu__warn_invalid_formats (pmu );
238
238
@@ -305,16 +305,17 @@ static int add_event_tool(struct list_head *list, int *idx,
305
305
.type = PERF_TYPE_SOFTWARE ,
306
306
.config = PERF_COUNT_SW_DUMMY ,
307
307
};
308
- const char * cpu_list = NULL ;
308
+ struct perf_cpu_map * cpu_list = NULL ;
309
309
310
310
if (tool_event == PERF_TOOL_DURATION_TIME ) {
311
311
/* Duration time is gathered globally, pretend it is only on CPU0. */
312
- cpu_list = "0" ;
312
+ cpu_list = perf_cpu_map__new ( "0" ) ;
313
313
}
314
314
evsel = __add_event (list , idx , & attr , /*init_attr=*/ true, /*name=*/ NULL ,
315
315
/*metric_id=*/ NULL , /*pmu=*/ NULL ,
316
316
/*config_terms=*/ NULL , /*auto_merge_stats=*/ false,
317
317
cpu_list );
318
+ perf_cpu_map__put (cpu_list );
318
319
if (!evsel )
319
320
return - ENOMEM ;
320
321
evsel -> tool_event = tool_event ;
0 commit comments