Linux Perf Users
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ian Rogers" <irogers@google.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v1 1/3] perf jevents: Add more components to the metric sorting order
Date: Tue, 07 Jul 2026 03:58:31 +0000	[thread overview]
Message-ID: <20260707035832.6F0941F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260707034019.241762-2-irogers@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Unconditional access of `j.metric_expr.ToPerfJson()` can raise `AttributeError: 'NoneType' object has no attribute 'ToPerfJson'` in `jevents.py`, causing a build failure.
--

--- Patch [1]: [PATCH v1 1/3] perf jevents: Add more components to the metric sorting order ---
commit ef069542148ff8d19abeda05cc13982058eb11d7
Author: Ian Rogers <irogers@google.com>

perf jevents: Add more components to the metric sorting order

This commit modifies the sorting order for metrics in the jevents.py script
by including expressions and descriptions. The goal is to prevent
non-deterministic builds that were occurring when metrics were sorted only
by name.

Closes: https://lore.kernel.org/linux-perf-users/20260706175624.692736-1-nazar.kazakov@codethink.co.uk/

> diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py
> index 376dc2d241621..3c6cfeefbd5dc 100755
> --- a/tools/perf/pmu-events/jevents.py
> +++ b/tools/perf/pmu-events/jevents.py
> @@ -570,13 +570,14 @@ static const struct pmu_table_entry {_pending_events_tblname}[] = {{
>  def print_pending_metrics() -> None:
>    """Optionally close metrics table."""
>  
> -  def metric_cmp_key(j: JsonEvent) -> Tuple[bool, str, str]:
> +  def metric_cmp_key(j: JsonEvent) -> Tuple[str, str, str, str]:
>      def fix_none(s: Optional[str]) -> str:
>        if s is None:
>          return ''
>        return s
>  
> -    return (j.desc is not None, fix_none(j.pmu), fix_none(j.metric_name))
> +    return (fix_none(j.pmu), fix_none(j.metric_name), j.metric_expr.ToPerfJson(),
> +            fix_none(j.desc))

[Severity: Low]
Will this crash with an AttributeError if an event lacks a metric expression?

If a parsed JSON event specifies a MetricName but omits MetricExpr,
j.metric_expr will be None. Calling j.metric_expr.ToPerfJson() in this case
would cause the build script to fail.

Would it be safer to check if j.metric_expr is None before calling
ToPerfJson()?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260707034019.241762-1-irogers@google.com?part=1

  reply	other threads:[~2026-07-07  3:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07  3:40 [PATCH v1 0/3] perf jevents: Deterministic build fix and mypy cleanliness Ian Rogers
2026-07-07  3:40 ` [PATCH v1 1/3] perf jevents: Add more components to the metric sorting order Ian Rogers
2026-07-07  3:58   ` sashiko-bot [this message]
2026-07-07  3:40 ` [PATCH v1 2/3] perf jevents: Add python type annotations Ian Rogers
2026-07-07  3:40 ` [PATCH v1 3/3] perf jevents metric: " Ian Rogers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260707035832.6F0941F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=irogers@google.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox