Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1225879imm; Tue, 5 Jun 2018 10:59:51 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK4u68ce1eRos10WATW8retRVFlK5SWcp5yktxD9kmz2XSamusagMtvMjlfRkyc5195pqE9 X-Received: by 2002:a17:902:b582:: with SMTP id a2-v6mr15395518pls.335.1528221591201; Tue, 05 Jun 2018 10:59:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528221591; cv=none; d=google.com; s=arc-20160816; b=N97LHgUuG92KtJy0GWmx4bSifiyn3cH31jHVPJHzBih4Bg2wPsxpR3saeA4Lje7ahU BYuF37QGsQJ+jCJlkOmOoP8hcoJZz2XlU+u10utuQ15ruJwFfcOQ3M7H9ugmLgiSDOOr AN91IBFsfso18sL6Swi6FOtGN/sVcWJmQe9GrzBHsdUirItHvzLz6x8amhjjfwdoI5AF XLEwMMBM1fucDkgKtQclbsHjs85BBTg66PNd1ls00UX64YA7hQedN6pS0rKjaBeLjLsZ 8+0ba86iIAb0LDqF5GVFPWOWvZNqgrN1SMh+vhqNA77x4sFtqUnPB7n9FFBVNbV4aF6u HJ7w== 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:dkim-signature:arc-authentication-results; bh=Y4hnzgd08WYnLl6FIT5jh+OsY6Pg5L5U9Ge8fxSXMMY=; b=U8eUPqpjFAnL+Cvk0BmgVY63bPX66n2iPP2nuGqjwcyAqDEug46OeWOcWCEivoySro 5wn/6ZnNYRvsEunp+lNxy5E9Z6jt4OER0aUVHdpg/52SwdGQm0TOw4IgLHvgEF026TOn i3kT3kgtgapCh1Ma5+C/2XxTxpRnmbfL1w1SVyoizVsHRkq9fckUtKim2uElWK+ZXTjY +/EDKK3AaOi/YyaTuucZYmjOPC+2CI2xDqhaIZviNt/QIWNnsaYYUpnSOKkDaw7WONBj RhTwdKsxXMFS3ew6C86W8Zi5/WH5g5xMIhhyCuk9S+vfUdSxZL7+tLvioHCMXKPwXyVy pFxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=a75B+idJ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r6-v6si5600214pfl.260.2018.06.05.10.59.37; Tue, 05 Jun 2018 10:59:51 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=a75B+idJ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752848AbeFERwW (ORCPT + 99 others); Tue, 5 Jun 2018 13:52:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:46464 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752816AbeFERwU (ORCPT ); Tue, 5 Jun 2018 13:52:20 -0400 Received: from jouet.infradead.org (unknown [179.97.41.186]) (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 00F632077B; Tue, 5 Jun 2018 17:52:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1528221139; bh=/BcusAjJ8Mnj0T6fdH6vGbW0DXr8MDRoLDNJzOCS0GQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a75B+idJ6nqNSQz2bXzJMx7ochwgrguC6o79DBO/D4Htl46r0SwxMOypXcLNXHaKr PlVXi5gP22LwDyfqxdHWtmJtF3buRXRf56H7qgPYlP/Pvm9tK3k0uFgSM9QMSqae/b 4aN8bqVMNInl7hIz400UuxaS+bX/XBQxcgsOrfn0= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Arnaldo Carvalho de Melo , Adrian Hunter , David Ahern , Jiri Olsa , Namhyung Kim , Wang Nan Subject: [PATCH 33/46] perf hists: Check if a hist_entry has callchains before using them Date: Tue, 5 Jun 2018 14:50:17 -0300 Message-Id: <20180605175030.32549-34-acme@kernel.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180605175030.32549-1-acme@kernel.org> References: <20180605175030.32549-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnaldo Carvalho de Melo So far if we use 'perf record -g' this will make symbol_conf.use_callchain 'true' and logic will assume that all events have callchains enabled, but ever since we added the possibility of setting up callchains for some events (e.g.: -e cycles/call-graph=dwarf/) while not for others, we limit usage scenarios by looking at that symbol_conf.use_callchain global boolean, we better look at each event attributes. On the road to that we need to look if a hist_entry has callchains, that is, to go from hist_entry->hists to the evsel that contains it, to then look at evsel->sample_type for PERF_SAMPLE_CALLCHAIN. The next step is to add a symbol_conf.ignore_callchains global, to use in the places where what we really want to know is if callchains should be ignored, even if present. Then -g will mean just to select a callchain mode to be applied to all events not explicitely setting some other callchain mode, i.e. a default callchain mode, and --no-call-graph will set symbol_conf.ignore_callchains with that clear intention. That too will at some point become a per evsel thing, that tools can set for all or just a few of its evsels. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-0sas5cm4dsw2obn75g7ruz69@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/ui/browsers/hists.c | 11 ++++++----- tools/perf/ui/gtk/hists.c | 5 +++-- tools/perf/ui/hist.c | 2 +- tools/perf/ui/stdio/hist.c | 4 ++-- tools/perf/util/hist.c | 11 ++++++----- tools/perf/util/hist.h | 6 ++++++ tools/perf/util/sort.h | 3 +-- 7 files changed, 25 insertions(+), 17 deletions(-) diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 22054107f1af..a96f62ca984a 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -1231,6 +1231,7 @@ static int hist_browser__show_entry(struct hist_browser *browser, int width = browser->b.width; char folded_sign = ' '; bool current_entry = ui_browser__is_current_entry(&browser->b, row); + bool use_callchain = hist_entry__has_callchains(entry) && symbol_conf.use_callchain; off_t row_offset = entry->row_offset; bool first = true; struct perf_hpp_fmt *fmt; @@ -1240,7 +1241,7 @@ static int hist_browser__show_entry(struct hist_browser *browser, browser->selection = &entry->ms; } - if (symbol_conf.use_callchain) { + if (use_callchain) { hist_entry__init_have_children(entry); folded_sign = hist_entry__folded(entry); } @@ -1276,7 +1277,7 @@ static int hist_browser__show_entry(struct hist_browser *browser, } if (first) { - if (symbol_conf.use_callchain) { + if (use_callchain) { ui_browser__printf(&browser->b, "%c ", folded_sign); width -= 2; } @@ -1583,7 +1584,7 @@ hists_browser__scnprintf_headers(struct hist_browser *browser, char *buf, int column = 0; int span = 0; - if (symbol_conf.use_callchain) { + if (hists__has_callchains(hists) && symbol_conf.use_callchain) { ret = scnprintf(buf, size, " "); if (advance_hpp_check(&dummy_hpp, ret)) return ret; @@ -1987,7 +1988,7 @@ static int hist_browser__fprintf_entry(struct hist_browser *browser, bool first = true; int ret; - if (symbol_conf.use_callchain) { + if (hist_entry__has_callchains(he) && symbol_conf.use_callchain) { folded_sign = hist_entry__folded(he); printed += fprintf(fp, "%c ", folded_sign); } @@ -2671,7 +2672,7 @@ static void hist_browser__update_percent_limit(struct hist_browser *hb, he->nr_rows = 0; } - if (!he->leaf || !symbol_conf.use_callchain) + if (!he->leaf || !hist_entry__has_callchains(he) || !symbol_conf.use_callchain) goto next; if (callchain_param.mode == CHAIN_GRAPH_REL) { diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c index 24e1ec201ffd..b085f1b3e34d 100644 --- a/tools/perf/ui/gtk/hists.c +++ b/tools/perf/ui/gtk/hists.c @@ -382,7 +382,8 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists, gtk_tree_store_set(store, &iter, col_idx++, s, -1); } - if (symbol_conf.use_callchain && hists__has(hists, sym)) { + if (hists__has_callchains(hists) && + symbol_conf.use_callchain && hists__has(hists, sym)) { if (callchain_param.mode == CHAIN_GRAPH_REL) total = symbol_conf.cumulate_callchain ? h->stat_acc->period : h->stat.period; @@ -479,7 +480,7 @@ static void perf_gtk__add_hierarchy_entries(struct hists *hists, } } - if (symbol_conf.use_callchain && he->leaf) { + if (he->leaf && hist_entry__has_callchains(he) && symbol_conf.use_callchain) { if (callchain_param.mode == CHAIN_GRAPH_REL) total = symbol_conf.cumulate_callchain ? he->stat_acc->period : he->stat.period; diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index 706f6f1e9c7d..fe3dfaa64a91 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c @@ -207,7 +207,7 @@ static int __hpp__sort_acc(struct hist_entry *a, struct hist_entry *b, if (ret) return ret; - if (a->thread != b->thread || !symbol_conf.use_callchain) + if (a->thread != b->thread || !hist_entry__has_callchains(a) || !symbol_conf.use_callchain) return 0; ret = b->callchain->max_depth - a->callchain->max_depth; diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c index c1eb476da91b..69b7a28f7a1c 100644 --- a/tools/perf/ui/stdio/hist.c +++ b/tools/perf/ui/stdio/hist.c @@ -516,7 +516,7 @@ static int hist_entry__hierarchy_fprintf(struct hist_entry *he, } printed += putc('\n', fp); - if (symbol_conf.use_callchain && he->leaf) { + if (he->leaf && hist_entry__has_callchains(he) && symbol_conf.use_callchain) { u64 total = hists__total_period(hists); printed += hist_entry_callchain__fprintf(he, total, 0, fp); @@ -550,7 +550,7 @@ static int hist_entry__fprintf(struct hist_entry *he, size_t size, ret = fprintf(fp, "%s\n", bf); - if (use_callchain) + if (hist_entry__has_callchains(he) && use_callchain) callchain_ret = hist_entry_callchain__fprintf(he, total_period, 0, fp); diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 6173dd489f39..b4c8e3a46370 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -410,7 +410,7 @@ static int hist_entry__init(struct hist_entry *he, map__get(he->mem_info->daddr.map); } - if (symbol_conf.use_callchain) + if (hist_entry__has_callchains(he) && symbol_conf.use_callchain) callchain_init(he->callchain); if (he->raw_data) { @@ -496,7 +496,7 @@ static u8 symbol__parent_filter(const struct symbol *parent) static void hist_entry__add_callchain_period(struct hist_entry *he, u64 period) { - if (!symbol_conf.use_callchain) + if (!hist_entry__has_callchains(he) || !symbol_conf.use_callchain) return; he->hists->callchain_period += period; @@ -990,7 +990,7 @@ iter_add_next_cumulative_entry(struct hist_entry_iter *iter, iter->he = he; he_cache[iter->curr++] = he; - if (symbol_conf.use_callchain) + if (hist_entry__has_callchains(he) && symbol_conf.use_callchain) callchain_append(he->callchain, &cursor, sample->period); return 0; } @@ -1377,7 +1377,8 @@ static int hists__hierarchy_insert_entry(struct hists *hists, if (new_he) { new_he->leaf = true; - if (symbol_conf.use_callchain) { + if (hist_entry__has_callchains(new_he) && + symbol_conf.use_callchain) { callchain_cursor_reset(&callchain_cursor); if (callchain_merge(&callchain_cursor, new_he->callchain, @@ -1418,7 +1419,7 @@ static int hists__collapse_insert_entry(struct hists *hists, if (symbol_conf.cumulate_callchain) he_stat__add_stat(iter->stat_acc, he->stat_acc); - if (symbol_conf.use_callchain) { + if (hist_entry__has_callchains(he) && symbol_conf.use_callchain) { callchain_cursor_reset(&callchain_cursor); if (callchain_merge(&callchain_cursor, iter->callchain, diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index cafafbf2aa9f..06607c434949 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h @@ -220,6 +220,12 @@ static inline struct hists *evsel__hists(struct perf_evsel *evsel) return &hevsel->hists; } +static __pure inline bool hists__has_callchains(struct hists *hists) +{ + const struct perf_evsel *evsel = hists_to_evsel(hists); + return evsel__has_callchain(evsel); +} + int hists__init(void); int __hists__init(struct hists *hists, struct perf_hpp_list *hpp_list); diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index 1a046157bfef..7cf2d5cc038e 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h @@ -153,8 +153,7 @@ struct hist_entry { static __pure inline bool hist_entry__has_callchains(struct hist_entry *he) { - const struct perf_evsel *evsel = hists_to_evsel(he->hists); - return evsel__has_callchain(evsel); + return hists__has_callchains(he->hists); } static inline bool hist_entry__has_pairs(struct hist_entry *he) -- 2.14.3