File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -472,9 +472,10 @@ int perf_stat_process_counter(struct perf_stat_config *config,
472
472
int perf_event__process_stat_event (struct perf_session * session ,
473
473
union perf_event * event )
474
474
{
475
- struct perf_counts_values count ;
475
+ struct perf_counts_values count , * ptr ;
476
476
struct perf_record_stat * st = & event -> stat ;
477
477
struct evsel * counter ;
478
+ int cpu_map_idx ;
478
479
479
480
count .val = st -> val ;
480
481
count .ena = st -> ena ;
@@ -485,8 +486,18 @@ int perf_event__process_stat_event(struct perf_session *session,
485
486
pr_err ("Failed to resolve counter for stat event.\n" );
486
487
return - EINVAL ;
487
488
}
488
-
489
- * perf_counts (counter -> counts , st -> cpu , st -> thread ) = count ;
489
+ cpu_map_idx = perf_cpu_map__idx (evsel__cpus (counter ), (struct perf_cpu ){.cpu = st -> cpu });
490
+ if (cpu_map_idx == -1 ) {
491
+ pr_err ("Invalid CPU %d for event %s.\n" , st -> cpu , evsel__name (counter ));
492
+ return - EINVAL ;
493
+ }
494
+ ptr = perf_counts (counter -> counts , cpu_map_idx , st -> thread );
495
+ if (ptr == NULL ) {
496
+ pr_err ("Failed to find perf count for CPU %d thread %d on event %s.\n" ,
497
+ st -> cpu , st -> thread , evsel__name (counter ));
498
+ return - EINVAL ;
499
+ }
500
+ * ptr = count ;
490
501
counter -> supported = true;
491
502
return 0 ;
492
503
}
You can’t perform that action at this time.
0 commit comments