From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933576AbdJRHUp (ORCPT ); Wed, 18 Oct 2017 03:20:45 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:8933 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932796AbdJRHUn (ORCPT ); Wed, 18 Oct 2017 03:20:43 -0400 From: Mengting Zhang To: , CC: , , , , , , , , , , Subject: [PATCH] perf script: Add option to display guest samples in host Date: Wed, 18 Oct 2017 15:09:54 +0800 Message-ID: <1508310594-51519-1-git-send-email-zhangmengting@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A010201.59E7008E.0009,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 72dc5db0980c05f7b311de63b75e9eec Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org By default, 'perf script' always exclude guest samples in host. However, for some tracepoint events(e.g. sched_switch), the tracing output lost sched_out samples for vcpu thread if 'perf script' filter guest samples, which is confusing. Therefore, it'd be better to display guest samples together with host samples. Add '--show-guest-samples' option to display guest samples in host. Without --show-guest-samples option, swapper 0 [008] 18479978.454475: sched:sched_switch: prev_comm=swapper/8 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=kworker/8:0 next_pid=7342 next_prio=120 kworker/8:0 7342 [008] 18479978.454482: sched:sched_switch: prev_comm=kworker/8:0 prev_pid=7342 prev_prio=120 prev_state=S ==> next_comm=CPU 0/KVM next_pid=32396 next_prio=120 swapper 0 [008] 18479979.230473: sched:sched_switch: prev_comm=swapper/8 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=kworker/8:0 next_pid=7342 next_prio=120 kworker/8:0 7342 [008] 18479979.230478: sched:sched_switch: prev_comm=kworker/8:0 prev_pid=7342 prev_prio=120 prev_state=S ==> next_comm=CPU 0/KVM next_pid=32396 next_prio=120 With --show-guest-samples option, swapper 0 [008] 18479978.454475: sched:sched_switch: prev_comm=swapper/8 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=kworker/8:0 next_pid=7342 next_prio=120 kworker/8:0 7342 [008] 18479978.454482: sched:sched_switch: prev_comm=kworker/8:0 prev_pid=7342 prev_prio=120 prev_state=S ==> next_comm=CPU 0/KVM next_pid=32396 next_prio=120 CPU 0/KVM 32396 [008] 18479978.454516: sched:sched_switch: prev_comm=CPU 0/KVM prev_pid=32396 prev_prio=120 prev_state=S ==> next_comm=swapper/8 next_pid=0 next_prio=120 swapper 0 [008] 18479979.230473: sched:sched_switch: prev_comm=swapper/8 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=kworker/8:0 next_pid=7342 next_prio=120 kworker/8:0 7342 [008] 18479979.230478: sched:sched_switch: prev_comm=kworker/8:0 prev_pid=7342 prev_prio=120 prev_state=S ==> next_comm=CPU 0/KVM next_pid=32396 next_prio=120 CPU 0/KVM 32396 [008] 18479979.230520: sched:sched_switch: prev_comm=CPU 0/KVM prev_pid=32396 prev_prio=120 prev_state=S ==> next_comm=swapper/8 next_pid=0 next_prio=120 Signed-off-by: Mengting Zhang --- tools/perf/Documentation/perf-script.txt | 3 +++ tools/perf/builtin-script.c | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt index 18dfcfa..85a080c 100644 --- a/tools/perf/Documentation/perf-script.txt +++ b/tools/perf/Documentation/perf-script.txt @@ -274,6 +274,9 @@ OPTIONS Display context switch events i.e. events of type PERF_RECORD_SWITCH or PERF_RECORD_SWITCH_CPU_WIDE. +--show-guest-samples + Dispaly guest samples in host. + --demangle:: Demangle symbol names to human readable form. It's enabled by default, disable with --no-demangle. diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 3d4c3b5..c34d241 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -1340,6 +1340,7 @@ struct perf_script { bool show_switch_events; bool show_namespace_events; bool allocated; + bool show_guest_samples; struct cpu_map *cpus; struct thread_map *threads; int name_width; @@ -1557,7 +1558,7 @@ static int process_sample_event(struct perf_tool *tool, return -1; } - if (al.filtered) + if (al.filtered && (!scr->show_guest_samples || !(al.filtered & (1 << HIST_FILTER__GUEST)))) goto out_put; if (cpu_list && !test_bit(sample->cpu, cpu_bitmap)) @@ -2771,6 +2772,8 @@ int cmd_script(int argc, const char **argv) "Show context switch events (if recorded)"), OPT_BOOLEAN('\0', "show-namespace-events", &script.show_namespace_events, "Show namespace events (if recorded)"), + OPT_BOOLEAN('\0', "show-guest-samples", &script.show_guest_samples, + "Show guest samples (if recorded)"), OPT_BOOLEAN('f', "force", &symbol_conf.force, "don't complain, do it"), OPT_INTEGER(0, "max-blocks", &max_blocks, "Maximum number of code blocks to dump with brstackinsn"), -- 1.7.12.4