File tree Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Original file line number Diff line number Diff line change 4
4
#include <subcmd/pager.h>
5
5
#include <sys/types.h>
6
6
#include <dirent.h>
7
+ #include <pthread.h>
7
8
#include <string.h>
8
9
#include <unistd.h>
9
10
#include "debug.h"
@@ -492,9 +493,35 @@ int perf_pmus__num_core_pmus(void)
492
493
return count ;
493
494
}
494
495
496
+ static bool __perf_pmus__supports_extended_type (void )
497
+ {
498
+ struct perf_pmu * pmu = NULL ;
499
+
500
+ if (perf_pmus__num_core_pmus () <= 1 )
501
+ return false;
502
+
503
+ while ((pmu = perf_pmus__scan_core (pmu )) != NULL ) {
504
+ if (!is_event_supported (PERF_TYPE_HARDWARE , PERF_COUNT_HW_CPU_CYCLES | ((__u64 )pmu -> type << PERF_PMU_TYPE_SHIFT )))
505
+ return false;
506
+ }
507
+
508
+ return true;
509
+ }
510
+
511
+ static bool perf_pmus__do_support_extended_type ;
512
+
513
+ static void perf_pmus__init_supports_extended_type (void )
514
+ {
515
+ perf_pmus__do_support_extended_type = __perf_pmus__supports_extended_type ();
516
+ }
517
+
495
518
bool perf_pmus__supports_extended_type (void )
496
519
{
497
- return perf_pmus__num_core_pmus () > 1 ;
520
+ static pthread_once_t extended_type_once = PTHREAD_ONCE_INIT ;
521
+
522
+ pthread_once (& extended_type_once , perf_pmus__init_supports_extended_type );
523
+
524
+ return perf_pmus__do_support_extended_type ;
498
525
}
499
526
500
527
struct perf_pmu * evsel__find_pmu (const struct evsel * evsel )
You can’t perform that action at this time.
0 commit comments