linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf jevents: Raise exception for no definition of a arch std event
@ 2023-08-07 11:16 John Garry
  2023-08-10  5:10 ` Ilkka Koskinen
  0 siblings, 1 reply; 6+ messages in thread
From: John Garry @ 2023-08-07 11:16 UTC (permalink / raw)
  To: irogers, acme; +Cc: linux-perf-users, linux-kernel, ilkka, John Garry

Recently Ilkka reported that the JSONs for the AmpereOne arm64-based
platform included a dud event which referenced a non-existent arch std
event [0].

Previously in the times of jevents.c, we would raise an exception for this.

This is still invalid, even though the current code just ignores such an
event.

Re-introduce code to raise an exception for when no definition exists to
help catch as many invalid JSONs as possible.

[0] https://lore.kernel.org/linux-perf-users/9e851e2a-26c7-ba78-cb20-be4337b2916a@oracle.com/

Signed-off-by: John Garry <john.g.garry@oracle.com>
---
Please do not apply before [0], above.

diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py
index 8cd561aa606a..98cccc3fcbbd 100755
--- a/tools/perf/pmu-events/jevents.py
+++ b/tools/perf/pmu-events/jevents.py
@@ -347,12 +347,15 @@ class JsonEvent:
       if self.desc and not self.desc.endswith('. '):
         self.desc += '. '
       self.desc = (self.desc if self.desc else '') + ('Unit: ' + self.pmu + ' ')
-    if arch_std and arch_std.lower() in _arch_std_events:
-      event = _arch_std_events[arch_std.lower()].event
-      # Copy from the architecture standard event to self for undefined fields.
-      for attr, value in _arch_std_events[arch_std.lower()].__dict__.items():
-        if hasattr(self, attr) and not getattr(self, attr):
-          setattr(self, attr, value)
+    if arch_std:
+      if arch_std.lower() in _arch_std_events:
+        event = _arch_std_events[arch_std.lower()].event
+        # Copy from the architecture standard event to self for undefined fields.
+        for attr, value in _arch_std_events[arch_std.lower()].__dict__.items():
+          if hasattr(self, attr) and not getattr(self, attr):
+            setattr(self, attr, value)
+      else:
+        raise argparse.ArgumentTypeError('Cannot find arch std event:', arch_std)
 
     self.event = real_event(self.name, event)
 
-- 
2.35.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf jevents: Raise exception for no definition of a arch std event
  2023-08-07 11:16 [PATCH] perf jevents: Raise exception for no definition of a arch std event John Garry
@ 2023-08-10  5:10 ` Ilkka Koskinen
  2023-08-10 19:27   ` Ian Rogers
  0 siblings, 1 reply; 6+ messages in thread
From: Ilkka Koskinen @ 2023-08-10  5:10 UTC (permalink / raw)
  To: John Garry; +Cc: irogers, acme, linux-perf-users, linux-kernel, ilkka


Hi John,

On Mon, 7 Aug 2023, John Garry wrote:
> Recently Ilkka reported that the JSONs for the AmpereOne arm64-based
> platform included a dud event which referenced a non-existent arch std
> event [0].

I wish I had found the bug in my patch a long time ago but, in fact, it 
was Dave Kleikamp who initially pointed it out to me and figured out the 
difference between jevents.c and jevents.py when porting the patch to 5.15 
kernel.

http://lists.infradead.org/pipermail/linux-arm-kernel/2023-June/844874.html

>
> Previously in the times of jevents.c, we would raise an exception for this.
>
> This is still invalid, even though the current code just ignores such an
> event.
>
> Re-introduce code to raise an exception for when no definition exists to
> help catch as many invalid JSONs as possible.
>
> [0] https://lore.kernel.org/linux-perf-users/9e851e2a-26c7-ba78-cb20-be4337b2916a@oracle.com/
>
> Signed-off-by: John Garry <john.g.garry@oracle.com>

Thanks for the patch! I quickly tested it and it worked as expected. Just 
in case this is needed:

Tested-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>


Cheers, Ilkka

> ---
> Please do not apply before [0], above.
>
> diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py
> index 8cd561aa606a..98cccc3fcbbd 100755
> --- a/tools/perf/pmu-events/jevents.py
> +++ b/tools/perf/pmu-events/jevents.py
> @@ -347,12 +347,15 @@ class JsonEvent:
>       if self.desc and not self.desc.endswith('. '):
>         self.desc += '. '
>       self.desc = (self.desc if self.desc else '') + ('Unit: ' + self.pmu + ' ')
> -    if arch_std and arch_std.lower() in _arch_std_events:
> -      event = _arch_std_events[arch_std.lower()].event
> -      # Copy from the architecture standard event to self for undefined fields.
> -      for attr, value in _arch_std_events[arch_std.lower()].__dict__.items():
> -        if hasattr(self, attr) and not getattr(self, attr):
> -          setattr(self, attr, value)
> +    if arch_std:
> +      if arch_std.lower() in _arch_std_events:
> +        event = _arch_std_events[arch_std.lower()].event
> +        # Copy from the architecture standard event to self for undefined fields.
> +        for attr, value in _arch_std_events[arch_std.lower()].__dict__.items():
> +          if hasattr(self, attr) and not getattr(self, attr):
> +            setattr(self, attr, value)
> +      else:
> +        raise argparse.ArgumentTypeError('Cannot find arch std event:', arch_std)
>
>     self.event = real_event(self.name, event)
>
> -- 
> 2.35.3
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf jevents: Raise exception for no definition of a arch std event
  2023-08-10  5:10 ` Ilkka Koskinen
@ 2023-08-10 19:27   ` Ian Rogers
  2023-08-21 10:46     ` John Garry
  0 siblings, 1 reply; 6+ messages in thread
From: Ian Rogers @ 2023-08-10 19:27 UTC (permalink / raw)
  To: Ilkka Koskinen; +Cc: John Garry, acme, linux-perf-users, linux-kernel

On Wed, Aug 9, 2023 at 10:11 PM Ilkka Koskinen
<ilkka@os.amperecomputing.com> wrote:
>
>
> Hi John,
>
> On Mon, 7 Aug 2023, John Garry wrote:
> > Recently Ilkka reported that the JSONs for the AmpereOne arm64-based
> > platform included a dud event which referenced a non-existent arch std
> > event [0].
>
> I wish I had found the bug in my patch a long time ago but, in fact, it
> was Dave Kleikamp who initially pointed it out to me and figured out the
> difference between jevents.c and jevents.py when porting the patch to 5.15
> kernel.
>
> http://lists.infradead.org/pipermail/linux-arm-kernel/2023-June/844874.html
>
> >
> > Previously in the times of jevents.c, we would raise an exception for this.
> >
> > This is still invalid, even though the current code just ignores such an
> > event.
> >
> > Re-introduce code to raise an exception for when no definition exists to
> > help catch as many invalid JSONs as possible.
> >
> > [0] https://lore.kernel.org/linux-perf-users/9e851e2a-26c7-ba78-cb20-be4337b2916a@oracle.com/
> >
> > Signed-off-by: John Garry <john.g.garry@oracle.com>
>
> Thanks for the patch! I quickly tested it and it worked as expected. Just
> in case this is needed:
>
> Tested-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>

Reviewed-by: Ian Rogers <irogers@google.com>

Thanks,
Ian

> Cheers, Ilkka
>
> > ---
> > Please do not apply before [0], above.
> >
> > diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py
> > index 8cd561aa606a..98cccc3fcbbd 100755
> > --- a/tools/perf/pmu-events/jevents.py
> > +++ b/tools/perf/pmu-events/jevents.py
> > @@ -347,12 +347,15 @@ class JsonEvent:
> >       if self.desc and not self.desc.endswith('. '):
> >         self.desc += '. '
> >       self.desc = (self.desc if self.desc else '') + ('Unit: ' + self.pmu + ' ')
> > -    if arch_std and arch_std.lower() in _arch_std_events:
> > -      event = _arch_std_events[arch_std.lower()].event
> > -      # Copy from the architecture standard event to self for undefined fields.
> > -      for attr, value in _arch_std_events[arch_std.lower()].__dict__.items():
> > -        if hasattr(self, attr) and not getattr(self, attr):
> > -          setattr(self, attr, value)
> > +    if arch_std:
> > +      if arch_std.lower() in _arch_std_events:
> > +        event = _arch_std_events[arch_std.lower()].event
> > +        # Copy from the architecture standard event to self for undefined fields.
> > +        for attr, value in _arch_std_events[arch_std.lower()].__dict__.items():
> > +          if hasattr(self, attr) and not getattr(self, attr):
> > +            setattr(self, attr, value)
> > +      else:
> > +        raise argparse.ArgumentTypeError('Cannot find arch std event:', arch_std)
> >
> >     self.event = real_event(self.name, event)
> >
> > --
> > 2.35.3
> >
> >

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf jevents: Raise exception for no definition of a arch std event
  2023-08-10 19:27   ` Ian Rogers
@ 2023-08-21 10:46     ` John Garry
  2023-08-21 13:01       ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 6+ messages in thread
From: John Garry @ 2023-08-21 10:46 UTC (permalink / raw)
  To: Ian Rogers, Ilkka Koskinen; +Cc: acme, linux-perf-users, linux-kernel

On 10/08/2023 20:27, Ian Rogers wrote:
> On Wed, Aug 9, 2023 at 10:11 PM Ilkka Koskinen
> <ilkka@os.amperecomputing.com> wrote:
>>
>>
>> Hi John,
>>
>> On Mon, 7 Aug 2023, John Garry wrote:
>>> Recently Ilkka reported that the JSONs for the AmpereOne arm64-based
>>> platform included a dud event which referenced a non-existent arch std
>>> event [0].
>>
>> I wish I had found the bug in my patch a long time ago but, in fact, it
>> was Dave Kleikamp who initially pointed it out to me and figured out the
>> difference between jevents.c and jevents.py when porting the patch to 5.15
>> kernel.
>>
>> https://urldefense.com/v3/__http://lists.infradead.org/pipermail/linux-arm-kernel/2023-June/844874.html__;!!ACWV5N9M2RV99hQ!It9EhKK4s2uBUJyQvLg-ruUfENAA6Sw7TWVo_hF8XmFoQ6q565iYafTnN-yoBNh3EQ1IFa2tHknUjNHs5dI$
>>
>>>
>>> Previously in the times of jevents.c, we would raise an exception for this.
>>>
>>> This is still invalid, even though the current code just ignores such an
>>> event.
>>>
>>> Re-introduce code to raise an exception for when no definition exists to
>>> help catch as many invalid JSONs as possible.
>>>
>>> [0] https://urldefense.com/v3/__https://lore.kernel.org/linux-perf-users/9e851e2a-26c7-ba78-cb20-be4337b2916a@oracle.com/__;!!ACWV5N9M2RV99hQ!It9EhKK4s2uBUJyQvLg-ruUfENAA6Sw7TWVo_hF8XmFoQ6q565iYafTnN-yoBNh3EQ1IFa2tHknU_t28TiE$
>>>
>>> Signed-off-by: John Garry <john.g.garry@oracle.com>
>>
>> Thanks for the patch! I quickly tested it and it worked as expected. Just
>> in case this is needed:
>>
>> Tested-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
> 
> Reviewed-by: Ian Rogers <irogers@google.com>

Hi Arnaldo,

Can you consider applying this patch along with 
https://lore.kernel.org/linux-perf-users/CAP-5=fX2uE=B_Vb90nn5EV0mw+AJBpjDecP9w29OUn=j7HKPPg@mail.gmail.com/

I think that we should expect another version of that series with 
changes elsewhere.

Thanks,
John

> 
> Thanks,
> Ian
> 
>> Cheers, Ilkka
>>
>>> ---
>>> Please do not apply before [0], above.
>>>
>>> diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py
>>> index 8cd561aa606a..98cccc3fcbbd 100755
>>> --- a/tools/perf/pmu-events/jevents.py
>>> +++ b/tools/perf/pmu-events/jevents.py
>>> @@ -347,12 +347,15 @@ class JsonEvent:
>>>        if self.desc and not self.desc.endswith('. '):
>>>          self.desc += '. '
>>>        self.desc = (self.desc if self.desc else '') + ('Unit: ' + self.pmu + ' ')
>>> -    if arch_std and arch_std.lower() in _arch_std_events:
>>> -      event = _arch_std_events[arch_std.lower()].event
>>> -      # Copy from the architecture standard event to self for undefined fields.
>>> -      for attr, value in _arch_std_events[arch_std.lower()].__dict__.items():
>>> -        if hasattr(self, attr) and not getattr(self, attr):
>>> -          setattr(self, attr, value)
>>> +    if arch_std:
>>> +      if arch_std.lower() in _arch_std_events:
>>> +        event = _arch_std_events[arch_std.lower()].event
>>> +        # Copy from the architecture standard event to self for undefined fields.
>>> +        for attr, value in _arch_std_events[arch_std.lower()].__dict__.items():
>>> +          if hasattr(self, attr) and not getattr(self, attr):
>>> +            setattr(self, attr, value)
>>> +      else:
>>> +        raise argparse.ArgumentTypeError('Cannot find arch std event:', arch_std)
>>>
>>>      self.event = real_event(self.name, event)
>>>
>>> --
>>> 2.35.3
>>>
>>>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf jevents: Raise exception for no definition of a arch std event
  2023-08-21 10:46     ` John Garry
@ 2023-08-21 13:01       ` Arnaldo Carvalho de Melo
  2023-08-26 19:30         ` Ilkka Koskinen
  0 siblings, 1 reply; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-08-21 13:01 UTC (permalink / raw)
  To: John Garry; +Cc: Ian Rogers, Ilkka Koskinen, linux-perf-users, linux-kernel

Em Mon, Aug 21, 2023 at 11:46:20AM +0100, John Garry escreveu:
> On 10/08/2023 20:27, Ian Rogers wrote:
> > On Wed, Aug 9, 2023 at 10:11 PM Ilkka Koskinen
> > <ilkka@os.amperecomputing.com> wrote:
> > > 
> > > 
> > > Hi John,
> > > 
> > > On Mon, 7 Aug 2023, John Garry wrote:
> > > > Recently Ilkka reported that the JSONs for the AmpereOne arm64-based
> > > > platform included a dud event which referenced a non-existent arch std
> > > > event [0].
> > > 
> > > I wish I had found the bug in my patch a long time ago but, in fact, it
> > > was Dave Kleikamp who initially pointed it out to me and figured out the
> > > difference between jevents.c and jevents.py when porting the patch to 5.15
> > > kernel.
> > > 
> > > https://urldefense.com/v3/__http://lists.infradead.org/pipermail/linux-arm-kernel/2023-June/844874.html__;!!ACWV5N9M2RV99hQ!It9EhKK4s2uBUJyQvLg-ruUfENAA6Sw7TWVo_hF8XmFoQ6q565iYafTnN-yoBNh3EQ1IFa2tHknUjNHs5dI$
> > > 
> > > > 
> > > > Previously in the times of jevents.c, we would raise an exception for this.
> > > > 
> > > > This is still invalid, even though the current code just ignores such an
> > > > event.
> > > > 
> > > > Re-introduce code to raise an exception for when no definition exists to
> > > > help catch as many invalid JSONs as possible.
> > > > 
> > > > [0] https://urldefense.com/v3/__https://lore.kernel.org/linux-perf-users/9e851e2a-26c7-ba78-cb20-be4337b2916a@oracle.com/__;!!ACWV5N9M2RV99hQ!It9EhKK4s2uBUJyQvLg-ruUfENAA6Sw7TWVo_hF8XmFoQ6q565iYafTnN-yoBNh3EQ1IFa2tHknU_t28TiE$
> > > > 
> > > > Signed-off-by: John Garry <john.g.garry@oracle.com>
> > > 
> > > Thanks for the patch! I quickly tested it and it worked as expected. Just
> > > in case this is needed:
> > > 
> > > Tested-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
> > 
> > Reviewed-by: Ian Rogers <irogers@google.com>
> 
> Hi Arnaldo,
> 
> Can you consider applying this patch along with https://lore.kernel.org/linux-perf-users/CAP-5=fX2uE=B_Vb90nn5EV0mw+AJBpjDecP9w29OUn=j7HKPPg@mail.gmail.com/
> 
> I think that we should expect another version of that series with changes
> elsewhere.

Done, thanks for the ping.

- Arnaldo
 
> Thanks,
> John
> 
> > 
> > Thanks,
> > Ian
> > 
> > > Cheers, Ilkka
> > > 
> > > > ---
> > > > Please do not apply before [0], above.
> > > > 
> > > > diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py
> > > > index 8cd561aa606a..98cccc3fcbbd 100755
> > > > --- a/tools/perf/pmu-events/jevents.py
> > > > +++ b/tools/perf/pmu-events/jevents.py
> > > > @@ -347,12 +347,15 @@ class JsonEvent:
> > > >        if self.desc and not self.desc.endswith('. '):
> > > >          self.desc += '. '
> > > >        self.desc = (self.desc if self.desc else '') + ('Unit: ' + self.pmu + ' ')
> > > > -    if arch_std and arch_std.lower() in _arch_std_events:
> > > > -      event = _arch_std_events[arch_std.lower()].event
> > > > -      # Copy from the architecture standard event to self for undefined fields.
> > > > -      for attr, value in _arch_std_events[arch_std.lower()].__dict__.items():
> > > > -        if hasattr(self, attr) and not getattr(self, attr):
> > > > -          setattr(self, attr, value)
> > > > +    if arch_std:
> > > > +      if arch_std.lower() in _arch_std_events:
> > > > +        event = _arch_std_events[arch_std.lower()].event
> > > > +        # Copy from the architecture standard event to self for undefined fields.
> > > > +        for attr, value in _arch_std_events[arch_std.lower()].__dict__.items():
> > > > +          if hasattr(self, attr) and not getattr(self, attr):
> > > > +            setattr(self, attr, value)
> > > > +      else:
> > > > +        raise argparse.ArgumentTypeError('Cannot find arch std event:', arch_std)
> > > > 
> > > >      self.event = real_event(self.name, event)
> > > > 
> > > > --
> > > > 2.35.3
> > > > 
> > > > 
> 

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf jevents: Raise exception for no definition of a arch std event
  2023-08-21 13:01       ` Arnaldo Carvalho de Melo
@ 2023-08-26 19:30         ` Ilkka Koskinen
  0 siblings, 0 replies; 6+ messages in thread
From: Ilkka Koskinen @ 2023-08-26 19:30 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: John Garry, Ian Rogers, Ilkka Koskinen, linux-perf-users,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 4766 bytes --]


Hi Arnaldo,

On Mon, 21 Aug 2023, Arnaldo Carvalho de Melo wrote:
> Em Mon, Aug 21, 2023 at 11:46:20AM +0100, John Garry escreveu:
>> On 10/08/2023 20:27, Ian Rogers wrote:
>>> On Wed, Aug 9, 2023 at 10:11 PM Ilkka Koskinen
>>> <ilkka@os.amperecomputing.com> wrote:
>>>>
>>>>
>>>> Hi John,
>>>>
>>>> On Mon, 7 Aug 2023, John Garry wrote:
>>>>> Recently Ilkka reported that the JSONs for the AmpereOne arm64-based
>>>>> platform included a dud event which referenced a non-existent arch std
>>>>> event [0].
>>>>
>>>> I wish I had found the bug in my patch a long time ago but, in fact, it
>>>> was Dave Kleikamp who initially pointed it out to me and figured out the
>>>> difference between jevents.c and jevents.py when porting the patch to 5.15
>>>> kernel.
>>>>
>>>> https://urldefense.com/v3/__http://lists.infradead.org/pipermail/linux-arm-kernel/2023-June/844874.html__;!!ACWV5N9M2RV99hQ!It9EhKK4s2uBUJyQvLg-ruUfENAA6Sw7TWVo_hF8XmFoQ6q565iYafTnN-yoBNh3EQ1IFa2tHknUjNHs5dI$
>>>>
>>>>>
>>>>> Previously in the times of jevents.c, we would raise an exception for this.
>>>>>
>>>>> This is still invalid, even though the current code just ignores such an
>>>>> event.
>>>>>
>>>>> Re-introduce code to raise an exception for when no definition exists to
>>>>> help catch as many invalid JSONs as possible.
>>>>>
>>>>> [0] https://urldefense.com/v3/__https://lore.kernel.org/linux-perf-users/9e851e2a-26c7-ba78-cb20-be4337b2916a@oracle.com/__;!!ACWV5N9M2RV99hQ!It9EhKK4s2uBUJyQvLg-ruUfENAA6Sw7TWVo_hF8XmFoQ6q565iYafTnN-yoBNh3EQ1IFa2tHknU_t28TiE$
>>>>>
>>>>> Signed-off-by: John Garry <john.g.garry@oracle.com>
>>>>
>>>> Thanks for the patch! I quickly tested it and it worked as expected. Just
>>>> in case this is needed:
>>>>
>>>> Tested-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
>>>
>>> Reviewed-by: Ian Rogers <irogers@google.com>
>>
>> Hi Arnaldo,
>>
>> Can you consider applying this patch along with https://lore.kernel.org/linux-perf-users/CAP-5=fX2uE=B_Vb90nn5EV0mw+AJBpjDecP9w29OUn=j7HKPPg@mail.gmail.com/
>>
>> I think that we should expect another version of that series with changes
>> elsewhere.
>
> Done, thanks for the ping.
>

Sorry, I completely missed these two emails for some reason.

I finally have the fixes for the metrics patch [1] as it took a while to 
verify some wrong equations that were found too. I was planning to submit 
v2 of the whole patchset but I can see you picked all of them already.

How should we do this? The original metrics patch had issues that John and 
Ian pointed out. Would it be best if you dropped it from perf-tools-next 
branch since it's not required by other patches and once John and Ian acks 
the fixed version, you could pick up the new one? Btw, I just submitted v2 
of the metric patch [2]


[1] https://lore.kernel.org/r/20230803211331.140553-4-ilkka@os.amperecomputing.com
705ed549148f perf vendor events arm64: Add AmpereOne metrics

[2] [PATCH v2] perf vendor events arm64: Add AmpereOne metrics
https://lore.kernel.org/linux-perf-users/20230826192352.3043220-1-ilkka@os.amperecomputing.com/T/#u

Cheers, Ilkka



> - Arnaldo
>
>> Thanks,
>> John
>>
>>>
>>> Thanks,
>>> Ian
>>>
>>>> Cheers, Ilkka
>>>>
>>>>> ---
>>>>> Please do not apply before [0], above.
>>>>>
>>>>> diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py
>>>>> index 8cd561aa606a..98cccc3fcbbd 100755
>>>>> --- a/tools/perf/pmu-events/jevents.py
>>>>> +++ b/tools/perf/pmu-events/jevents.py
>>>>> @@ -347,12 +347,15 @@ class JsonEvent:
>>>>>        if self.desc and not self.desc.endswith('. '):
>>>>>          self.desc += '. '
>>>>>        self.desc = (self.desc if self.desc else '') + ('Unit: ' + self.pmu + ' ')
>>>>> -    if arch_std and arch_std.lower() in _arch_std_events:
>>>>> -      event = _arch_std_events[arch_std.lower()].event
>>>>> -      # Copy from the architecture standard event to self for undefined fields.
>>>>> -      for attr, value in _arch_std_events[arch_std.lower()].__dict__.items():
>>>>> -        if hasattr(self, attr) and not getattr(self, attr):
>>>>> -          setattr(self, attr, value)
>>>>> +    if arch_std:
>>>>> +      if arch_std.lower() in _arch_std_events:
>>>>> +        event = _arch_std_events[arch_std.lower()].event
>>>>> +        # Copy from the architecture standard event to self for undefined fields.
>>>>> +        for attr, value in _arch_std_events[arch_std.lower()].__dict__.items():
>>>>> +          if hasattr(self, attr) and not getattr(self, attr):
>>>>> +            setattr(self, attr, value)
>>>>> +      else:
>>>>> +        raise argparse.ArgumentTypeError('Cannot find arch std event:', arch_std)
>>>>>
>>>>>      self.event = real_event(self.name, event)
>>>>>
>>>>> --
>>>>> 2.35.3
>>>>>
>>>>>
>>
>
> -- 
>
> - Arnaldo
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-08-26 19:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-07 11:16 [PATCH] perf jevents: Raise exception for no definition of a arch std event John Garry
2023-08-10  5:10 ` Ilkka Koskinen
2023-08-10 19:27   ` Ian Rogers
2023-08-21 10:46     ` John Garry
2023-08-21 13:01       ` Arnaldo Carvalho de Melo
2023-08-26 19:30         ` Ilkka Koskinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).