Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp527492imu; Thu, 22 Nov 2018 01:10:01 -0800 (PST) X-Google-Smtp-Source: AFSGD/WI4LuUHquRdBMu/d0R9miOEROQtIFhm/QOzqzF1qIz0UeTB1/YkmhWlsdnCWB+okawsBTD X-Received: by 2002:a63:7f4f:: with SMTP id p15mr9356249pgn.296.1542877801567; Thu, 22 Nov 2018 01:10:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542877801; cv=none; d=google.com; s=arc-20160816; b=gEQFbMpCKnvL6nZoL2eL/uKwyyXDz0ODx6broawWMP1oIIh1efz6TSKSx1cRWrNMxL 6+WTYDhT1EVnYl8EJIvCKG5qROEzYnwknaLsfBlU+WlSGasKNfEzdi7kNPHL7VuPLORP 1orRDc2XAnQ7UVrf59KeDbweBJuLPoeL9y/VqpNaMSbOViBu44FubjOznTH86fL5v1uo fttGOvXEUgROtZ0N5axGwLGowHuueoXT0TO6dVqGw+69BYTDXWmlU8IitF75YDpy4gYl j1CcJIXxLH5AwZtrP1N0flADi0C/3vePvAL/NjdawjSASsQCVZ5A14DBmOkKWFRD5rLy U6Ww== 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 :in-reply-to:references:mime-version:dkim-signature; bh=fe+/BH9+z11hYH6xVZazuRoUd1WG4gc2Oob49Cc5vs4=; b=QGBdpa4xdRwFsJFKgXIxo9b/v1vZ7MP20ZIvBoC/XopAtSf3izBQXnZRKVM8aqkugq e8FSIwIKD13xKt+bILvuMzqL0E4iuIm7pe8f+pnbThdIdNmYvKk6TOe0A6GTlRcdSza4 Xn/yBnvXhnQkFOEsS/yKBDmFOQeejn6L+Y7tklAwYwxvDr2hioy7vVp+5C5aLYJu+HJo nQUfl5+5QK4jSqaVOCcAN0Ns7OVPNB3No/cwlGoskcU3MG8EZCmUlLZ3eahBQ+68Tq9D 34ZbDCTOXUj5oKoYNVCGTjzsTJgSV52Lv+Dc5uT262/i+gmwFtmGiljdRr1d0Q54oe/G MMcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Vy5Y2jr9; 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 v190si9720515pfv.8.2018.11.22.01.09.46; Thu, 22 Nov 2018 01:10:01 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=Vy5Y2jr9; 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 S2390140AbeKVJJ4 (ORCPT + 99 others); Thu, 22 Nov 2018 04:09:56 -0500 Received: from mail-vs1-f66.google.com ([209.85.217.66]:42432 "EHLO mail-vs1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390125AbeKVJJ4 (ORCPT ); Thu, 22 Nov 2018 04:09:56 -0500 Received: by mail-vs1-f66.google.com with SMTP id b74so4234185vsd.9 for ; Wed, 21 Nov 2018 14:33:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fe+/BH9+z11hYH6xVZazuRoUd1WG4gc2Oob49Cc5vs4=; b=Vy5Y2jr95N4Ay8swuvR4EH38atjeikqhlZK6/Di75BjRr6pwiX5CRpxKYS4qXOy7OD 7BN9ChntOF1sL3ZAhMYQKWVM6jL6vg9LTD3ujRh0jVuh9y0PdN8QgZmDoIX2GOPv+wuy OkKSp549xk6crtbDw2SrMhV95Gd628EefeLFbLvdS4cird/szF6rPAY3oz9ExqMqgp+0 Oxokx72lpjsQawIZCS/CuL2izSEuWh9cTfAzon85pp/h+JrMRmhHEgqoIr2G4jG44x24 43jD70kgois37Ampazy3qXLu+5J+jtUNbFNmPia9MDSObtp3fPP/rwuHjGBDsDrnv/oP MTNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fe+/BH9+z11hYH6xVZazuRoUd1WG4gc2Oob49Cc5vs4=; b=K1NeKKaGe/ZCo2HrxlzvTAgNuo6CRXHJT/7I41Mt1Cv4d8Zn2rB3AWA8lfd4yRM2l0 ecDUxQMFHskf0prDLCHMqMXcI6FYZ8A7cCsG0pmq3Zan74155LpM69pEkw0J07j4ILy6 xiCO0OpAwNApznnzhRzvM+DUAEQK4MJkOJhXLk1iH9rFzqNr3TvfV/jG1XWHEtvR71RO FQp7V19tb8N2L36SFaBbGO/s46LDd732m+tqkaH97XiQSLCOYR4jVgDLl2y79JqL4fsk lz4ek4V7vjJcBEvFj2py0jF4Y/aQ9/VGlkpbbpPEVDoctgp8JTh+Nk4x5H73fygOBoiS Kf+g== X-Gm-Message-State: AA+aEWbe7iWE1d7juT4rQKEH/kptrrMn8TvMBMVR/98lbbIrobVCdy+u fS+2C95znEXuanx77/N7zM84oGtkGrC28mckZG25OZGW+Sg= X-Received: by 2002:a67:1106:: with SMTP id 6mr3625114vsr.213.1542839614432; Wed, 21 Nov 2018 14:33:34 -0800 (PST) MIME-Version: 1.0 References: <1541587845-9150-1-git-send-email-eranian@google.com> In-Reply-To: <1541587845-9150-1-git-send-email-eranian@google.com> From: Stephane Eranian Date: Wed, 21 Nov 2018 14:33:23 -0800 Message-ID: Subject: Re: [PATCH] perf stat: fix csv mode column output for non-cgroup events To: LKML Cc: Arnaldo Carvalho de Melo , Peter Zijlstra , mingo@elte.hu, Jiri Olsa 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 Jiri, Any update on this patch? Thanks. On Wed, Nov 7, 2018 at 2:50 AM Stephane Eranian wrote: > > 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. > > 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 >