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] [day] [month] [year] [list]
Date:   Mon, 12 Dec 2022 12:46:06 -0300
From:   Arnaldo Carvalho de Melo <acme@...nel.org>
To:     Ian Rogers <irogers@...gle.com>
Cc:     John Garry <john.g.garry@...cle.com>,
        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

Em Thu, Dec 08, 2022 at 09:41:55AM -0800, Ian Rogers escreveu:
> Apologies, I found an issue with a double-if. Could you add the 1 line
> fix plus test:

Had to apply manually, the patch was munged, end result should be the
same:


diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric.py
index cc451a26575185f4..4797ed4fd817b1a0 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 4741b7b6612dc268..15315d0f716caf4e 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 =3D r'a if b else c if d else e'
+    after =3D 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.
 
> 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

-- 

- Arnaldo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ