[PATCH v3 0/8] CSV/JSON metric thresholds, fix printf modifiers

Ian Rogers posted 8 patches 1 month, 1 week ago
There is a newer version of this series
tools/perf/Documentation/perf-stat.txt        |   1 +
tools/perf/arch/x86/util/iostat.c             |   2 +-
tools/perf/builtin-sched.c                    |   2 +-
tools/perf/builtin-script.c                   |   6 +-
tools/perf/builtin-stat.c                     |   8 ++
tools/perf/builtin-trace.c                    |   2 +-
.../tests/shell/lib/perf_json_output_lint.py  |   5 +-
tools/perf/tests/shell/stat+csv_output.sh     |  24 ++--
tools/perf/util/arm-spe.c                     |   2 +-
tools/perf/util/color.h                       |   9 +-
tools/perf/util/intel-bts.c                   |   2 +-
tools/perf/util/intel-pt.c                    |   2 +-
tools/perf/util/s390-cpumsf.c                 |   2 +-
tools/perf/util/s390-sample-raw.c             |   6 +-
tools/perf/util/stat-display.c                |  85 +++++++++---
tools/perf/util/stat-shadow.c                 | 128 ++++++++++--------
tools/perf/util/stat.h                        |  16 ++-
17 files changed, 191 insertions(+), 111 deletions(-)
[PATCH v3 0/8] CSV/JSON metric thresholds, fix printf modifiers
Posted by Ian Rogers 1 month, 1 week ago
Metric thresholds are being computed for CSV and JSON output but not
displayed. Rename the color that encodes the threshold as enum values
and use to generate string constants in a CSV column or json
dictionary value.

Add printf attribute to functions in color.h that could support
it. Fix bad printf format strings that this detected.

v3. Rebase.
v2. Don't display metric-value for json output if there is no unit.

Ian Rogers (8):
  perf color: Add printf format checking and resolve issues
  perf stat: Fix/add parameter names for print_metric
  perf stat: Display "none" for NaN with metric only json
  perf stat: Drop metric-unit if unit is NULL
  perf stat: Change color to threshold in print_metric
  perf stat: Display metric threshold value in CSV output
  perf stat: Add metric-threshold to json output
  perf stat: Disable metric thresholds for CSV/JSON metric-only mode

 tools/perf/Documentation/perf-stat.txt        |   1 +
 tools/perf/arch/x86/util/iostat.c             |   2 +-
 tools/perf/builtin-sched.c                    |   2 +-
 tools/perf/builtin-script.c                   |   6 +-
 tools/perf/builtin-stat.c                     |   8 ++
 tools/perf/builtin-trace.c                    |   2 +-
 .../tests/shell/lib/perf_json_output_lint.py  |   5 +-
 tools/perf/tests/shell/stat+csv_output.sh     |  24 ++--
 tools/perf/util/arm-spe.c                     |   2 +-
 tools/perf/util/color.h                       |   9 +-
 tools/perf/util/intel-bts.c                   |   2 +-
 tools/perf/util/intel-pt.c                    |   2 +-
 tools/perf/util/s390-cpumsf.c                 |   2 +-
 tools/perf/util/s390-sample-raw.c             |   6 +-
 tools/perf/util/stat-display.c                |  85 +++++++++---
 tools/perf/util/stat-shadow.c                 | 128 ++++++++++--------
 tools/perf/util/stat.h                        |  16 ++-
 17 files changed, 191 insertions(+), 111 deletions(-)

-- 
2.47.0.105.g07ac214952-goog
Re: [PATCH v3 0/8] CSV/JSON metric thresholds, fix printf modifiers
Posted by Namhyung Kim 1 month, 1 week ago
On Wed, 16 Oct 2024 10:53:42 -0700, Ian Rogers wrote:

> Metric thresholds are being computed for CSV and JSON output but not
> displayed. Rename the color that encodes the threshold as enum values
> and use to generate string constants in a CSV column or json
> dictionary value.
> 
> Add printf attribute to functions in color.h that could support
> it. Fix bad printf format strings that this detected.
> 
> [...]

Applied to perf-tools-next, thanks!

Best regards,
Namhyung
Re: [PATCH v3 0/8] CSV/JSON metric thresholds, fix printf modifiers
Posted by Ian Rogers 1 month, 1 week ago
On Thu, Oct 17, 2024 at 9:39 AM Namhyung Kim <namhyung@kernel.org> wrote:
>
> On Wed, 16 Oct 2024 10:53:42 -0700, Ian Rogers wrote:
>
> > Metric thresholds are being computed for CSV and JSON output but not
> > displayed. Rename the color that encodes the threshold as enum values
> > and use to generate string constants in a CSV column or json
> > dictionary value.
> >
> > Add printf attribute to functions in color.h that could support
> > it. Fix bad printf format strings that this detected.
> >
> > [...]
>
> Applied to perf-tools-next, thanks!

Sorry for the trouble, could we switch to the v4 series due to issues
on hypervisors with not counted events in CSV output missing a column:
https://lore.kernel.org/lkml/20241016215139.212939-1-irogers@google.com/
The patch set drops the CSV output metric threshold support.

Thanks,
Ian
Re: [PATCH v3 0/8] CSV/JSON metric thresholds, fix printf modifiers
Posted by Namhyung Kim 1 month, 1 week ago
On Thu, Oct 17, 2024 at 09:44:08AM -0700, Ian Rogers wrote:
> On Thu, Oct 17, 2024 at 9:39 AM Namhyung Kim <namhyung@kernel.org> wrote:
> >
> > On Wed, 16 Oct 2024 10:53:42 -0700, Ian Rogers wrote:
> >
> > > Metric thresholds are being computed for CSV and JSON output but not
> > > displayed. Rename the color that encodes the threshold as enum values
> > > and use to generate string constants in a CSV column or json
> > > dictionary value.
> > >
> > > Add printf attribute to functions in color.h that could support
> > > it. Fix bad printf format strings that this detected.
> > >
> > > [...]
> >
> > Applied to perf-tools-next, thanks!
> 
> Sorry for the trouble, could we switch to the v4 series due to issues
> on hypervisors with not counted events in CSV output missing a column:
> https://lore.kernel.org/lkml/20241016215139.212939-1-irogers@google.com/
> The patch set drops the CSV output metric threshold support.

Oops, sorry for missing v4.  And I also noticed a build error on i386.
I'll drop this for now and push perf-tools-next soon.

Thanks,
Namhyung

Re: [PATCH v3 0/8] CSV/JSON metric thresholds, fix printf modifiers
Posted by Ian Rogers 1 month, 1 week ago
On Thu, Oct 17, 2024 at 9:55 AM Namhyung Kim <namhyung@kernel.org> wrote:
>
> On Thu, Oct 17, 2024 at 09:44:08AM -0700, Ian Rogers wrote:
> > On Thu, Oct 17, 2024 at 9:39 AM Namhyung Kim <namhyung@kernel.org> wrote:
> > >
> > > On Wed, 16 Oct 2024 10:53:42 -0700, Ian Rogers wrote:
> > >
> > > > Metric thresholds are being computed for CSV and JSON output but not
> > > > displayed. Rename the color that encodes the threshold as enum values
> > > > and use to generate string constants in a CSV column or json
> > > > dictionary value.
> > > >
> > > > Add printf attribute to functions in color.h that could support
> > > > it. Fix bad printf format strings that this detected.
> > > >
> > > > [...]
> > >
> > > Applied to perf-tools-next, thanks!
> >
> > Sorry for the trouble, could we switch to the v4 series due to issues
> > on hypervisors with not counted events in CSV output missing a column:
> > https://lore.kernel.org/lkml/20241016215139.212939-1-irogers@google.com/
> > The patch set drops the CSV output metric threshold support.
>
> Oops, sorry for missing v4.  And I also noticed a build error on i386.
> I'll drop this for now and push perf-tools-next soon.

Thanks, I'll need to send a v5 to address the 32-bit/i386 issue.

Ian
Re: [PATCH v3 0/8] CSV/JSON metric thresholds, fix printf modifiers
Posted by Ian Rogers 1 month, 1 week ago
On Wed, Oct 16, 2024 at 10:53 AM Ian Rogers <irogers@google.com> wrote:
>
> Metric thresholds are being computed for CSV and JSON output but not
> displayed. Rename the color that encodes the threshold as enum values
> and use to generate string constants in a CSV column or json
> dictionary value.
>
> Add printf attribute to functions in color.h that could support
> it. Fix bad printf format strings that this detected.
>
> v3. Rebase.
> v2. Don't display metric-value for json output if there is no unit.

I'm going to change this. On a hypervisor where counters fail to open
the CSV output is losing a column. I hate the stat-display code as it
is spaghetti, I'm just going to disable metric thresholds with CSV
output.

Thanks,
Ian

> Ian Rogers (8):
>   perf color: Add printf format checking and resolve issues
>   perf stat: Fix/add parameter names for print_metric
>   perf stat: Display "none" for NaN with metric only json
>   perf stat: Drop metric-unit if unit is NULL
>   perf stat: Change color to threshold in print_metric
>   perf stat: Display metric threshold value in CSV output
>   perf stat: Add metric-threshold to json output
>   perf stat: Disable metric thresholds for CSV/JSON metric-only mode
>
>  tools/perf/Documentation/perf-stat.txt        |   1 +
>  tools/perf/arch/x86/util/iostat.c             |   2 +-
>  tools/perf/builtin-sched.c                    |   2 +-
>  tools/perf/builtin-script.c                   |   6 +-
>  tools/perf/builtin-stat.c                     |   8 ++
>  tools/perf/builtin-trace.c                    |   2 +-
>  .../tests/shell/lib/perf_json_output_lint.py  |   5 +-
>  tools/perf/tests/shell/stat+csv_output.sh     |  24 ++--
>  tools/perf/util/arm-spe.c                     |   2 +-
>  tools/perf/util/color.h                       |   9 +-
>  tools/perf/util/intel-bts.c                   |   2 +-
>  tools/perf/util/intel-pt.c                    |   2 +-
>  tools/perf/util/s390-cpumsf.c                 |   2 +-
>  tools/perf/util/s390-sample-raw.c             |   6 +-
>  tools/perf/util/stat-display.c                |  85 +++++++++---
>  tools/perf/util/stat-shadow.c                 | 128 ++++++++++--------
>  tools/perf/util/stat.h                        |  16 ++-
>  17 files changed, 191 insertions(+), 111 deletions(-)
>
> --
> 2.47.0.105.g07ac214952-goog
>