Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3541855ybz; Mon, 20 Apr 2020 05:00:43 -0700 (PDT) X-Google-Smtp-Source: APiQypKC9zs5aMperCmxpOSsoJ/D8+ku7YWmtp1QBpgD6Dj1dOno4EcZJtjWdpx4APlbmDEA8Nk3 X-Received: by 2002:a17:906:cd1:: with SMTP id l17mr15186904ejh.319.1587384043137; Mon, 20 Apr 2020 05:00:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587384043; cv=none; d=google.com; s=arc-20160816; b=jfGwy0bEEiYagl2rez6GzQqNtublLyKMgGXSnJWC2VWeMK8USpLZarYmSFlBq1IrJv VG6LBixsRJOSwR9qyjMouuEfQBrj69AR2OISZIm1NlZPemvJXlC1Wg2cbh1LR2FgqH34 rq9c9DcIGZQeMmK9a7npo9r47rrgw1jsI+JbnZlIUHZkEitzl3rvVs8bMIPulKv87oye ir0oNkDbdc0mOlHIgGNZ3a6hsfTjNJSqhz6hYQTMBDO19losErbda/+KsBh3bdnuGtfC GUYqjCHcd2fx8WR+UkWyF6slkzghfLMUkhwgHuxaHWOfTvlDt9pnXkgqX2il2vsRkz0A Axpw== 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=WTvI7crYMH9R7gdyKunA+SwoH02q6oOWtx9byZI9AR8=; b=bemM5Q75El53AFTx2vFpneddmKzPVcMoQRDr4XMmdKdjGaFWSCtfQ73/yz/VZSOy3k 9uwHJ8xzBbmWj4BYIEksFR7q17gsXfNB5tfPJxumszYHTxgeCj+XOsfp78qDA09Ri8CY jHJdEmS/npJuXszwxAOPaJLQZYffOiudgIFtUsUmrcoX61rlHK3G4+350oPEo2yqjFoM /OZvF0ga2JPf8RKgPH1iLpTYy2CMTiJ+1ep7I7EnhYq6h+1W2LoTmotZQ7ovYqSXeKPr Fs0AwDZjrrF2F9XO8/IG35RMOkmUKYYjaOjA/o/54Yo+QT3o8cBMbhQXBffbZ7aiV59s ATFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YyrZreaA; 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 ks2si404946ejb.445.2020.04.20.05.00.19; Mon, 20 Apr 2020 05:00:43 -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=YyrZreaA; 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 S1727822AbgDTL5u (ORCPT + 99 others); Mon, 20 Apr 2020 07:57:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:42570 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726491AbgDTL5t (ORCPT ); Mon, 20 Apr 2020 07:57:49 -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 B4498221F4; Mon, 20 Apr 2020 11:57:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587383868; bh=arrV/6jlE9PMFQImZ+Ghcb3WvlSfwtJ473Br6T/Y84w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YyrZreaAvDI7QXHESL67uiJjwuroNfR0jVCKb/FMNVOAAJtFNi31IVl/7VAYZi+YB jvLQDk2eOs0JEO4pErtMyF+1PlnDpUd8nOm+OL7feTYtxjm6LcLNhuiZCqYOv0qt4N l1UzGACJ30AXP/WyywVpsg5oJS4gkMxU0GKDRjiU= 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 , Arnaldo Carvalho de Melo , Adrian Hunter , Alexey Budankov , Mathieu Poirier , Michael Ellerman , Pavel Gerasimov , Peter Zijlstra , Ravi Bangoria , Stephane Eranian , Vitaly Slobodskoy Subject: [PATCH 58/60] perf top: Add option to enable the LBR stitching approach Date: Mon, 20 Apr 2020 08:53:14 -0300 Message-Id: <20200420115316.18781-59-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. The option must be used with --call-graph lbr. Signed-off-by: Kan Liang Reviewed-by: Andi Kleen Acked-by: Jiri Olsa Tested-by: Arnaldo Carvalho de Melo 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-16-kan.liang@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Documentation/perf-top.txt | 9 +++++++++ tools/perf/builtin-top.c | 11 +++++++++++ tools/perf/util/top.h | 1 + 3 files changed, 21 insertions(+) diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt index 487737a725e9..20227dabc208 100644 --- a/tools/perf/Documentation/perf-top.txt +++ b/tools/perf/Documentation/perf-top.txt @@ -319,6 +319,15 @@ Default is to monitor all CPUS. go straight to the histogram browser, just like 'perf top' with no events explicitely specified does. +--stitch-lbr:: + Show callgraph with stitched LBRs, which may have more complete + callgraph. The option must be used with --call-graph lbr recording. + 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. INTERACTIVE PROMPTING KEYS -------------------------- diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 289cf83e658a..6b067a5ba1d5 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -33,6 +33,7 @@ #include "util/map.h" #include "util/mmap.h" #include "util/session.h" +#include "util/thread.h" #include "util/symbol.h" #include "util/synthetic-events.h" #include "util/top.h" @@ -775,6 +776,9 @@ static void perf_event__process_sample(struct perf_tool *tool, if (machine__resolve(machine, &al, sample) < 0) return; + if (top->stitch_lbr) + al.thread->lbr_stitch_enable = true; + if (!machine->kptr_restrict_warned && symbol_conf.kptr_restrict && al.cpumode == PERF_RECORD_MISC_KERNEL) { @@ -1571,6 +1575,8 @@ int cmd_top(int argc, const char **argv) "Sort the output by the event at the index n in group. " "If n is invalid, sort by the first event. " "WARNING: should be used on grouped events."), + OPT_BOOLEAN(0, "stitch-lbr", &top.stitch_lbr, + "Enable LBR callgraph stitching approach"), OPTS_EVSWITCH(&top.evswitch), OPT_END() }; @@ -1640,6 +1646,11 @@ int cmd_top(int argc, const char **argv) } } + if (top.stitch_lbr && !(callchain_param.record_mode == CALLCHAIN_LBR)) { + pr_err("Error: --stitch-lbr must be used with --call-graph lbr\n"); + goto out_delete_evlist; + } + if (opts->branch_stack && callchain_param.enabled) symbol_conf.show_branchflag_count = true; diff --git a/tools/perf/util/top.h b/tools/perf/util/top.h index f117d4f4821e..45dc84ddff37 100644 --- a/tools/perf/util/top.h +++ b/tools/perf/util/top.h @@ -36,6 +36,7 @@ struct perf_top { bool use_tui, use_stdio; bool vmlinux_warned; bool dump_symtab; + bool stitch_lbr; struct hist_entry *sym_filter_entry; struct evsel *sym_evsel; struct perf_session *session; -- 2.21.1