lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAP-5=fWa=zNK_ecpWGoGggHCQx7z-oW0eGMQf19Maywg0QK=4g@mail.gmail.com>
Date:   Thu, 8 Dec 2022 09:41:55 -0800
From:   Ian Rogers <irogers@...gle.com>
To:     Arnaldo Carvalho de Melo <acme@...nel.org>,
        John Garry <john.g.garry@...cle.com>
Cc:     Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...nel.org>,
        Namhyung Kim <namhyung@...nel.org>,
        Sumanth Korikkar <sumanthk@...ux.ibm.com>,
        Thomas Richter <tmricht@...ux.ibm.com>,
        linux-kernel@...r.kernel.org, linux-perf-users@...r.kernel.org,
        Stephane Eranian <eranian@...gle.com>
Subject: Re: [PATCH v4] perf jevents: Parse metrics during conversion

Apologies, I found an issue with a double-if. Could you add the 1 line
fix plus test:

diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric.py
index cc451a265751..4797ed4fd817 100644
--- a/tools/perf/pmu-events/metric.py
+++ b/tools/perf/pmu-events/metric.py
@@ -462,6 +462,7 @@ class _RewriteIfExpToSelect(ast.NodeTransformer):

  def visit_IfExp(self, node):
    # pylint: disable=invalid-name
+    self.generic_visit(node)
    call = ast.Call(
        func=ast.Name(id='Select', ctx=ast.Load()),
        args=[node.body, node.test, node.orelse],
diff --git a/tools/perf/pmu-events/metric_test.py
b/tools/perf/pmu-events/metric_test.py
index 4741b7b6612d..6980f452df0a 100644
--- a/tools/perf/pmu-events/metric_test.py
+++ b/tools/perf/pmu-events/metric_test.py
@@ -87,6 +87,10 @@ class TestMetricExpressions(unittest.TestCase):
    after = r'min((a + b if c > 1 else c + d), e + f)'
    self.assertEqual(ParsePerfJson(before).ToPerfJson(), after)

+    before = r'a if b else c if d else e'
+    after = r'(a if b else (c if d else e))'
+    self.assertEqual(ParsePerfJson(before).ToPerfJson(), after)
+
  def test_ToPython(self):
    # pylint: disable=eval-used
    # Based on an example of a real metric.

Thanks,
Ian

On Wed, Dec 7, 2022 at 9:47 AM Arnaldo Carvalho de Melo <acme@...nel.org> wrote:
>
> Em Wed, Dec 07, 2022 at 05:42:52PM +0000, John Garry escreveu:
> > On 07/12/2022 17:40, Arnaldo Carvalho de Melo wrote:
> > > Em Tue, Dec 06, 2022 at 09:59:08PM -0800, Ian Rogers escreveu:
> > > > Currently the 'MetricExpr' json value is passed from the json
> > > > file to the pmu-events.c. This change introduces an expression
> > > > tree that is parsed into. The parsing is done largely by using
> > > > operator overloading and python's 'eval' function. Two advantages
> > > > in doing this are:
> > > John, what tag can I get from you? 😄
> > >
> > > - Arnaldo
> > Sure,
> > Reviewed-by: John Garry <john.g.garry@...cle.com>
>
> Thanks a lot!
>
> - Arnaldo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ