hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/tools/perf/util/smt.c
....@@ -15,6 +15,9 @@
1515 if (cached)
1616 return cached_result;
1717
18
+ if (sysfs__read_int("devices/system/cpu/smt/active", &cached_result) >= 0)
19
+ goto done;
20
+
1821 ncpu = sysconf(_SC_NPROCESSORS_CONF);
1922 for (cpu = 0; cpu < ncpu; cpu++) {
2023 unsigned long long siblings;
....@@ -23,10 +26,14 @@
2326 char fn[256];
2427
2528 snprintf(fn, sizeof fn,
26
- "devices/system/cpu/cpu%d/topology/thread_siblings",
27
- cpu);
28
- if (sysfs__read_str(fn, &str, &strlen) < 0)
29
- continue;
29
+ "devices/system/cpu/cpu%d/topology/core_cpus", cpu);
30
+ if (sysfs__read_str(fn, &str, &strlen) < 0) {
31
+ snprintf(fn, sizeof fn,
32
+ "devices/system/cpu/cpu%d/topology/thread_siblings",
33
+ cpu);
34
+ if (sysfs__read_str(fn, &str, &strlen) < 0)
35
+ continue;
36
+ }
3037 /* Entry is hex, but does not have 0x, so need custom parser */
3138 siblings = strtoull(str, NULL, 16);
3239 free(str);
....@@ -38,6 +45,7 @@
3845 }
3946 if (!cached) {
4047 cached_result = 0;
48
+done:
4149 cached = true;
4250 }
4351 return cached_result;