All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/3] perf tool: fix reading new topology attribute "core_cpus"
@ 2020-04-29 16:19 Konstantin Khlebnikov
  2020-04-29 16:22 ` [PATCH v2 2/3] perf tool: fix detecting smt at machines with more than 32 cpus Konstantin Khlebnikov
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Konstantin Khlebnikov @ 2020-04-29 16:19 UTC (permalink / raw)
  To: linux-kernel, Arnaldo Carvalho de Melo, Peter Zijlstra,
	Ingo Molnar
  Cc: Kan Liang, Jiri Olsa, Andi Kleen, Dmitry Monakhov

Check access("devices/system/cpu/cpu%d/topology/core_cpus", F_OK) fails,
unless current directory is "/sys". Simply try read this file first.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Fixes: 0ccdb8407a46 ("perf tools: Apply new CPU topology sysfs attributes")
---
 tools/perf/util/smt.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/smt.c b/tools/perf/util/smt.c
index 3b791ef2cd50..8481842e9edb 100644
--- a/tools/perf/util/smt.c
+++ b/tools/perf/util/smt.c
@@ -24,13 +24,13 @@ int smt_on(void)
 
 		snprintf(fn, sizeof fn,
 			"devices/system/cpu/cpu%d/topology/core_cpus", cpu);
-		if (access(fn, F_OK) == -1) {
+		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;
 		}
-		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);


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-05-08 13:09 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-29 16:19 [PATCH v2 1/3] perf tool: fix reading new topology attribute "core_cpus" Konstantin Khlebnikov
2020-04-29 16:22 ` [PATCH v2 2/3] perf tool: fix detecting smt at machines with more than 32 cpus Konstantin Khlebnikov
2020-04-29 18:13   ` Arnaldo Carvalho de Melo
2020-04-29 18:38     ` Konstantin Khlebnikov
2020-04-30 13:37       ` Arnaldo Carvalho de Melo
2020-04-29 16:23 ` [PATCH v2 3/3] perf tool: simplify checking active smt Konstantin Khlebnikov
2020-04-29 18:16   ` Arnaldo Carvalho de Melo
2020-05-08 13:05   ` [tip: perf/core] perf tools: Simplify checking if SMT is active tip-bot2 for Konstantin Khlebnikov
2020-04-29 18:11 ` [PATCH v2 1/3] perf tool: fix reading new topology attribute "core_cpus" Arnaldo Carvalho de Melo
2020-05-08 13:05 ` [tip: perf/core] perf tools: Fix " tip-bot2 for Konstantin Khlebnikov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.