From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751833Ab3LXIWg (ORCPT ); Tue, 24 Dec 2013 03:22:36 -0500 Received: from LGEMRELSE6Q.lge.com ([156.147.1.121]:47075 "EHLO LGEMRELSE6Q.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751694Ab3LXIWe (ORCPT ); Tue, 24 Dec 2013 03:22:34 -0500 X-AuditID: 9c930179-b7c89ae000006438-eb-52b94446f0c5 From: Namhyung Kim To: Arnaldo Carvalho de Melo Cc: Peter Zijlstra , Paul Mackerras , Ingo Molnar , Namhyung Kim , LKML , Arun Sharma , Frederic Weisbecker , Jiri Olsa , Rodrigo Campos Subject: [PATCH 06/21] perf tools: Update cpumode for each cumulative entry Date: Tue, 24 Dec 2013 17:22:12 +0900 Message-Id: <1387873347-28838-7-git-send-email-namhyung@kernel.org> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1387873347-28838-1-git-send-email-namhyung@kernel.org> References: <1387873347-28838-1-git-send-email-namhyung@kernel.org> X-Brightmail-Tracker: AAAAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Namhyung Kim The cpumode and level in struct addr_localtion was set for a sample and but updated as cumulative callchains were added. This led to have non-matching symbol and cpumode in the output. Update it accordingly based on the fact whether the map is a part of the kernel or not. This is a reverse of what thread__find_addr_map() does. Cc: Arun Sharma Cc: Frederic Weisbecker Signed-off-by: Namhyung Kim --- tools/perf/builtin-report.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 4fde0ab82498..17c41c686042 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -100,6 +100,7 @@ struct add_entry_iter { struct report *rep; struct perf_evsel *evsel; struct perf_sample *sample; + struct machine *machine; struct hist_entry *he; struct symbol *parent; void *priv; @@ -362,7 +363,7 @@ iter_finish_normal_entry(struct add_entry_iter *iter, struct addr_location *al) static int iter_prepare_cumulative_entry(struct add_entry_iter *iter, - struct machine *machine __maybe_unused, + struct machine *machine, struct perf_evsel *evsel, struct addr_location *al __maybe_unused, struct perf_sample *sample) @@ -371,6 +372,7 @@ iter_prepare_cumulative_entry(struct add_entry_iter *iter, iter->evsel = evsel; iter->sample = sample; + iter->machine = machine; return 0; } @@ -414,9 +416,35 @@ iter_next_cumulative_entry(struct add_entry_iter *iter, else al->addr = node->ip; - if (iter->rep->hide_unresolved && al->sym == NULL) - return 0; + if (al->sym == NULL) { + if (iter->rep->hide_unresolved) + return 0; + if (al->map == NULL) + goto out; + } + + if (al->map->groups == &iter->machine->kmaps) { + if (machine__is_host(iter->machine)) { + al->cpumode = PERF_RECORD_MISC_KERNEL; + al->level = 'k'; + } else { + al->cpumode = PERF_RECORD_MISC_GUEST_KERNEL; + al->level = 'g'; + } + } else { + if (machine__is_host(iter->machine)) { + al->cpumode = PERF_RECORD_MISC_USER; + al->level = '.'; + } else if (perf_guest) { + al->cpumode = PERF_RECORD_MISC_GUEST_USER; + al->level = 'u'; + } else { + al->cpumode = PERF_RECORD_MISC_HYPERVISOR; + al->level = 'H'; + } + } +out: callchain_cursor_advance(&callchain_cursor); return 1; } -- 1.7.11.7