Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3544990ybz; Mon, 20 Apr 2020 05:03:23 -0700 (PDT) X-Google-Smtp-Source: APiQypKa0AwHIHUoNn/lyIGWCneOSMwHHWynFSXZ2uCLLjIyOYzmd5g3mVdvDj7bHU3A3dCnSuwh X-Received: by 2002:a50:cd89:: with SMTP id p9mr13791108edi.188.1587384202801; Mon, 20 Apr 2020 05:03:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587384202; cv=none; d=google.com; s=arc-20160816; b=xv5x+oI8KjGjaLN2wP1sAijndIGhYWw/CSL309M/1cAnfNUyhHiCwxYuZjOqXQ5eyV hTPh7ZMkcWBaqcQYQN01oapLmpfRrJYp0t3NJaai2Ub82bLQWfkskGa0mnb05JMxs7He XFjg0to3QeWQb+9V0LoXWYdFic34bkJoGxZtXAt8rQjv6gkt5XOokgRbA2Ckc94SdCWN GjNnfsT00B1PunVjzxOOVc7L4ukivtaNIKedHwuB2M453onyKEQdHhndRJvCpPaq51b/ bcuARlmrFW2NKuxOdI0zpXLKV7ngp9e8H95nrjNZyS2DkJyFv1SGz+ok8/DxwjDEfBOV zEnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Vq6qRTzW6zK3Fwa7YydRWgsWY82TZJyLux5KVEmRbxA=; b=ZE/SxnLqW6W1qko7qQMeaQHGsQxw6LlrD321kqT45soOjvGQFC8Ln2wHPQBAf6qhIN K+RHbyqFmc17wV1lQqrmMEcgueBXwssyPxCYafWagcuGsw+eX9sp4BKMlXLGTLN8EL+s v3pYzg3149MCrlg7527Y0VR6Of4bjSJqm9tke7JzT+agAo1c9UNa8uVcZjIbXiBLDPs7 01MdoPxkCMEsO1bUZz2fx3YB6hbbMaYH/VXPHJzjcEOPHTbFNZ7+2knKQSx2TyWN+C0I YN1akC17M8b3n9kGRttJ4nzg3JF5W98DT8wD8sFByk5oYXgsAL4HZl1ylQ0iRsT7fvNW hrJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pNCBl2+t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a23si396521ejv.375.2020.04.20.05.02.59; Mon, 20 Apr 2020 05:03:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pNCBl2+t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726895AbgDTL5z (ORCPT + 99 others); Mon, 20 Apr 2020 07:57:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:42698 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726460AbgDTL5x (ORCPT ); Mon, 20 Apr 2020 07:57:53 -0400 Received: from quaco.ghostprotocols.net (unknown [179.97.37.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B0611206D4; Mon, 20 Apr 2020 11:57:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587383873; bh=cE1x6PV2IpQ5pEbpGUoIqF2i+nLe38cqkHMW4RuNLx0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pNCBl2+tUheghdxX6k2c/CJjk5phgNnGmD5SGZ2xLzhh/OoZ+LF5RAfVRAnRZlP92 XEyhMEet1lCo/or4B5ss3XT9Thss2gpylHKeTgqteXDJULTD5C/pnr+uxiKpFqAErm 0xRjmIyLtqXp8Y6ZGjxzr9EZSLKxJGY5QiPmlkAA= From: Arnaldo Carvalho de Melo To: Ingo Molnar , Thomas Gleixner Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Kan Liang , Andi Kleen , Jiri Olsa , Adrian Hunter , Alexey Budankov , Mathieu Poirier , Michael Ellerman , Pavel Gerasimov , Peter Zijlstra , Ravi Bangoria , Stephane Eranian , Vitaly Slobodskoy , Arnaldo Carvalho de Melo Subject: [PATCH 59/60] perf c2c: Add option to enable the LBR stitching approach Date: Mon, 20 Apr 2020 08:53:15 -0300 Message-Id: <20200420115316.18781-60-acme@kernel.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200420115316.18781-1-acme@kernel.org> References: <20200420115316.18781-1-acme@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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. Signed-off-by: Kan Liang Reviewed-by: Andi Kleen Acked-by: Jiri Olsa Cc: Adrian Hunter Cc: Alexey Budankov Cc: Mathieu Poirier Cc: Michael Ellerman Cc: Namhyung Kim Cc: Pavel Gerasimov Cc: Peter Zijlstra Cc: Ravi Bangoria Cc: Stephane Eranian Cc: Vitaly Slobodskoy Link: http://lore.kernel.org/lkml/20200319202517.23423-17-kan.liang@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Documentation/perf-c2c.txt | 11 +++++++++++ tools/perf/builtin-c2c.c | 12 ++++++++++++ 2 files changed, 23 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 246ac0b4d54f..0d544c4fb4be 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) @@ -2601,6 +2605,12 @@ static int setup_callchain(struct evlist *evlist) } } + if (c2c.stitch_lbr && (mode != CALLCHAIN_LBR)) { + ui__warning("Can't find LBR callchain. Switch off --stitch-lbr.\n" + "Please apply --call-graph lbr when recording.\n"); + c2c.stitch_lbr = false; + } + callchain_param.record_mode = mode; callchain_param.min_percent = 0; return 0; @@ -2752,6 +2762,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.21.1