Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1781509imu; Thu, 22 Nov 2018 23:35:54 -0800 (PST) X-Google-Smtp-Source: AJdET5dBkcmsMMuPIKYScQnMoxqKzmyD/GAf1rPSUdYekck//cEVyJQKaFGt1NvYKkmNTvPJfW0c X-Received: by 2002:a62:2f06:: with SMTP id v6mr15023070pfv.216.1542958554099; Thu, 22 Nov 2018 23:35:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542958554; cv=none; d=google.com; s=arc-20160816; b=LJ3zjwfJKlWkInURW/SWxdJ6N26BdPpVhofYuie2QrnHkSthEtwlPZ10hC197ZhjyC GC2NJAlR1gqDNdDZ2acod+oSALU88u1HcFp7cWRKcOOPW/hwGCt2Fq5qs3XQqxZ/Pab/ 0fJqHyTaoXcqBWkYholAUztrKGLNOMN/OMdjsWsyJKgt52aXAZypq1zoT16pM6u4fxlg mkCFP15128ZN5NEApQd5iaviyNOXHgaojxZ6XZo1whCdbrMoJmNizuOF1lmlR9hQES8T 4oDqQ11kmhT3n2/n7a61onDIM096xfH+GNu6pq8LMIVmJfgRoAL20IfysuLy2I4+9EGB nYHw== 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; bh=vNTaG5zkgn4noECifE0bZ3uw6WFrvWfwGJaJhP0/TWU=; b=SkbgawJkbBjDha8rSEsuTFvHbERzPBuGM0EGG9VuALMH4Ncmhi9J9yVRFbNIcBNtkC buDKNAVkKRlug4f/6cukDQNMQE1Z/avxI/LPJuCrGpQUqriYB4v2DVnxG/XGeuKTGPUn Yrpr21x+Yu/f3kg5LRLiRQQb3LAsM+yJ+3huOTif4GNCV1zOYD43x92rI5LE4tDfjOmU wcsTfw02iOZ91zNjNeweQQm8MFT6eJAYZSmuO8cC4Pf8VzYNl7kgbIb5d6pcZGFy2Vdy NWD1yTsLz7yM8AeO4u11jEqEQt5+oLBvBeFY/t2vW3RDpoXcszU0s6RKROYsb19c8u8x cIVg== 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 133si4366456pfc.61.2018.11.22.23.35.39; Thu, 22 Nov 2018 23:35:54 -0800 (PST) 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 S2393434AbeKVTrN (ORCPT + 99 others); Thu, 22 Nov 2018 14:47:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42991 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730412AbeKVTrN (ORCPT ); Thu, 22 Nov 2018 14:47:13 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 72FB888314; Thu, 22 Nov 2018 09:08:38 +0000 (UTC) Received: from krava (unknown [10.43.17.92]) by smtp.corp.redhat.com (Postfix) with SMTP id BB8355C21E; Thu, 22 Nov 2018 09:08:36 +0000 (UTC) Date: Thu, 22 Nov 2018 10:08:35 +0100 From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: Stephane Eranian , linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@elte.hu, acme@kernel.org Subject: Re: [PATCH] perf stat: fix csv mode column output for non-cgroup events Message-ID: <20181122090835.GB15953@krava> References: <1541587845-9150-1-git-send-email-eranian@google.com> <20181122035811.GD5468@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181122035811.GD5468@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 22 Nov 2018 09:08:38 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 22, 2018 at 01:58:11AM -0200, Arnaldo Carvalho de Melo wrote: > Em Wed, Nov 07, 2018 at 02:50:45AM -0800, Stephane Eranian escreveu: > > When using the -x option, perf stat prints csv-style output > > with one event per line. For each event, it prints the count, > > the unit, the event name, the cgroup, and a bunch of other event > > specific fields (such as insn per cycles). > > > > When you use csv-style mode, you expect a normalized output where > > each event is printed with the same number of fields regardless of > > what it is so it can easily be imported into a spreadsheet or parsed. > > For instance, if an event does not have a unit, then print an empty field > > for it. Although this approach was implemented for the unit, it was not > > for the cgroup. When mixing cgroup and non-cgroup events, then non-cgroup > > events would not show an empty field, instead the next field was printed, > > make columns not line up correctly. > > > > This patch fixes the cgroup output issues by forcing an empty field > > for non-cgroup events as soon as one event has cgroup. > > Looks sane, that nr_cgroups global variable at some point has to go to > the evlist, but that is not introduced by this patch, Jiri, are you ok > with it as well? yep, looks good, sry I missed it Acked-by: Jiri Olsa jirka > > - Arnaldo > > > Before: > > @ @cycles @foo @ 0 @100.00@@ > > 2531614 @ @cycles @6420922@100.00@ @ > > > > foo cgroup lines up with time_running! > > > > After: > > @ @cycles @foo @0 @100.00@@ > > 2594834 @ @cycles @ @5287372 @100.00@@ > > > > Fields line up. > > > > Signed-off-by: Stephane Eranian > > --- > > tools/perf/util/stat-display.c | 16 +++++++++++----- > > 1 file changed, 11 insertions(+), 5 deletions(-) > > > > diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c > > index e7b4c44ebb62..665ee374fc01 100644 > > --- a/tools/perf/util/stat-display.c > > +++ b/tools/perf/util/stat-display.c > > @@ -59,6 +59,15 @@ static void print_noise(struct perf_stat_config *config, > > print_noise_pct(config, stddev_stats(&ps->res_stats[0]), avg); > > } > > > > +static void print_cgroup(struct perf_stat_config *config, struct perf_evsel *evsel) > > +{ > > + if (nr_cgroups) { > > + const char *cgrp_name = evsel->cgrp ? evsel->cgrp->name : ""; > > + fprintf(config->output, "%s%s", config->csv_sep, cgrp_name); > > + } > > +} > > + > > + > > static void aggr_printout(struct perf_stat_config *config, > > struct perf_evsel *evsel, int id, int nr) > > { > > @@ -336,8 +345,7 @@ static void abs_printout(struct perf_stat_config *config, > > > > fprintf(output, "%-*s", config->csv_output ? 0 : 25, perf_evsel__name(evsel)); > > > > - if (evsel->cgrp) > > - fprintf(output, "%s%s", config->csv_sep, evsel->cgrp->name); > > + print_cgroup(config, evsel); > > } > > > > static bool is_mixed_hw_group(struct perf_evsel *counter) > > @@ -431,9 +439,7 @@ static void printout(struct perf_stat_config *config, int id, int nr, > > config->csv_output ? 0 : -25, > > perf_evsel__name(counter)); > > > > - if (counter->cgrp) > > - fprintf(config->output, "%s%s", > > - config->csv_sep, counter->cgrp->name); > > + print_cgroup(config, counter); > > > > if (!config->csv_output) > > pm(config, &os, NULL, NULL, "", 0); > > -- > > 2.7.4