From 6778948f9de86c3cfaf36725a7c87dcff9ba247f Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Mon, 11 Dec 2023 08:20:59 +0000
Subject: [PATCH] kernel_5.10 no rt
---
kernel/tools/perf/util/smt.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/kernel/tools/perf/util/smt.c b/kernel/tools/perf/util/smt.c
index 453f6f6..34f1b1b 100644
--- a/kernel/tools/perf/util/smt.c
+++ b/kernel/tools/perf/util/smt.c
@@ -15,6 +15,9 @@
if (cached)
return cached_result;
+ if (sysfs__read_int("devices/system/cpu/smt/active", &cached_result) >= 0)
+ goto done;
+
ncpu = sysconf(_SC_NPROCESSORS_CONF);
for (cpu = 0; cpu < ncpu; cpu++) {
unsigned long long siblings;
@@ -23,10 +26,14 @@
char fn[256];
snprintf(fn, sizeof fn,
- "devices/system/cpu/cpu%d/topology/thread_siblings",
- cpu);
- if (sysfs__read_str(fn, &str, &strlen) < 0)
- continue;
+ "devices/system/cpu/cpu%d/topology/core_cpus", cpu);
+ if (sysfs__read_str(fn, &str, &strlen) < 0) {
+ snprintf(fn, sizeof fn,
+ "devices/system/cpu/cpu%d/topology/thread_siblings",
+ cpu);
+ if (sysfs__read_str(fn, &str, &strlen) < 0)
+ continue;
+ }
/* Entry is hex, but does not have 0x, so need custom parser */
siblings = strtoull(str, NULL, 16);
free(str);
@@ -38,6 +45,7 @@
}
if (!cached) {
cached_result = 0;
+done:
cached = true;
}
return cached_result;
--
Gitblit v1.6.2