From: Arnaldo Carvalho de Melo <[email protected]> Instead of reading /sysfs/devices/system/cpu/cpu%d/topology/physical_package_id for each sample.
While at it, check that the sample has PERF_SAMPLE_CPU, i.e. that sample.cpu >= 0, to avoid an out of bounds access. Reported-by: Wang Nan <[email protected]> Based-on-a-patch-by: Jiri Olsa <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: David Ahern <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: Kan Liang <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Wang Nan <[email protected]> Link: http://lkml.kernel.org/n/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]> --- tools/perf/util/event.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 0bf8c9889fc0..497157affc9c 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -1021,7 +1021,14 @@ int perf_event__preprocess_sample(const union perf_event *event, al->sym = NULL; al->cpu = sample->cpu; - al->socket = cpu_map__get_socket_id(al->cpu); + al->socket = -1; + + if (al->cpu >= 0) { + struct perf_env *env = machine->env; + + if (env && env->cpu) + al->socket = env->cpu[al->cpu].socket_id; + } if (al->map) { struct dso *dso = al->map->dso; -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/

