From 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5 Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Tue, 22 Oct 2024 10:36:11 +0000
Subject: [PATCH] 修改4g拨号为QMI,需要在系统里后台执行quectel-CM

---
 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