[PATCH v5 0/7] CSV/JSON metric thresholds, fix printf modifiers

Ian Rogers posted 7 patches 1 month, 1 week ago
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/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             |   8 +-
tools/perf/util/stat-display.c                |  73 +++++++---
tools/perf/util/stat-shadow.c                 | 128 ++++++++++--------
tools/perf/util/stat.h                        |  16 ++-
15 files changed, 170 insertions(+), 97 deletions(-)
[PATCH v5 0/7] 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 for a json dictionary
value. Disable metric thresholds with CSV output.

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

v5. Switch some u64 printf flags to PRIx64 rather than llx (kernel
    convention) to resolve 32-bit build issues.
v4. Drop CSV metric thresholds due to formatting variation on
    hypervisors (broken counters) and not as detected by
    tests/shell/stat+csv_output.sh.
v3. Rebase.
v2. Don't display metric-value for json output if there is no unit.

Ian Rogers (7):
  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: Add metric-threshold to json output
  perf stat: Disable metric thresholds for CSV and JSON metric-only mode

 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/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             |   8 +-
 tools/perf/util/stat-display.c                |  73 +++++++---
 tools/perf/util/stat-shadow.c                 | 128 ++++++++++--------
 tools/perf/util/stat.h                        |  16 ++-
 15 files changed, 170 insertions(+), 97 deletions(-)

-- 
2.47.0.105.g07ac214952-goog
Re: [PATCH v5 0/7] CSV/JSON metric thresholds, fix printf modifiers
Posted by Namhyung Kim 1 month, 1 week ago
Hi Ian,

On Thu, Oct 17, 2024 at 10:53:49AM -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 for a json dictionary
> value. Disable metric thresholds with CSV output.
> 
> Add printf attribute to functions in color.h that could support
> it. Fix bad printf format strings that this detected.

Thanks for the quick fix, I'll take this.

> 
> v5. Switch some u64 printf flags to PRIx64 rather than llx (kernel
>     convention) to resolve 32-bit build issues.
> v4. Drop CSV metric thresholds due to formatting variation on
>     hypervisors (broken counters) and not as detected by
>     tests/shell/stat+csv_output.sh.

I'm ok with dropping CSV support for now, but could you explain
a bit more detail about the problem?  Is it possible to see the
same problem on host if it has a unsupported event?

Thanks,
Namhyung


> v3. Rebase.
> v2. Don't display metric-value for json output if there is no unit.
> 
> Ian Rogers (7):
>   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: Add metric-threshold to json output
>   perf stat: Disable metric thresholds for CSV and JSON metric-only mode
> 
>  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/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             |   8 +-
>  tools/perf/util/stat-display.c                |  73 +++++++---
>  tools/perf/util/stat-shadow.c                 | 128 ++++++++++--------
>  tools/perf/util/stat.h                        |  16 ++-
>  15 files changed, 170 insertions(+), 97 deletions(-)
> 
> -- 
> 2.47.0.105.g07ac214952-goog
>
Re: [PATCH v5 0/7] CSV/JSON metric thresholds, fix printf modifiers
Posted by Ian Rogers 1 month, 1 week ago
On Thu, Oct 17, 2024 at 11:20 AM Namhyung Kim <namhyung@kernel.org> wrote:
>
> Hi Ian,
>
> On Thu, Oct 17, 2024 at 10:53:49AM -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 for a json dictionary
> > value. Disable metric thresholds with CSV output.
> >
> > Add printf attribute to functions in color.h that could support
> > it. Fix bad printf format strings that this detected.
>
> Thanks for the quick fix, I'll take this.
>
> >
> > v5. Switch some u64 printf flags to PRIx64 rather than llx (kernel
> >     convention) to resolve 32-bit build issues.
> > v4. Drop CSV metric thresholds due to formatting variation on
> >     hypervisors (broken counters) and not as detected by
> >     tests/shell/stat+csv_output.sh.
>
> I'm ok with dropping CSV support for now, but could you explain
> a bit more detail about the problem?  Is it possible to see the
> same problem on host if it has a unsupported event?

It would be. The issue is the stat-display code being a rat's nest and
adding a column to CSV should be straightforward but causes --thread
to behave in odd ways with an uncounted/unsupported event. Where the
column counts differ from supported to not supported causing the CSV
stat output check to fail. Fixing one issue leads to other issues and
my usual desire to rewrite stat-display which can wait for another
occasion. Here I'm trying to address that we may compute the metric
threshold, use extra events, but then never even show the output.

Thanks,
Ian

>
> > v3. Rebase.
> > v2. Don't display metric-value for json output if there is no unit.
> >
> > Ian Rogers (7):
> >   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: Add metric-threshold to json output
> >   perf stat: Disable metric thresholds for CSV and JSON metric-only mode
> >
> >  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/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             |   8 +-
> >  tools/perf/util/stat-display.c                |  73 +++++++---
> >  tools/perf/util/stat-shadow.c                 | 128 ++++++++++--------
> >  tools/perf/util/stat.h                        |  16 ++-
> >  15 files changed, 170 insertions(+), 97 deletions(-)
> >
> > --
> > 2.47.0.105.g07ac214952-goog
> >
Re: [PATCH v5 0/7] CSV/JSON metric thresholds, fix printf modifiers
Posted by Namhyung Kim 1 month, 1 week ago
On Thu, Oct 17, 2024 at 12:15:26PM -0700, Ian Rogers wrote:
> On Thu, Oct 17, 2024 at 11:20 AM Namhyung Kim <namhyung@kernel.org> wrote:
> >
> > Hi Ian,
> >
> > On Thu, Oct 17, 2024 at 10:53:49AM -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 for a json dictionary
> > > value. Disable metric thresholds with CSV output.
> > >
> > > Add printf attribute to functions in color.h that could support
> > > it. Fix bad printf format strings that this detected.
> >
> > Thanks for the quick fix, I'll take this.
> >
> > >
> > > v5. Switch some u64 printf flags to PRIx64 rather than llx (kernel
> > >     convention) to resolve 32-bit build issues.
> > > v4. Drop CSV metric thresholds due to formatting variation on
> > >     hypervisors (broken counters) and not as detected by
> > >     tests/shell/stat+csv_output.sh.
> >
> > I'm ok with dropping CSV support for now, but could you explain
> > a bit more detail about the problem?  Is it possible to see the
> > same problem on host if it has a unsupported event?
> 
> It would be. The issue is the stat-display code being a rat's nest and
> adding a column to CSV should be straightforward but causes --thread
> to behave in odd ways with an uncounted/unsupported event. Where the
> column counts differ from supported to not supported causing the CSV
> stat output check to fail. Fixing one issue leads to other issues and
> my usual desire to rewrite stat-display which can wait for another
> occasion. Here I'm trying to address that we may compute the metric
> threshold, use extra events, but then never even show the output.

I'm curious how it loos like.  Can you show me an example in both cases?

Thanks,
Namhyung

Re: [PATCH v5 0/7] CSV/JSON metric thresholds, fix printf modifiers
Posted by Namhyung Kim 1 month, 1 week ago
On Thu, 17 Oct 2024 10:53:49 -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 for a json dictionary
> value. Disable metric thresholds with CSV output.
> 
> 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