perf tools: Apply new CPU topology sysfs attributes
authorKan Liang <kan.liang@linux.intel.com>
Tue, 4 Jun 2019 22:50:44 +0000 (15:50 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 10 Jun 2019 19:20:11 +0000 (16:20 -0300)
The existing "thread_siblings" and "thread_siblings_list" attribute will
be deprecated.

Use the new CPU topology sysfs attributes, "core_cpus" and
"core_cpus_list", which are synonymous with the deprecated attributes.

Check the new name first. If not available, use the deprecated name to
be compatible with old kernel.

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Reviewed-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1559688644-106558-5-git-send-email-kan.liang@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/cputopo.c
tools/perf/util/smt.c

index 85fa87fc30cfead2de748159b60278b970b00dca..26e73a4bd4fe9efe1510d9a6e0e59e942a51b74e 100644 (file)
@@ -15,6 +15,8 @@
        "%s/devices/system/cpu/cpu%d/topology/die_cpus_list"
 #define THRD_SIB_FMT \
        "%s/devices/system/cpu/cpu%d/topology/thread_siblings_list"
+#define THRD_SIB_FMT_NEW \
+       "%s/devices/system/cpu/cpu%d/topology/core_cpus_list"
 #define NODE_ONLINE_FMT \
        "%s/devices/system/node/online"
 #define NODE_MEMINFO_FMT \
@@ -91,8 +93,12 @@ try_dies:
        ret = 0;
 
 try_threads:
-       scnprintf(filename, MAXPATHLEN, THRD_SIB_FMT,
+       scnprintf(filename, MAXPATHLEN, THRD_SIB_FMT_NEW,
                  sysfs__mountpoint(), cpu);
+       if (access(filename, F_OK) == -1) {
+               scnprintf(filename, MAXPATHLEN, THRD_SIB_FMT,
+                         sysfs__mountpoint(), cpu);
+       }
        fp = fopen(filename, "r");
        if (!fp)
                goto done;
index 453f6f6f29f30342790fa879a00eff5a9442614e..3b791ef2cd502222ff01a2edb0605a8c74a46bf7 100644 (file)
@@ -23,8 +23,12 @@ int smt_on(void)
                char fn[256];
 
                snprintf(fn, sizeof fn,
-                       "devices/system/cpu/cpu%d/topology/thread_siblings",
-                       cpu);
+                       "devices/system/cpu/cpu%d/topology/core_cpus", cpu);
+               if (access(fn, F_OK) == -1) {
+                       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 */