Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp615036ybc; Tue, 19 Nov 2019 06:38:01 -0800 (PST) X-Google-Smtp-Source: APXvYqzFSEN9yKPGUXZJL7OroYoFez7l2phY11Xen12mjBfmdHN4rDeQ3TLzFkmMXqhoYeza6rcW X-Received: by 2002:adf:f490:: with SMTP id l16mr27061126wro.77.1574174281827; Tue, 19 Nov 2019 06:38:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574174281; cv=none; d=google.com; s=arc-20160816; b=pUZNx/MUvgSpX+HZtuJ6Y/gos+0T9nCm5rKTWLXE92z7eZe+nX6ajw/0IVh6VE6kB+ Uux54f4gF4m9b/AsA2/ZbQbTETu01xAs89BeIrhJqBcxmqr2B60carhTc1I+IoW4qcyY fin3MNebRmkSwo1g1d5BsKqXAL9mcirgVGMkXBLTR9l6hxRkXUKRc4GmLVghgFNrit1u rrVo3YOU1jd+7J0kWF8mEmyspaAvWvjdQ8BMMEYz2Wnm9cg27xJx5ZooiZ7BkpEhVLrY 7kjoTJGw0SyjV5eQdOWngn3QYYVQMqcERtalT0z6aLhf56d0Szc7lqFFMW21GBeaeEB2 Ygfw== 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=UnGZtFXeaxWAJYlVCovmZa8KSDPX7HX8fgrNXhRSljA=; b=uxKCReXEIn0ESu5IIyhA0m4JK+PO+x2wxYzYa/YzjphSmncnX5yzKjE5NN1hyfwBPq 7rn7NgvMaxsnu75x3vgrczjg/DlIWuILQSr6crlmo2Cep/5qgzNrc1N1tmC+WDIuU5Nk /1ZqYDg5IIXC9b6h6S+n8fzeTOgRbBVCDf+QSUgaOPs1MFKDFZZL43/KVZ76hPx6bt/H 5WsYsPRCIAkrfus0KpVjW+OHf3w8S5cmmTPu9XIZ0oKOn8ONROZcLUuXSjEgNt8y9rUE nMAJOVN/7X3I7k+pp4kaWdhAJbOzsXNnYF641vv2pyWS9y3/Wrx76wcxiVR9Kn+H0Mwu PVOA== 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 b34si15880667edc.74.2019.11.19.06.37.37; Tue, 19 Nov 2019 06:38:01 -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 S1728376AbfKSOfj (ORCPT + 99 others); Tue, 19 Nov 2019 09:35:39 -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 S1728311AbfKSOfT (ORCPT ); Tue, 19 Nov 2019 09:35:19 -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:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,324,1569308400"; d="scan'208";a="215552428" 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:18 -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 12/13] perf c2c: Add option to enable the LBR stitching approach Date: Tue, 19 Nov 2019 06:34:10 -0800 Message-Id: <20191119143411.3482-13-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-c2c.txt | 11 +++++++++++ tools/perf/builtin-c2c.c | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/tools/perf/Documentation/perf-c2c.txt b/tools/perf/Documentation/perf-c2c.txt index e6150f21267d..2133eb320cb0 100644 --- a/tools/perf/Documentation/perf-c2c.txt +++ b/tools/perf/Documentation/perf-c2c.txt @@ -111,6 +111,17 @@ REPORT OPTIONS --display:: Switch to HITM type (rmt, lcl) to display and sort on. Total HITMs as default. +--stitch-lbr:: + Show callgraph with stitched LBRs, which may have more complete + callgraph. The perf.data file must have been obtained using + perf c2c 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. + C2C RECORD ---------- The perf c2c record command setup options related to HITM cacheline analysis diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index e69f44941aad..91c6277f958a 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -95,6 +95,7 @@ struct perf_c2c { bool use_stdio; bool stats_only; bool symbol_full; + bool stitch_lbr; /* HITM shared clines stats */ struct c2c_stats hitm_stats; @@ -273,6 +274,9 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused, return -1; } + if (c2c.stitch_lbr) + al.thread->lbr_stitch_enable = true; + ret = sample__resolve_callchain(sample, &callchain_cursor, NULL, evsel, &al, sysctl_perf_event_max_stack); if (ret) @@ -2750,6 +2754,8 @@ static int perf_c2c__report(int argc, const char **argv) OPT_STRING('c', "coalesce", &coalesce, "coalesce fields", "coalesce fields: pid,tid,iaddr,dso"), OPT_BOOLEAN('f', "force", &symbol_conf.force, "don't complain, do it"), + OPT_BOOLEAN(0, "stitch-lbr", &c2c.stitch_lbr, + "Enable LBR callgraph stitching approach"), OPT_PARENT(c2c_options), OPT_END() }; -- 2.17.1