lkml.org 
[lkml]   [2015]   [Sep]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 06/13] perf top: Cache the cpu topology info when "-s socket" is used
Date
From: Arnaldo Carvalho de Melo <acme@redhat.com>

We need to cache that info to use in perf_event__preprocess_sample(), so
that we don't read sysfs files for each sample.

The next patches will add machine->env pointer that will point to either
the perf_env read from a perf.data file header or from the current
system.

Tools needing some specific info should call the perf_env methods that
cache the info, in this case perf_env__read_cpu_topology_map().

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-54vvsb71b56v9d2e4qxwp49t@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-top.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index e5ca6848f01d..bdaf44f24d5d 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -963,6 +963,13 @@ static int __cmd_top(struct perf_top *top)

machine__synthesize_threads(&top->session->machines.host, &opts->target,
top->evlist->threads, false, opts->proc_map_timeout);
+
+ if (sort__has_socket) {
+ ret = perf_env__read_cpu_topology_map(&perf_env);
+ if (ret < 0)
+ goto out_err_cpu_topo;
+ }
+
ret = perf_top__start_counters(top);
if (ret)
goto out_delete;
@@ -1020,6 +1027,14 @@ out_delete:
top->session = NULL;

return ret;
+
+out_err_cpu_topo: {
+ char errbuf[BUFSIZ];
+ const char *err = strerror_r(-ret, errbuf, sizeof(errbuf));
+
+ ui__error("Could not read the CPU topology map: %s\n", err);
+ goto out_delete;
+}
}

static int
--
2.1.0


\
 
 \ /
  Last update: 2015-09-09 22:01    [W:0.289 / U:3.812 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site