Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp615520ybc; Tue, 19 Nov 2019 06:38:27 -0800 (PST) X-Google-Smtp-Source: APXvYqzRzgeFpj+h9ZvCJrrd7n1I3988gs25DsP6tn+T/MRzAz1BHT983iTKbMXt0nJ2lKKPcpeT X-Received: by 2002:a1c:3b08:: with SMTP id i8mr5908441wma.56.1574174307438; Tue, 19 Nov 2019 06:38:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574174307; cv=none; d=google.com; s=arc-20160816; b=k1G+zFGctlugWTBU3Vdw1Uk/I9qbk84MVH0ujDafGQUvYm3kFOXAf21QIhB+6JXNqt FsBwSNoD0P57TR2TnKnL3CNRlauhIq9rT2z8wNyc3gNhXmCM8XAw5r9gXq9tfLbe9lAO Q03nqI7IIyxioWglzXcY1TIzYtbZQrnwAaiP8+zNc2ILf9nuFcUKCdziku6tt+IvSHaH S0ek4eGc/WbVLbCfwD2T4x17wombxcz5H1Uv5ei4r2AjH8iawhYdl9XpU6Ld+mpxTWDH jZXoq6if3zUCDGOHCafxbBCkJwbF4ijpB080W39k4Y9nm3+WSVPu1e96+zSRevzfoIJn eueg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=NSVk0hIYHzo5DN7HFOjD6ZRGEmF1+Ne2CbhLhsVXgfA=; b=dLxGMwcUP7EqX4GX7BQ2GBXsCtop/cqCcTOJ8aazM2VzHlxqenThercPZ89zuJCWCY Kx0HAU2ZYzbIr0wQCCoXoFJyiHBYtGdkgaZkUV1fSqumsFFDW1oqWXXhillIpljrhKBK rNmbd0NRhYICk0/Yqn3gAGakcClVxTHkN7eOcr+lYnjUeA7FIG1XJ5Z18zxZbuFoHXE1 5fx0p8o1A29Dqb7mM3N/VTxgFPGn4XkoaclkPfyQ/wTeZ3NXssVvG3jb4QmeKfeZwqro S5oGJIE1+oCSts8RocKS/X14tCi9vly/3VE2bGJ/B6n2kPgX7xvxbXkp8uwH3myQaYw7 v0/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r4si15581484edx.365.2019.11.19.06.38.02; Tue, 19 Nov 2019 06:38:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728329AbfKSOfV (ORCPT + 99 others); Tue, 19 Nov 2019 09:35:21 -0500 Received: from mga04.intel.com ([192.55.52.120]:64767 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728300AbfKSOfR (ORCPT ); Tue, 19 Nov 2019 09:35:17 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Nov 2019 06:35:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,324,1569308400"; d="scan'208";a="215552419" Received: from labuser-ice-lake-client-platform.jf.intel.com ([10.54.55.50]) by fmsmga001.fm.intel.com with ESMTP; 19 Nov 2019 06:35:16 -0800 From: kan.liang@linux.intel.com To: peterz@infradead.org, acme@redhat.com, mingo@kernel.org, linux-kernel@vger.kernel.org Cc: jolsa@kernel.org, namhyung@kernel.org, vitaly.slobodskoy@intel.com, pavel.gerasimov@intel.com, ak@linux.intel.com, eranian@google.com, mpe@ellerman.id.au, Kan Liang Subject: [PATCH V4 10/13] perf script: Add option to enable the LBR stitching approach Date: Tue, 19 Nov 2019 06:34:08 -0800 Message-Id: <20191119143411.3482-11-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191119143411.3482-1-kan.liang@linux.intel.com> References: <20191119143411.3482-1-kan.liang@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kan Liang With the LBR stitching approach, the reconstructed LBR call stack can break the HW limitation. However, it may reconstruct invalid call stacks in some cases, e.g. exception handing such as setjmp/longjmp. Also, it may impact the processing time especially when the number of samples with stitched LBRs are huge. Add an option to enable the approach. Reviewed-by: Andi Kleen Signed-off-by: Kan Liang --- tools/perf/Documentation/perf-script.txt | 11 +++++++++++ tools/perf/builtin-script.c | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt index 2599b057e47b..472f20f1e479 100644 --- a/tools/perf/Documentation/perf-script.txt +++ b/tools/perf/Documentation/perf-script.txt @@ -426,6 +426,17 @@ include::itrace.txt[] --show-on-off-events:: Show the --switch-on/off events too. +--stitch-lbr:: + Show callgraph with stitched LBRs, which may have more complete + callgraph. The perf.data file must have been obtained using + perf record --call-graph lbr. + Disabled by default. In common cases with call stack overflows, + it can recreate better call stacks than the default lbr call stack + output. But this approach is not full proof. There can be cases + where it creates incorrect call stacks from incorrect matches. + The known limitations include exception handing such as + setjmp/longjmp will have calls/returns not match. + SEE ALSO -------- linkperf:perf-record[1], linkperf:perf-script-perl[1], diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index f86c5cce5b2c..fa1d475571dd 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -1641,6 +1641,7 @@ struct perf_script { bool show_bpf_events; bool allocated; bool per_event_dump; + bool stitch_lbr; struct evswitch evswitch; struct perf_cpu_map *cpus; struct perf_thread_map *threads; @@ -1867,6 +1868,9 @@ static void process_event(struct perf_script *script, if (PRINT_FIELD(IP)) { struct callchain_cursor *cursor = NULL; + if (script->stitch_lbr) + al->thread->lbr_stitch_enable = true; + if (symbol_conf.use_callchain && sample->callchain && thread__resolve_callchain(al->thread, &callchain_cursor, evsel, sample, NULL, NULL, scripting_max_stack) == 0) @@ -3556,6 +3560,8 @@ int cmd_script(int argc, const char **argv) "file", "file saving guest os /proc/kallsyms"), OPT_STRING(0, "guestmodules", &symbol_conf.default_guest_modules, "file", "file saving guest os /proc/modules"), + OPT_BOOLEAN('\0', "stitch-lbr", &script.stitch_lbr, + "Enable LBR callgraph stitching approach"), OPTS_EVSWITCH(&script.evswitch), OPT_END() }; -- 2.17.1