Received: by 10.213.65.68 with SMTP id h4csp162179imn; Mon, 19 Mar 2018 23:34:29 -0700 (PDT) X-Google-Smtp-Source: AG47ELtev03WihdD+z56o/MqR7CfZaks0S6ZCvqqHocmnCiN2x9dateg75kazFxQ0xV9FrHsVORe X-Received: by 2002:a17:902:6c0d:: with SMTP id q13-v6mr10627332plk.350.1521527669723; Mon, 19 Mar 2018 23:34:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521527669; cv=none; d=google.com; s=arc-20160816; b=hVm787ci1OSerWV8ktiuou35rNBa+Hl7my2iz1BdGAZdcX4oA6GhKgF9+lDwonEjcs JjRKq7ZUvnGfWq35j62uRaFYAAvc7T3m1S5QwKyQjoOuCT5AixSifNh7FE2TseQ/9pdF quXapXyb3IIX9l7RYGdauBDeXuG5aTu+9FWqFD0SO4aCabjf5oMJYar+C6aoN+2dlNgt JupiQvADChBCW/FaSiPNz1bO1U/6IZjpPoCYM1x08TqbrsGYHtEWZqiF4EcguLRSQRty z5T6mb3Xmwub0QJZ6s04aTRGldeG5JMVGcok7Ut5qDRkRLB/5X0byZyuHorBe5Xmrzxj ps0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=R37/l/rRayfTtu9i2Lwo1Bdg/qkw59lmEaT5C74vl78=; b=LrzPizJA3xCYwIhkFENJ4FC0kzZljRGnnwwKlcfDiBhx5Z4ZmwmuM/NdYnMif7HLLH 7S8AdtTohyHewXyJFoviJsPsx/t4iApE/4VnE45UvfA8njsZz3pTsWW1bKeKkvRZx938 M59Mq4ntZyNRM29ClXZFI8Q0/EzSwyHZMhd8S6BSI6e56Sv7Bw9gNpzY3IWMugSFR5dr 55SCPcRqxLFsub/n2MS6zDsZCDgaj5Z8gDwnGATjgVX5WWZLMMpPdhnvTR7SP3J8dXIr TgJjVn8NDz3nI6xcObQw72sGj5wPfVvybD5+FxzyZWvm2wxofFLjjdWwg0V+70yVKth9 Jnfg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h12si734814pgn.317.2018.03.19.23.34.14; Mon, 19 Mar 2018 23:34:29 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752277AbeCTGdB (ORCPT + 99 others); Tue, 20 Mar 2018 02:33:01 -0400 Received: from terminus.zytor.com ([198.137.202.136]:36769 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751719AbeCTGc6 (ORCPT ); Tue, 20 Mar 2018 02:32:58 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w2K6WZOs031471; Mon, 19 Mar 2018 23:32:35 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w2K6WYGT031467; Mon, 19 Mar 2018 23:32:34 -0700 Date: Mon, 19 Mar 2018 23:32:34 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Jiri Olsa Message-ID: Cc: peterz@infradead.org, alexander.shishkin@linux.intel.com, dsahern@gmail.com, eranian@google.com, mingo@kernel.org, tglx@linutronix.de, jolsa@kernel.org, acme@redhat.com, linux-kernel@vger.kernel.org, namhyung@kernel.org, hpa@zytor.com Reply-To: namhyung@kernel.org, hpa@zytor.com, acme@redhat.com, jolsa@kernel.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, dsahern@gmail.com, alexander.shishkin@linux.intel.com, eranian@google.com, mingo@kernel.org, peterz@infradead.org In-Reply-To: <20180314092205.23291-2-jolsa@kernel.org> References: <20180314092205.23291-2-jolsa@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf report: Support forced leader feature in pipe mode Git-Commit-ID: 57b5de463925b9fbd1eff56a38a510495ac9c2c0 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 57b5de463925b9fbd1eff56a38a510495ac9c2c0 Gitweb: https://git.kernel.org/tip/57b5de463925b9fbd1eff56a38a510495ac9c2c0 Author: Jiri Olsa AuthorDate: Wed, 14 Mar 2018 10:22:05 +0100 Committer: Arnaldo Carvalho de Melo CommitDate: Fri, 16 Mar 2018 13:56:59 -0300 perf report: Support forced leader feature in pipe mode Stephane reported a problem with forced leader in pipe mode, where report does not force the group output. The reason is that we don't force the leader in pipe mode. This patch adds HEADER_LAST_FEATURE mark to have a point where we have all events and features received, and force the group if requested. $ perf record --group -e '{cycles, instructions}' -o - kill | perf report -i - --group SNIP # Overhead Command Shared Object Symbol # ................ ....... ................ ....................... # 28.36% 0.00% kill libc-2.25.so [.] __unregister_atfork 26.32% 0.00% kill libc-2.25.so [.] _dl_addr 26.10% 0.00% kill ld-2.25.so [.] _dl_relocate_object 17.32% 0.00% kill ld-2.25.so [.] __tunables_init 1.70% 0.01% kill [unknown] [k] 0xffffffffafa01a40 0.20% 0.00% kill ld-2.25.so [.] _start 0.00% 48.77% kill ld-2.25.so [.] do_lookup_x 0.00% 42.97% kill libc-2.25.so [.] _IO_getline 0.00% 6.35% kill ld-2.25.so [.] strcmp 0.00% 1.71% kill ld-2.25.so [.] _dl_sysdep_start 0.00% 0.19% kill ld-2.25.so [.] _dl_start Signed-off-by: Jiri Olsa Tested-by: Arnaldo Carvalho de Melo Tested-by: Stephane Eranian Cc: Alexander Shishkin Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20180314092205.23291-2-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-report.c | 57 ++++++++++++++++++++++++++++++++++----------- tools/perf/util/header.c | 11 ++++++++- 2 files changed, 53 insertions(+), 15 deletions(-) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 971ccba85464..91da12975642 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -68,6 +68,7 @@ struct report { bool header; bool header_only; bool nonany_branch_mode; + bool group_set; int max_stack; struct perf_read_values show_threads_values; const char *pretty_printing_style; @@ -193,6 +194,45 @@ out: return err; } +/* + * Events in data file are not collect in groups, but we still want + * the group display. Set the artificial group and set the leader's + * forced_leader flag to notify the display code. + */ +static void setup_forced_leader(struct report *report, + struct perf_evlist *evlist) +{ + if (report->group_set && !evlist->nr_groups) { + struct perf_evsel *leader = perf_evlist__first(evlist); + + perf_evlist__set_leader(evlist); + leader->forced_leader = true; + } +} + +static int process_feature_event(struct perf_tool *tool, + union perf_event *event, + struct perf_session *session __maybe_unused) +{ + struct report *rep = container_of(tool, struct report, tool); + + if (event->feat.feat_id < HEADER_LAST_FEATURE) + return perf_event__process_feature(tool, event, session); + + if (event->feat.feat_id != HEADER_LAST_FEATURE) { + pr_err("failed: wrong feature ID: %" PRIu64 "\n", + event->feat.feat_id); + return -1; + } + + /* + * All features are received, we can force the + * group if needed. + */ + setup_forced_leader(rep, session->evlist); + return 0; +} + static int process_sample_event(struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, @@ -940,7 +980,6 @@ int cmd_report(int argc, const char **argv) "perf report []", NULL }; - bool group_set = false; struct report report = { .tool = { .sample = process_sample_event, @@ -958,7 +997,7 @@ int cmd_report(int argc, const char **argv) .id_index = perf_event__process_id_index, .auxtrace_info = perf_event__process_auxtrace_info, .auxtrace = perf_event__process_auxtrace, - .feature = perf_event__process_feature, + .feature = process_feature_event, .ordered_events = true, .ordering_requires_timestamps = true, }, @@ -1060,7 +1099,7 @@ int cmd_report(int argc, const char **argv) "Specify disassembler style (e.g. -M intel for intel syntax)"), OPT_BOOLEAN(0, "show-total-period", &symbol_conf.show_total_period, "Show a column with the sum of periods"), - OPT_BOOLEAN_SET(0, "group", &symbol_conf.event_group, &group_set, + OPT_BOOLEAN_SET(0, "group", &symbol_conf.event_group, &report.group_set, "Show event group information together"), OPT_CALLBACK_NOOPT('b', "branch-stack", &branch_mode, "", "use branch records for per branch histogram filling", @@ -1177,17 +1216,7 @@ repeat: has_br_stack = perf_header__has_feat(&session->header, HEADER_BRANCH_STACK); - /* - * Events in data file are not collect in groups, but we still want - * the group display. Set the artificial group and set the leader's - * forced_leader flag to notify the display code. - */ - if (group_set && !session->evlist->nr_groups) { - struct perf_evsel *leader = perf_evlist__first(session->evlist); - - perf_evlist__set_leader(session->evlist); - leader->forced_leader = true; - } + setup_forced_leader(&report, session->evlist); if (itrace_synth_opts.last_branch) has_br_stack = true; diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index e14b3f7c7212..121df1683c36 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -3415,8 +3415,17 @@ int perf_event__synthesize_features(struct perf_tool *tool, return ret; } } + + /* Send HEADER_LAST_FEATURE mark. */ + fe = ff.buf; + fe->feat_id = HEADER_LAST_FEATURE; + fe->header.type = PERF_RECORD_HEADER_FEATURE; + fe->header.size = sizeof(*fe); + + ret = process(tool, ff.buf, NULL, NULL); + free(ff.buf); - return 0; + return ret; } int perf_event__process_feature(struct perf_tool *tool,