Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3540260ybz; Mon, 20 Apr 2020 04:58:50 -0700 (PDT) X-Google-Smtp-Source: APiQypIzxV5wshHxRt356gKpniX9SHrb32iVcEgkY5TIdw6ztbU1GbxJj7M/L+TjaFeX9rUuFqGe X-Received: by 2002:aa7:d718:: with SMTP id t24mr14122943edq.29.1587383930651; Mon, 20 Apr 2020 04:58:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587383930; cv=none; d=google.com; s=arc-20160816; b=toapmcpK1wfYujijUpKuBzBc9k74DI/2YcF14BZwC0L5a1XtV2IPEtR6a3XG9TXxF6 vwgg9Y+ytJccOHcqJkHtSiNq7HJITC3pERYgDnHtFjPllDJ0NLW/64EsksmYQ3KU37ZS 1FTnqPJSVtm6GXDY/4c6cdVB8O93Y18+PNI7vpY41ALtGVrADiYyRYfRZRxKyYnQxVao xSndRYda7PbL9foYthf26Zu95uVZ4BpnZDjkUwRFQUxKA7DXzLW/r8jcbRmRbIfIHBty TV4pFAwy4UvqyeSFQX03JxPTSva5fJlZieTInFyFMYAImT5KNCO9T3ZaZzhn2S8fVLQ+ ZGug== 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=ex1gMof6AeQ+UMwL0FY7oBUjer76tGkZyqPWxfyC5t0=; b=ykPYRWmVjGkadNiJOPhuZgnXpuI5lyxTuXXcDJB2qwkPuNom4s8Yyuq8Lj922/3xSZ XtXO8o5eXuVGiMgf3mTHk64ItrEPw+VbKym/jHa8VbngeTlh3LZPVd5pPRsgwVsILQLi bstfrQcmsJk54qSQKcCyXqwtgHvzuexo70rb41fmHog3bV5uXv2TDHKk1v+/4+4ceqsl 3B1j8askEL+7UKeNRKlOWPo7qMu1mVrl632zksLK/CizM67OLHY21j/Q+vV7v3y3ZfDV XKxODVcLIGVh4/tD2UxX+tKRobfBeANGJn11pYMuB4MkpMCbbGIfajs0r67tSj6jl9nl fImg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bilgAKTw; 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 m9si453934eda.117.2020.04.20.04.58.27; Mon, 20 Apr 2020 04:58:50 -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=bilgAKTw; 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 S1726993AbgDTLz7 (ORCPT + 99 others); Mon, 20 Apr 2020 07:55:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:40222 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726987AbgDTLz5 (ORCPT ); Mon, 20 Apr 2020 07:55:57 -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 3DCF422242; Mon, 20 Apr 2020 11:55:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587383756; bh=b1USSG9LcsTVBb0Rfa2wXYsUzzv4VmGAUuC6/lbc0Uc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bilgAKTwPuflDEnk/2yfoQ1s6CM4BjiTzQIv99w/HxhaCF6okGeAJptEYZNROLLYh siXxys8UJCwhzAQbFCXeutqAKQgCtxrsfLybm8dtjIOO1A/iXaJQQkwoHMSFe2V0Ci INL3R3MNIt2WWL14s6iA+lQ5Ww6pvAHZCb6QKrVg= 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, Adrian Hunter , Andi Kleen , Jiri Olsa , Arnaldo Carvalho de Melo Subject: [PATCH 32/60] perf auxtrace: Add an option to synthesize callchains for regular events Date: Mon, 20 Apr 2020 08:52:48 -0300 Message-Id: <20200420115316.18781-33-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: Adrian Hunter Currently, callchains can be synthesized only for synthesized events. Add an itrace option to synthesize callchains for regular events. Signed-off-by: Adrian Hunter Cc: Andi Kleen Cc: Jiri Olsa Link: http://lore.kernel.org/lkml/20200401101613.6201-9-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Documentation/itrace.txt | 1 + tools/perf/builtin-report.c | 3 ++- tools/perf/builtin-script.c | 2 +- tools/perf/util/auxtrace.c | 6 +++++- tools/perf/util/auxtrace.h | 2 ++ tools/perf/util/s390-cpumsf.c | 2 +- 6 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tools/perf/Documentation/itrace.txt b/tools/perf/Documentation/itrace.txt index 82ff7dad40c2..671e154ede03 100644 --- a/tools/perf/Documentation/itrace.txt +++ b/tools/perf/Documentation/itrace.txt @@ -10,6 +10,7 @@ e synthesize error events d create a debug log g synthesize a call chain (use with i or x) + G synthesize a call chain on existing event records l synthesize last branch entries (use with i or x) s skip initial number of events diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 26d8fc27e427..c0cebd53ecf9 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -339,6 +339,7 @@ static int report__setup_sample_type(struct report *rep) bool is_pipe = perf_data__is_pipe(session->data); if (session->itrace_synth_opts->callchain || + session->itrace_synth_opts->add_callchain || (!is_pipe && perf_header__has_feat(&session->header, HEADER_AUXTRACE) && !session->itrace_synth_opts->set)) @@ -1332,7 +1333,7 @@ int cmd_report(int argc, const char **argv) if (symbol_conf.cumulate_callchain && !callchain_param.order_set) callchain_param.order = ORDER_CALLER; - if (itrace_synth_opts.callchain && + if ((itrace_synth_opts.callchain || itrace_synth_opts.add_callchain) && (int)itrace_synth_opts.callchain_sz > report.max_stack) report.max_stack = itrace_synth_opts.callchain_sz; diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 8bf3ba280312..06b511c0a539 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -3537,7 +3537,7 @@ int cmd_script(int argc, const char **argv) return -1; } - if (itrace_synth_opts.callchain && + if ((itrace_synth_opts.callchain || itrace_synth_opts.add_callchain) && itrace_synth_opts.callchain_sz > scripting_max_stack) scripting_max_stack = itrace_synth_opts.callchain_sz; diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index b60bae8e395c..809a09e75c55 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -1462,8 +1462,12 @@ int itrace_parse_synth_opts(const struct option *opt, const char *str, synth_opts->branches = true; synth_opts->returns = true; break; + case 'G': case 'g': - synth_opts->callchain = true; + if (p[-1] == 'G') + synth_opts->add_callchain = true; + else + synth_opts->callchain = true; synth_opts->callchain_sz = PERF_ITRACE_DEFAULT_CALLCHAIN_SZ; while (*p == ' ' || *p == ',') diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h index db65aae5c2ea..dd8a4ff8209e 100644 --- a/tools/perf/util/auxtrace.h +++ b/tools/perf/util/auxtrace.h @@ -74,6 +74,7 @@ enum itrace_period_type { * @calls: limit branch samples to calls (can be combined with @returns) * @returns: limit branch samples to returns (can be combined with @calls) * @callchain: add callchain to 'instructions' events + * @add_callchain: add callchain to existing event records * @thread_stack: feed branches to the thread_stack * @last_branch: add branch context to 'instruction' events * @callchain_sz: maximum callchain size @@ -101,6 +102,7 @@ struct itrace_synth_opts { bool calls; bool returns; bool callchain; + bool add_callchain; bool thread_stack; bool last_branch; unsigned int callchain_sz; diff --git a/tools/perf/util/s390-cpumsf.c b/tools/perf/util/s390-cpumsf.c index d7779e48652f..38a942881d1a 100644 --- a/tools/perf/util/s390-cpumsf.c +++ b/tools/perf/util/s390-cpumsf.c @@ -1079,7 +1079,7 @@ static bool check_auxtrace_itrace(struct itrace_synth_opts *itops) itops->pwr_events || itops->errors || itops->dont_decode || itops->calls || itops->returns || itops->callchain || itops->thread_stack || - itops->last_branch; + itops->last_branch || itops->add_callchain; if (!ison) return true; pr_err("Unsupported --itrace options specified\n"); -- 2.21.1