Received: by 10.213.65.68 with SMTP id h4csp232585imn; Tue, 13 Mar 2018 02:27:59 -0700 (PDT) X-Google-Smtp-Source: AG47ELsDnX2D+c5ef8oIY3wbZahjzKLL0e3HodbcZkFcYjXEwXIOqE4SmWJa3o70n4aHRbiJ6wzi X-Received: by 10.99.124.1 with SMTP id x1mr7105993pgc.318.1520933278968; Tue, 13 Mar 2018 02:27:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520933278; cv=none; d=google.com; s=arc-20160816; b=yCJeR9HmlDqY3b+k/XHV1iGRlpztJd6GK0aN/zNBJkJtodgV2269VP2Gig35HmroCF RXDvS8wa+0Ce0fb7Mpz2vsofV2n9mWtRJkJ70a4alDqxKlFWimdD2NREvSkSMYwBfG4v Suy7KocAAh+ijwQHGF1JvyEme+nvyjR5momGKvYe7Fio6xgTYCgxtVPW5LdNXNaRX5aD zJXW8F/LgQNUVgPOQK/Ph1XL5E18d0xtC+6sSY6lhjSeV0L7GjAEbMIwZ387re49q09m kaj1lEc5NO4WOm+gZ0USw0xLjAhnUolHvAovdehXVdMe5QXUr1N7k2JDYL0C5TtLLYbB ddSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=gB2hF2p2SFDnBUAM+ERfbUJx6L+ngDELP5pztb2UxAU=; b=QQPREXXBObFferRctK47spUujiSbPnLefC1qfxveBjXqoMojCjWwkKz3FadyT3Dqh5 nw2GLwechw2YofOgLgil2ow7pBxzbps4LadXoV8vxrTHFNaKf2t1KReqSmarNn9oXLUW GI2thB97QtKu6Niew8Bz3dSPk8V6BlAoQ3kqilcahZcB4Hq8t2DiUnygEMAVhdO0GioE 1i44tHKshz1PFqK1CCT7T9QPECo4C4VU+roIYfk4NGnkBhZx8BkuZERO7rBkxVXf92fW /xp7h2PCsGXiJ4fsprxq3EmbrMp+t5iGZqiJ03o+CoCnGlb9aoNeE/pfXCjikFcJcNS4 G6rw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t188si6273141pgt.387.2018.03.13.02.27.44; Tue, 13 Mar 2018 02:27:58 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752464AbeCMJ0u (ORCPT + 99 others); Tue, 13 Mar 2018 05:26:50 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:39740 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752443AbeCMJ0s (ORCPT ); Tue, 13 Mar 2018 05:26:48 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1D568406802A; Tue, 13 Mar 2018 09:26:48 +0000 (UTC) Received: from krava (ovpn-204-150.brq.redhat.com [10.40.204.150]) by smtp.corp.redhat.com (Postfix) with SMTP id 45B7D215CDAC; Tue, 13 Mar 2018 09:26:46 +0000 (UTC) Date: Tue, 13 Mar 2018 10:26:45 +0100 From: Jiri Olsa To: Stephane Eranian Cc: LKML , Arnaldo Carvalho de Melo , Peter Zijlstra , mingo@elte.hu, Andi Kleen , David Carrillo-Cisneros Subject: Re: [BUG] perf record: GROUP_DESC not supported in pipe mode Message-ID: <20180313092645.GA16389@krava> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 13 Mar 2018 09:26:48 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 13 Mar 2018 09:26:48 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jolsa@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 12, 2018 at 06:06:54PM -0700, Stephane Eranian wrote: > Hi, > > I ran into a problem trying to group events in perf record while in pipe mode. > If I do: > > > $ perf record --group -e '{cycles, instructions}' -o - | perf report > -i - --group > > I do not get the profiles grouped together. Instead I get two profiles. > > Looking at the code in util/header.c I see that a bunch of features and not > supported in pipe mode (synthesized method). It is not clear to me why. > Clearly grouping should be supported. This is a very commonly used mode. > > Am I missing something? nope, the support is missing.. attached patch fixes that for me adding David to the loop, as it's touching the code he added jirka --- diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index d33103291b02..32f8ace5fdad 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -754,13 +754,10 @@ static int record__synthesize(struct record *rec, bool tail) return 0; if (data->is_pipe) { - err = perf_event__synthesize_features( - tool, session, rec->evlist, process_synthesized_event); - if (err < 0) { - pr_err("Couldn't synthesize features.\n"); - return err; - } - + /* + * We need to synthesize events first, because some + * features works on top of them (on report side). + */ err = perf_event__synthesize_attrs(tool, session, process_synthesized_event); if (err < 0) { @@ -768,6 +765,13 @@ static int record__synthesize(struct record *rec, bool tail) goto out; } + err = perf_event__synthesize_features( + tool, session, rec->evlist, process_synthesized_event); + if (err < 0) { + pr_err("Couldn't synthesize features.\n"); + return err; + } + if (have_tracepoints(&rec->evlist->entries)) { /* * FIXME err <= 0 here actually means that diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 971ccba85464..fbeb5ef8446a 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,44 @@ 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 +979,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 +996,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 +1098,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 +1215,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..06bada952953 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 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,