Received: by 10.213.65.68 with SMTP id h4csp1173357imn; Wed, 14 Mar 2018 11:47:22 -0700 (PDT) X-Google-Smtp-Source: AG47ELs/MeQYcw7Ff7HaRJO+66qV580/07fEg9h7pKRLBdFmX13UR59okWWIBnZwwp3s8hbBNAts X-Received: by 2002:a17:902:b2c6:: with SMTP id x6-v6mr5129193plw.298.1521053242246; Wed, 14 Mar 2018 11:47:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521053242; cv=none; d=google.com; s=arc-20160816; b=w/KBufQcMIaGuBI4wVvuwWBcnAW48Cvh9e80w3ad5PxuMFsDTOVuiyM0XtC6OGNksl h+dW7slkJmODIIhyvgmnIY7np8StPyS+3qbMTaYsr+Ie33qRjwnz4i/pVm7BInh6cgOs hccrsVz7M+Cl0fVJ1jHakAQ0ZD831/gQ+6YCPuQvAoPVT6VhdIbIGvPlBVZPhJPclDOk kc9hm/E4R2WK8ZULIGmszQXAoIPmJhirpVgjkXLVZ2EC5BoREZsa5hAArEOpaVT6sTOa W6NdtB5rVvv4OCfNDfTTYF/7i1f/ivcTX69/ViKwS1+HdrRKuQeVgj0y3zB1l5SAnIoD K6Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=tgC01N3EKBi51S1utfAn6kpG375Fo/O0ZI46jAi5MX8=; b=WxzXx8j4c6pW6vJ62qMx0YnErhfToAy4n1yDYCJ8T9gDhE6iAKsnq6ZwuIFZcZORRI Fnf6dJ8LHwRyYoCrAGgSfLx/HZ1ch8F2yo/NR/w3IGfvvE+vIBFJay1UsdMUgB4Q25En +nABeFOa4dZOPDffgHkYyALPLr/MJKz1Nl3v56kQ8Abn/1Ygbg2kl2mvxArr5Zdtj3/F zZboKYPiAdBjs13pBdUDCu6JDDb9awi7jtsl68dYdDRyCX/uOTuEldqrrFuJvOisAOO/ K1bs3HYj+O/tDjgP9DJ4j9Ht1DFbiZNnzfdBYcAmpXviHWckHVlbUmFeJM7fAzsZT0ba vT1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=uwoOVqDZ; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d1si1988960pgu.357.2018.03.14.11.47.07; Wed, 14 Mar 2018 11:47:22 -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=@google.com header.s=20161025 header.b=uwoOVqDZ; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751549AbeCNSqE (ORCPT + 99 others); Wed, 14 Mar 2018 14:46:04 -0400 Received: from mail-it0-f66.google.com ([209.85.214.66]:40223 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750862AbeCNSqC (ORCPT ); Wed, 14 Mar 2018 14:46:02 -0400 Received: by mail-it0-f66.google.com with SMTP id e64-v6so5964236ita.5 for ; Wed, 14 Mar 2018 11:46:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=tgC01N3EKBi51S1utfAn6kpG375Fo/O0ZI46jAi5MX8=; b=uwoOVqDZfVl5jeTG9MQwEZtMVterv40vx7YAykuMsA1YHHS81SAwKc3cRYmhqBJK/T 7YyuBSRb0qjFdA9P3SOPmiK2DGPhiGVT7z3gpAO44a85gRSzp7Upq2v7qjUkymzWqaTI QqBPIW8eIwgxs9yJQjg3K90IJSDtQOmi2jWv8anQA0nh8ZeFeezHDpZO1jrD85al1PhF SHeLhEbRfvMUR4QHjBOjxHbulXMYZzhjUXn8df2oDgo5Tnia+LdjditY7VBbWbaOz+SY NxHEd3HOeBJAhOrAvX54haXjwdw0nGNvJCVUg0zj7ViIxELsxmuci7MDA/OwJKiwXHwf c2nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=tgC01N3EKBi51S1utfAn6kpG375Fo/O0ZI46jAi5MX8=; b=uhBBnn0/knKnq7dCcELVNJnTPHHCtbhJW6ubFea5GJarQZ6JXtMxbNfSjuCivXq42A NilOEvTEWM1ft7ozqVVwXkNok8Qba9rnV6jUD3RmRRUuhEaSu+trHJ1yKIYEI6aAVbEa iDzjaA4It7xPLt52sTxW9LZQ45thDx6AIS2m5EaJoFenyXnW1FTS3INtjvL2uA4eLY/V gfHrPxYMmAB1qJXzeA+MhGgkqqboAl9Uw+s1t4SQJZK6GgSpGGSDRgsM3S2449MIKgSF G+WR2X2mGaJJgY65fcFJjCztG5T1sTMaCO3Q50cODjbd46A8jERBw+hRNEjLLPE2zKni Q40Q== X-Gm-Message-State: AElRT7E1KWPMEWUjNm4NzA9SZu8SCbvfpwnBvwp50LerQSwR/u3gfI1+ BYuZzHHIKuL+HTzAw7+wY2jOhkOFsYnFzbowW+D/AQ== X-Received: by 2002:a24:5ad4:: with SMTP id v203-v6mr3380499ita.150.1521053161751; Wed, 14 Mar 2018 11:46:01 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.222.25 with HTTP; Wed, 14 Mar 2018 11:46:01 -0700 (PDT) In-Reply-To: <20180314092205.23291-2-jolsa@kernel.org> References: <20180314092205.23291-1-jolsa@kernel.org> <20180314092205.23291-2-jolsa@kernel.org> From: Stephane Eranian Date: Wed, 14 Mar 2018 11:46:01 -0700 Message-ID: Subject: Re: [PATCH 2/2] perf report: Support forced leader feature in pipe mode To: Jiri Olsa Cc: Arnaldo Carvalho de Melo , lkml , Ingo Molnar , Namhyung Kim , David Ahern , Alexander Shishkin , Peter Zijlstra Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 14, 2018 at 2:22 AM, Jiri Olsa wrote: > Stephan 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 > > Link: http://lkml.kernel.org/n/tip-afxv5ufoxsbtxfhzupcv9ktg@git.kernel.org > Signed-off-by: Jiri Olsa Works for me. Thanks. Tested-by: Stephane Eranian > --- > 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 @@ static int hist_iter__branch_callback(struct hist_entry_iter *iter, > 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 @@ int cmd_report(int argc, const char **argv) > 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, > -- > 2.13.6 >