linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf script: Skip dummy event attr check
@ 2022-08-31 12:40 Jiri Olsa
  2022-08-31 16:02 ` Ian Rogers
  0 siblings, 1 reply; 10+ messages in thread
From: Jiri Olsa @ 2022-08-31 12:40 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Hongtao Yu, Namhyung Kim, lkml, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Ian Rogers, linux-perf-users

Hongtao Yu reported problem when displaying uregs in perf script
for system wide perf.data:

  # perf script -F uregs | head -10
  Samples for 'dummy:HG' event do not have UREGS attribute set. Cannot print 'uregs' field.

The problem is the extra dummy event added for system wide,
which does not have proper sample_type setup.

Skipping attr check completely for dummy event as suggested
by Namhyung, because it does not have any samples anyway.

Reported-by: Hongtao Yu <hoy@fb.com>
Suggested-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/builtin-script.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 13580a9c50b8..304d234d8e84 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -566,6 +566,8 @@ static struct evsel *find_first_output_type(struct evlist *evlist,
 	struct evsel *evsel;
 
 	evlist__for_each_entry(evlist, evsel) {
+		if (evsel__is_dummy_event(evsel))
+			continue;
 		if (output_type(evsel->core.attr.type) == (int)type)
 			return evsel;
 	}
-- 
2.37.2


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

* Re: [PATCH] perf script: Skip dummy event attr check
  2022-08-31 12:40 [PATCH] perf script: Skip dummy event attr check Jiri Olsa
@ 2022-08-31 16:02 ` Ian Rogers
  2022-08-31 16:23   ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 10+ messages in thread
From: Ian Rogers @ 2022-08-31 16:02 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Arnaldo Carvalho de Melo, Hongtao Yu, Namhyung Kim, lkml,
	Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	linux-perf-users

On Wed, Aug 31, 2022 at 5:40 AM Jiri Olsa <jolsa@kernel.org> wrote:
>
> Hongtao Yu reported problem when displaying uregs in perf script
> for system wide perf.data:
>
>   # perf script -F uregs | head -10
>   Samples for 'dummy:HG' event do not have UREGS attribute set. Cannot print 'uregs' field.
>
> The problem is the extra dummy event added for system wide,
> which does not have proper sample_type setup.
>
> Skipping attr check completely for dummy event as suggested
> by Namhyung, because it does not have any samples anyway.
>
> Reported-by: Hongtao Yu <hoy@fb.com>
> Suggested-by: Namhyung Kim <namhyung@kernel.org>
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>

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

Thanks,
Ian

> ---
>  tools/perf/builtin-script.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> index 13580a9c50b8..304d234d8e84 100644
> --- a/tools/perf/builtin-script.c
> +++ b/tools/perf/builtin-script.c
> @@ -566,6 +566,8 @@ static struct evsel *find_first_output_type(struct evlist *evlist,
>         struct evsel *evsel;
>
>         evlist__for_each_entry(evlist, evsel) {
> +               if (evsel__is_dummy_event(evsel))
> +                       continue;
>                 if (output_type(evsel->core.attr.type) == (int)type)
>                         return evsel;
>         }
> --
> 2.37.2
>

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

* Re: [PATCH] perf script: Skip dummy event attr check
  2022-08-31 16:02 ` Ian Rogers
@ 2022-08-31 16:23   ` Arnaldo Carvalho de Melo
  2022-09-07  2:49     ` Xing Zhengjun
  0 siblings, 1 reply; 10+ messages in thread
From: Arnaldo Carvalho de Melo @ 2022-08-31 16:23 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Jiri Olsa, Hongtao Yu, Namhyung Kim, lkml, Peter Zijlstra,
	Ingo Molnar, Mark Rutland, Alexander Shishkin, linux-perf-users

Em Wed, Aug 31, 2022 at 09:02:46AM -0700, Ian Rogers escreveu:
> On Wed, Aug 31, 2022 at 5:40 AM Jiri Olsa <jolsa@kernel.org> wrote:
> >
> > Hongtao Yu reported problem when displaying uregs in perf script
> > for system wide perf.data:
> >
> >   # perf script -F uregs | head -10
> >   Samples for 'dummy:HG' event do not have UREGS attribute set. Cannot print 'uregs' field.
> >
> > The problem is the extra dummy event added for system wide,
> > which does not have proper sample_type setup.
> >
> > Skipping attr check completely for dummy event as suggested
> > by Namhyung, because it does not have any samples anyway.
> >
> > Reported-by: Hongtao Yu <hoy@fb.com>
> > Suggested-by: Namhyung Kim <namhyung@kernel.org>
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> 
> Acked-by: Ian Rogers <irogers@google.com>

Thanks, applied to perf/urgent.

- Arnaldo

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

* Re: [PATCH] perf script: Skip dummy event attr check
  2022-08-31 16:23   ` Arnaldo Carvalho de Melo
@ 2022-09-07  2:49     ` Xing Zhengjun
  2022-09-07  4:50       ` Namhyung Kim
  0 siblings, 1 reply; 10+ messages in thread
From: Xing Zhengjun @ 2022-09-07  2:49 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Ian Rogers, Jiri Olsa
  Cc: Hongtao Yu, Namhyung Kim, lkml, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, linux-perf-users, Liang, Kan

Hi,

On 9/1/2022 12:23 AM, Arnaldo Carvalho de Melo wrote:
> Em Wed, Aug 31, 2022 at 09:02:46AM -0700, Ian Rogers escreveu:
>> On Wed, Aug 31, 2022 at 5:40 AM Jiri Olsa <jolsa@kernel.org> wrote:
>>>
>>> Hongtao Yu reported problem when displaying uregs in perf script
>>> for system wide perf.data:
>>>
>>>    # perf script -F uregs | head -10
>>>    Samples for 'dummy:HG' event do not have UREGS attribute set. Cannot print 'uregs' field.
>>>
>>> The problem is the extra dummy event added for system wide,
>>> which does not have proper sample_type setup.
>>>
>>> Skipping attr check completely for dummy event as suggested
>>> by Namhyung, because it does not have any samples anyway.
>>>
>>> Reported-by: Hongtao Yu <hoy@fb.com>
>>> Suggested-by: Namhyung Kim <namhyung@kernel.org>
>>> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
>>
>> Acked-by: Ian Rogers <irogers@google.com>
> 
> Thanks, applied to perf/urgent.
> 
> - Arnaldo

I have met a similar issue on hybrid systems such as ADL, I apply the 
patch, and it works OK for the normal mode.
  # ./perf record  --intr-regs=di,r8,dx,cx -e 
br_inst_retired.near_call:p -c 1000 --per-thread true
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.024 MB perf.data (25 samples) ]

# ./perf script -F iregs |head -5
  ABI:2    CX:0xffff90e19d024ed8    DX:0x1    DI:0xffff90e19d024ed8 
R8:0xffffba5e437e7b30
  ABI:2    CX:0x7f5239783000    DX:0x80000000    DI:0xffff90e1801eea00 
  R8:0x71
  ABI:2    CX:0x40    DX:0x60    DI:0xffffffff9fde5ab8    R8:0x40
  ABI:2    CX:0x0    DX:0xffffffffffffffff    DI:0xffff90e1877408e8 
R8:0x1
  ABI:2    CX:0xcc0    DX:0x1    DI:0xffff90e187d17c60    R8:0x40

But the issue still happened when running the test in the pipe mode. In 
the pipe mode, it calls process_attr() which still checks the attr for 
the dummy event, so the issue happened.

  # ./perf record -o - --intr-regs=di,r8,dx,cx -e 
br_inst_retired.near_call:p -c 1000 --per-thread true 2>/dev/null|./perf 
script -F iregs |head -5
Samples for 'dummy:HG' event do not have IREGS attribute set. Cannot 
print 'iregs' field.
0x120 [0x90]: failed to process type: 64

I have one test patch which can fix the pipe mode issue.

  ./perf record -o - --intr-regs=di,r8,dx,cx -e 
br_inst_retired.near_call:p -c 1000 --per-thread true 2>/dev/null|./perf 
script -F iregs |head -5
  ABI:2    CX:0xffff90e18119e278    DX:0x0    DI:0xffff90e18119f858 
R8:0xffff90e18119e278
  ABI:2    CX:0x0    DX:0x1    DI:0xfffffa2844a91580    R8:0x402
  ABI:2    CX:0x0    DX:0x0    DI:0x100cca    R8:0x0
  ABI:2    CX:0x0    DX:0x0    DI:0xffffffff9e997ca5    R8:0x0
  ABI:2    CX:0x113ce8000    DX:0xffff90e198f46600 
DI:0xffff90e189de8000    R8:0x290


Fixes: b91e5492f9d7 ("perf record: Add a dummy event on hybrid systems 
to collect metadata records")
Signed-off-by: Zhengjun Xing <zhengjun.xing@linux.intel.com>
---
  tools/perf/builtin-script.c | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 9152e3e45b69..2d863cdb19fe 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -2429,6 +2429,8 @@ static int process_attr(struct perf_tool *tool, 
union perf_event *event,
         }

         if (evsel->core.attr.sample_type) {
+               if (evsel__is_dummy_event(evsel))
+                       return 0;
                 err = evsel__check_attr(evsel, scr->session);
                 if (err)
                         return err;
--
2.25.1

-- 
Zhengjun Xing

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

* Re: [PATCH] perf script: Skip dummy event attr check
  2022-09-07  2:49     ` Xing Zhengjun
@ 2022-09-07  4:50       ` Namhyung Kim
  2022-09-07  5:19         ` Xing Zhengjun
  0 siblings, 1 reply; 10+ messages in thread
From: Namhyung Kim @ 2022-09-07  4:50 UTC (permalink / raw)
  To: Xing Zhengjun
  Cc: Arnaldo Carvalho de Melo, Ian Rogers, Jiri Olsa, Hongtao Yu,
	lkml, Peter Zijlstra, Ingo Molnar, Mark Rutland,
	Alexander Shishkin, linux-perf-users, Liang, Kan

Hello,

On Tue, Sep 6, 2022 at 7:49 PM Xing Zhengjun
<zhengjun.xing@linux.intel.com> wrote:
>
> Hi,
>
> On 9/1/2022 12:23 AM, Arnaldo Carvalho de Melo wrote:
> > Em Wed, Aug 31, 2022 at 09:02:46AM -0700, Ian Rogers escreveu:
> >> On Wed, Aug 31, 2022 at 5:40 AM Jiri Olsa <jolsa@kernel.org> wrote:
> >>>
> >>> Hongtao Yu reported problem when displaying uregs in perf script
> >>> for system wide perf.data:
> >>>
> >>>    # perf script -F uregs | head -10
> >>>    Samples for 'dummy:HG' event do not have UREGS attribute set. Cannot print 'uregs' field.
> >>>
> >>> The problem is the extra dummy event added for system wide,
> >>> which does not have proper sample_type setup.
> >>>
> >>> Skipping attr check completely for dummy event as suggested
> >>> by Namhyung, because it does not have any samples anyway.
> >>>
> >>> Reported-by: Hongtao Yu <hoy@fb.com>
> >>> Suggested-by: Namhyung Kim <namhyung@kernel.org>
> >>> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> >>
> >> Acked-by: Ian Rogers <irogers@google.com>
> >
> > Thanks, applied to perf/urgent.
> >
> > - Arnaldo
>
> I have met a similar issue on hybrid systems such as ADL, I apply the
> patch, and it works OK for the normal mode.
>   # ./perf record  --intr-regs=di,r8,dx,cx -e
> br_inst_retired.near_call:p -c 1000 --per-thread true
> [ perf record: Woken up 1 times to write data ]
> [ perf record: Captured and wrote 0.024 MB perf.data (25 samples) ]
>
> # ./perf script -F iregs |head -5
>   ABI:2    CX:0xffff90e19d024ed8    DX:0x1    DI:0xffff90e19d024ed8
> R8:0xffffba5e437e7b30
>   ABI:2    CX:0x7f5239783000    DX:0x80000000    DI:0xffff90e1801eea00
>   R8:0x71
>   ABI:2    CX:0x40    DX:0x60    DI:0xffffffff9fde5ab8    R8:0x40
>   ABI:2    CX:0x0    DX:0xffffffffffffffff    DI:0xffff90e1877408e8
> R8:0x1
>   ABI:2    CX:0xcc0    DX:0x1    DI:0xffff90e187d17c60    R8:0x40
>
> But the issue still happened when running the test in the pipe mode. In
> the pipe mode, it calls process_attr() which still checks the attr for
> the dummy event, so the issue happened.
>
>   # ./perf record -o - --intr-regs=di,r8,dx,cx -e
> br_inst_retired.near_call:p -c 1000 --per-thread true 2>/dev/null|./perf
> script -F iregs |head -5
> Samples for 'dummy:HG' event do not have IREGS attribute set. Cannot
> print 'iregs' field.
> 0x120 [0x90]: failed to process type: 64
>
> I have one test patch which can fix the pipe mode issue.
>
>   ./perf record -o - --intr-regs=di,r8,dx,cx -e
> br_inst_retired.near_call:p -c 1000 --per-thread true 2>/dev/null|./perf
> script -F iregs |head -5
>   ABI:2    CX:0xffff90e18119e278    DX:0x0    DI:0xffff90e18119f858
> R8:0xffff90e18119e278
>   ABI:2    CX:0x0    DX:0x1    DI:0xfffffa2844a91580    R8:0x402
>   ABI:2    CX:0x0    DX:0x0    DI:0x100cca    R8:0x0
>   ABI:2    CX:0x0    DX:0x0    DI:0xffffffff9e997ca5    R8:0x0
>   ABI:2    CX:0x113ce8000    DX:0xffff90e198f46600
> DI:0xffff90e189de8000    R8:0x290
>
>
> Fixes: b91e5492f9d7 ("perf record: Add a dummy event on hybrid systems
> to collect metadata records")
> Signed-off-by: Zhengjun Xing <zhengjun.xing@linux.intel.com>
> ---
>   tools/perf/builtin-script.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> index 9152e3e45b69..2d863cdb19fe 100644
> --- a/tools/perf/builtin-script.c
> +++ b/tools/perf/builtin-script.c
> @@ -2429,6 +2429,8 @@ static int process_attr(struct perf_tool *tool,
> union perf_event *event,
>          }
>
>          if (evsel->core.attr.sample_type) {
> +               if (evsel__is_dummy_event(evsel))
> +                       return 0;

Maybe we can move this into evsel__check_attr().

Thanks,
Namhyung


>                  err = evsel__check_attr(evsel, scr->session);
>                  if (err)
>                          return err;
> --
> 2.25.1
>
> --
> Zhengjun Xing

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

* Re: [PATCH] perf script: Skip dummy event attr check
  2022-09-07  4:50       ` Namhyung Kim
@ 2022-09-07  5:19         ` Xing Zhengjun
  2022-09-07  8:09           ` Jiri Olsa
  0 siblings, 1 reply; 10+ messages in thread
From: Xing Zhengjun @ 2022-09-07  5:19 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Ian Rogers, Jiri Olsa, Hongtao Yu,
	lkml, Peter Zijlstra, Ingo Molnar, Mark Rutland,
	Alexander Shishkin, linux-perf-users, Liang, Kan



On 9/7/2022 12:50 PM, Namhyung Kim wrote:
> Hello,
> 
> On Tue, Sep 6, 2022 at 7:49 PM Xing Zhengjun
> <zhengjun.xing@linux.intel.com> wrote:
>>
>> Hi,
>>
>> On 9/1/2022 12:23 AM, Arnaldo Carvalho de Melo wrote:
>>> Em Wed, Aug 31, 2022 at 09:02:46AM -0700, Ian Rogers escreveu:
>>>> On Wed, Aug 31, 2022 at 5:40 AM Jiri Olsa <jolsa@kernel.org> wrote:
>>>>>
>>>>> Hongtao Yu reported problem when displaying uregs in perf script
>>>>> for system wide perf.data:
>>>>>
>>>>>     # perf script -F uregs | head -10
>>>>>     Samples for 'dummy:HG' event do not have UREGS attribute set. Cannot print 'uregs' field.
>>>>>
>>>>> The problem is the extra dummy event added for system wide,
>>>>> which does not have proper sample_type setup.
>>>>>
>>>>> Skipping attr check completely for dummy event as suggested
>>>>> by Namhyung, because it does not have any samples anyway.
>>>>>
>>>>> Reported-by: Hongtao Yu <hoy@fb.com>
>>>>> Suggested-by: Namhyung Kim <namhyung@kernel.org>
>>>>> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
>>>>
>>>> Acked-by: Ian Rogers <irogers@google.com>
>>>
>>> Thanks, applied to perf/urgent.
>>>
>>> - Arnaldo
>>
>> I have met a similar issue on hybrid systems such as ADL, I apply the
>> patch, and it works OK for the normal mode.
>>    # ./perf record  --intr-regs=di,r8,dx,cx -e
>> br_inst_retired.near_call:p -c 1000 --per-thread true
>> [ perf record: Woken up 1 times to write data ]
>> [ perf record: Captured and wrote 0.024 MB perf.data (25 samples) ]
>>
>> # ./perf script -F iregs |head -5
>>    ABI:2    CX:0xffff90e19d024ed8    DX:0x1    DI:0xffff90e19d024ed8
>> R8:0xffffba5e437e7b30
>>    ABI:2    CX:0x7f5239783000    DX:0x80000000    DI:0xffff90e1801eea00
>>    R8:0x71
>>    ABI:2    CX:0x40    DX:0x60    DI:0xffffffff9fde5ab8    R8:0x40
>>    ABI:2    CX:0x0    DX:0xffffffffffffffff    DI:0xffff90e1877408e8
>> R8:0x1
>>    ABI:2    CX:0xcc0    DX:0x1    DI:0xffff90e187d17c60    R8:0x40
>>
>> But the issue still happened when running the test in the pipe mode. In
>> the pipe mode, it calls process_attr() which still checks the attr for
>> the dummy event, so the issue happened.
>>
>>    # ./perf record -o - --intr-regs=di,r8,dx,cx -e
>> br_inst_retired.near_call:p -c 1000 --per-thread true 2>/dev/null|./perf
>> script -F iregs |head -5
>> Samples for 'dummy:HG' event do not have IREGS attribute set. Cannot
>> print 'iregs' field.
>> 0x120 [0x90]: failed to process type: 64
>>
>> I have one test patch which can fix the pipe mode issue.
>>
>>    ./perf record -o - --intr-regs=di,r8,dx,cx -e
>> br_inst_retired.near_call:p -c 1000 --per-thread true 2>/dev/null|./perf
>> script -F iregs |head -5
>>    ABI:2    CX:0xffff90e18119e278    DX:0x0    DI:0xffff90e18119f858
>> R8:0xffff90e18119e278
>>    ABI:2    CX:0x0    DX:0x1    DI:0xfffffa2844a91580    R8:0x402
>>    ABI:2    CX:0x0    DX:0x0    DI:0x100cca    R8:0x0
>>    ABI:2    CX:0x0    DX:0x0    DI:0xffffffff9e997ca5    R8:0x0
>>    ABI:2    CX:0x113ce8000    DX:0xffff90e198f46600
>> DI:0xffff90e189de8000    R8:0x290
>>
>>
>> Fixes: b91e5492f9d7 ("perf record: Add a dummy event on hybrid systems
>> to collect metadata records")
>> Signed-off-by: Zhengjun Xing <zhengjun.xing@linux.intel.com>
>> ---
>>    tools/perf/builtin-script.c | 2 ++
>>    1 file changed, 2 insertions(+)
>>
>> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
>> index 9152e3e45b69..2d863cdb19fe 100644
>> --- a/tools/perf/builtin-script.c
>> +++ b/tools/perf/builtin-script.c
>> @@ -2429,6 +2429,8 @@ static int process_attr(struct perf_tool *tool,
>> union perf_event *event,
>>           }
>>
>>           if (evsel->core.attr.sample_type) {
>> +               if (evsel__is_dummy_event(evsel))
>> +                       return 0;
> 
> Maybe we can move this into evsel__check_attr().
> 
> Thanks,
> Namhyung

Yes, the following changes in evsel__check_attr() can fix both normal 
and pipe mode issues, Otherwise, we have to patch everywhere when 
evsel__check_attr() is called.

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 13580a9c50b8..fb76e3191858 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -451,6 +451,9 @@ static int evsel__check_attr(struct evsel *evsel, 
struct perf_session *session)
         allow_user_set = perf_header__has_feat(&session->header,
                                                HEADER_AUXTRACE);

+       if (evsel__is_dummy_event(evsel))
+               allow_user_set = true;
+
         if (PRINT_FIELD(TRACE) &&
             !perf_session__has_traces(session, "record -R"))
                 return -EINVAL;
--
2.25.1

> 
> 
>>                   err = evsel__check_attr(evsel, scr->session);
>>                   if (err)
>>                           return err;
>> --
>> 2.25.1
>>
>> --
>> Zhengjun Xing

-- 
Zhengjun Xing

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

* Re: [PATCH] perf script: Skip dummy event attr check
  2022-09-07  5:19         ` Xing Zhengjun
@ 2022-09-07  8:09           ` Jiri Olsa
  2022-09-07  8:14             ` Namhyung Kim
  0 siblings, 1 reply; 10+ messages in thread
From: Jiri Olsa @ 2022-09-07  8:09 UTC (permalink / raw)
  To: Xing Zhengjun
  Cc: Namhyung Kim, Arnaldo Carvalho de Melo, Ian Rogers, Hongtao Yu,
	lkml, Peter Zijlstra, Ingo Molnar, Mark Rutland,
	Alexander Shishkin, linux-perf-users, Liang, Kan

On Wed, Sep 07, 2022 at 01:19:32PM +0800, Xing Zhengjun wrote:
> 
> 
> On 9/7/2022 12:50 PM, Namhyung Kim wrote:
> > Hello,
> > 
> > On Tue, Sep 6, 2022 at 7:49 PM Xing Zhengjun
> > <zhengjun.xing@linux.intel.com> wrote:
> > > 
> > > Hi,
> > > 
> > > On 9/1/2022 12:23 AM, Arnaldo Carvalho de Melo wrote:
> > > > Em Wed, Aug 31, 2022 at 09:02:46AM -0700, Ian Rogers escreveu:
> > > > > On Wed, Aug 31, 2022 at 5:40 AM Jiri Olsa <jolsa@kernel.org> wrote:
> > > > > > 
> > > > > > Hongtao Yu reported problem when displaying uregs in perf script
> > > > > > for system wide perf.data:
> > > > > > 
> > > > > >     # perf script -F uregs | head -10
> > > > > >     Samples for 'dummy:HG' event do not have UREGS attribute set. Cannot print 'uregs' field.
> > > > > > 
> > > > > > The problem is the extra dummy event added for system wide,
> > > > > > which does not have proper sample_type setup.
> > > > > > 
> > > > > > Skipping attr check completely for dummy event as suggested
> > > > > > by Namhyung, because it does not have any samples anyway.
> > > > > > 
> > > > > > Reported-by: Hongtao Yu <hoy@fb.com>
> > > > > > Suggested-by: Namhyung Kim <namhyung@kernel.org>
> > > > > > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > > > > 
> > > > > Acked-by: Ian Rogers <irogers@google.com>
> > > > 
> > > > Thanks, applied to perf/urgent.
> > > > 
> > > > - Arnaldo
> > > 
> > > I have met a similar issue on hybrid systems such as ADL, I apply the
> > > patch, and it works OK for the normal mode.
> > >    # ./perf record  --intr-regs=di,r8,dx,cx -e
> > > br_inst_retired.near_call:p -c 1000 --per-thread true
> > > [ perf record: Woken up 1 times to write data ]
> > > [ perf record: Captured and wrote 0.024 MB perf.data (25 samples) ]
> > > 
> > > # ./perf script -F iregs |head -5
> > >    ABI:2    CX:0xffff90e19d024ed8    DX:0x1    DI:0xffff90e19d024ed8
> > > R8:0xffffba5e437e7b30
> > >    ABI:2    CX:0x7f5239783000    DX:0x80000000    DI:0xffff90e1801eea00
> > >    R8:0x71
> > >    ABI:2    CX:0x40    DX:0x60    DI:0xffffffff9fde5ab8    R8:0x40
> > >    ABI:2    CX:0x0    DX:0xffffffffffffffff    DI:0xffff90e1877408e8
> > > R8:0x1
> > >    ABI:2    CX:0xcc0    DX:0x1    DI:0xffff90e187d17c60    R8:0x40
> > > 
> > > But the issue still happened when running the test in the pipe mode. In
> > > the pipe mode, it calls process_attr() which still checks the attr for
> > > the dummy event, so the issue happened.
> > > 
> > >    # ./perf record -o - --intr-regs=di,r8,dx,cx -e
> > > br_inst_retired.near_call:p -c 1000 --per-thread true 2>/dev/null|./perf
> > > script -F iregs |head -5
> > > Samples for 'dummy:HG' event do not have IREGS attribute set. Cannot
> > > print 'iregs' field.
> > > 0x120 [0x90]: failed to process type: 64
> > > 
> > > I have one test patch which can fix the pipe mode issue.
> > > 
> > >    ./perf record -o - --intr-regs=di,r8,dx,cx -e
> > > br_inst_retired.near_call:p -c 1000 --per-thread true 2>/dev/null|./perf
> > > script -F iregs |head -5
> > >    ABI:2    CX:0xffff90e18119e278    DX:0x0    DI:0xffff90e18119f858
> > > R8:0xffff90e18119e278
> > >    ABI:2    CX:0x0    DX:0x1    DI:0xfffffa2844a91580    R8:0x402
> > >    ABI:2    CX:0x0    DX:0x0    DI:0x100cca    R8:0x0
> > >    ABI:2    CX:0x0    DX:0x0    DI:0xffffffff9e997ca5    R8:0x0
> > >    ABI:2    CX:0x113ce8000    DX:0xffff90e198f46600
> > > DI:0xffff90e189de8000    R8:0x290
> > > 
> > > 
> > > Fixes: b91e5492f9d7 ("perf record: Add a dummy event on hybrid systems
> > > to collect metadata records")
> > > Signed-off-by: Zhengjun Xing <zhengjun.xing@linux.intel.com>
> > > ---
> > >    tools/perf/builtin-script.c | 2 ++
> > >    1 file changed, 2 insertions(+)
> > > 
> > > diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> > > index 9152e3e45b69..2d863cdb19fe 100644
> > > --- a/tools/perf/builtin-script.c
> > > +++ b/tools/perf/builtin-script.c
> > > @@ -2429,6 +2429,8 @@ static int process_attr(struct perf_tool *tool,
> > > union perf_event *event,
> > >           }
> > > 
> > >           if (evsel->core.attr.sample_type) {
> > > +               if (evsel__is_dummy_event(evsel))
> > > +                       return 0;
> > 
> > Maybe we can move this into evsel__check_attr().
> > 
> > Thanks,
> > Namhyung
> 
> Yes, the following changes in evsel__check_attr() can fix both normal and
> pipe mode issues, Otherwise, we have to patch everywhere when
> evsel__check_attr() is called.
> 
> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> index 13580a9c50b8..fb76e3191858 100644
> --- a/tools/perf/builtin-script.c
> +++ b/tools/perf/builtin-script.c
> @@ -451,6 +451,9 @@ static int evsel__check_attr(struct evsel *evsel, struct
> perf_session *session)
>         allow_user_set = perf_header__has_feat(&session->header,
>                                                HEADER_AUXTRACE);
> 
> +       if (evsel__is_dummy_event(evsel))
> +               allow_user_set = true;
> +

hm, do you need to pass allow_user_set to UREGS check then?

jirka


---
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 13580a9c50b8..30c9cbdee98d 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -451,6 +451,9 @@ static int evsel__check_attr(struct evsel *evsel, struct perf_session *session)
 	allow_user_set = perf_header__has_feat(&session->header,
 					       HEADER_AUXTRACE);
 
+	if (evsel__is_dummy_event(evsel))
+		allow_user_set = true;
+
 	if (PRINT_FIELD(TRACE) &&
 	    !perf_session__has_traces(session, "record -R"))
 		return -EINVAL;
@@ -517,7 +520,7 @@ static int evsel__check_attr(struct evsel *evsel, struct perf_session *session)
 		return -EINVAL;
 
 	if (PRINT_FIELD(UREGS) &&
-	    evsel__check_stype(evsel, PERF_SAMPLE_REGS_USER, "UREGS", PERF_OUTPUT_UREGS))
+	    evsel__do_check_stype(evsel, PERF_SAMPLE_REGS_USER, "UREGS", PERF_OUTPUT_UREGS, allow_user_set))
 		return -EINVAL;
 
 	if (PRINT_FIELD(PHYS_ADDR) &&

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

* Re: [PATCH] perf script: Skip dummy event attr check
  2022-09-07  8:09           ` Jiri Olsa
@ 2022-09-07  8:14             ` Namhyung Kim
  2022-09-07 14:16               ` Jiri Olsa
  0 siblings, 1 reply; 10+ messages in thread
From: Namhyung Kim @ 2022-09-07  8:14 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Xing Zhengjun, Arnaldo Carvalho de Melo, Ian Rogers, Hongtao Yu,
	lkml, Peter Zijlstra, Ingo Molnar, Mark Rutland,
	Alexander Shishkin, linux-perf-users, Liang, Kan

On Wed, Sep 7, 2022 at 1:09 AM Jiri Olsa <olsajiri@gmail.com> wrote:
>
> On Wed, Sep 07, 2022 at 01:19:32PM +0800, Xing Zhengjun wrote:
> >
> >
> > On 9/7/2022 12:50 PM, Namhyung Kim wrote:
> > > Hello,
> > >
> > > On Tue, Sep 6, 2022 at 7:49 PM Xing Zhengjun
> > > <zhengjun.xing@linux.intel.com> wrote:
> > > >
> > > > Hi,
> > > >
> > > > On 9/1/2022 12:23 AM, Arnaldo Carvalho de Melo wrote:
> > > > > Em Wed, Aug 31, 2022 at 09:02:46AM -0700, Ian Rogers escreveu:
> > > > > > On Wed, Aug 31, 2022 at 5:40 AM Jiri Olsa <jolsa@kernel.org> wrote:
> > > > > > >
> > > > > > > Hongtao Yu reported problem when displaying uregs in perf script
> > > > > > > for system wide perf.data:
> > > > > > >
> > > > > > >     # perf script -F uregs | head -10
> > > > > > >     Samples for 'dummy:HG' event do not have UREGS attribute set. Cannot print 'uregs' field.
> > > > > > >
> > > > > > > The problem is the extra dummy event added for system wide,
> > > > > > > which does not have proper sample_type setup.
> > > > > > >
> > > > > > > Skipping attr check completely for dummy event as suggested
> > > > > > > by Namhyung, because it does not have any samples anyway.
> > > > > > >
> > > > > > > Reported-by: Hongtao Yu <hoy@fb.com>
> > > > > > > Suggested-by: Namhyung Kim <namhyung@kernel.org>
> > > > > > > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > > > > >
> > > > > > Acked-by: Ian Rogers <irogers@google.com>
> > > > >
> > > > > Thanks, applied to perf/urgent.
> > > > >
> > > > > - Arnaldo
> > > >
> > > > I have met a similar issue on hybrid systems such as ADL, I apply the
> > > > patch, and it works OK for the normal mode.
> > > >    # ./perf record  --intr-regs=di,r8,dx,cx -e
> > > > br_inst_retired.near_call:p -c 1000 --per-thread true
> > > > [ perf record: Woken up 1 times to write data ]
> > > > [ perf record: Captured and wrote 0.024 MB perf.data (25 samples) ]
> > > >
> > > > # ./perf script -F iregs |head -5
> > > >    ABI:2    CX:0xffff90e19d024ed8    DX:0x1    DI:0xffff90e19d024ed8
> > > > R8:0xffffba5e437e7b30
> > > >    ABI:2    CX:0x7f5239783000    DX:0x80000000    DI:0xffff90e1801eea00
> > > >    R8:0x71
> > > >    ABI:2    CX:0x40    DX:0x60    DI:0xffffffff9fde5ab8    R8:0x40
> > > >    ABI:2    CX:0x0    DX:0xffffffffffffffff    DI:0xffff90e1877408e8
> > > > R8:0x1
> > > >    ABI:2    CX:0xcc0    DX:0x1    DI:0xffff90e187d17c60    R8:0x40
> > > >
> > > > But the issue still happened when running the test in the pipe mode. In
> > > > the pipe mode, it calls process_attr() which still checks the attr for
> > > > the dummy event, so the issue happened.
> > > >
> > > >    # ./perf record -o - --intr-regs=di,r8,dx,cx -e
> > > > br_inst_retired.near_call:p -c 1000 --per-thread true 2>/dev/null|./perf
> > > > script -F iregs |head -5
> > > > Samples for 'dummy:HG' event do not have IREGS attribute set. Cannot
> > > > print 'iregs' field.
> > > > 0x120 [0x90]: failed to process type: 64
> > > >
> > > > I have one test patch which can fix the pipe mode issue.
> > > >
> > > >    ./perf record -o - --intr-regs=di,r8,dx,cx -e
> > > > br_inst_retired.near_call:p -c 1000 --per-thread true 2>/dev/null|./perf
> > > > script -F iregs |head -5
> > > >    ABI:2    CX:0xffff90e18119e278    DX:0x0    DI:0xffff90e18119f858
> > > > R8:0xffff90e18119e278
> > > >    ABI:2    CX:0x0    DX:0x1    DI:0xfffffa2844a91580    R8:0x402
> > > >    ABI:2    CX:0x0    DX:0x0    DI:0x100cca    R8:0x0
> > > >    ABI:2    CX:0x0    DX:0x0    DI:0xffffffff9e997ca5    R8:0x0
> > > >    ABI:2    CX:0x113ce8000    DX:0xffff90e198f46600
> > > > DI:0xffff90e189de8000    R8:0x290
> > > >
> > > >
> > > > Fixes: b91e5492f9d7 ("perf record: Add a dummy event on hybrid systems
> > > > to collect metadata records")
> > > > Signed-off-by: Zhengjun Xing <zhengjun.xing@linux.intel.com>
> > > > ---
> > > >    tools/perf/builtin-script.c | 2 ++
> > > >    1 file changed, 2 insertions(+)
> > > >
> > > > diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> > > > index 9152e3e45b69..2d863cdb19fe 100644
> > > > --- a/tools/perf/builtin-script.c
> > > > +++ b/tools/perf/builtin-script.c
> > > > @@ -2429,6 +2429,8 @@ static int process_attr(struct perf_tool *tool,
> > > > union perf_event *event,
> > > >           }
> > > >
> > > >           if (evsel->core.attr.sample_type) {
> > > > +               if (evsel__is_dummy_event(evsel))
> > > > +                       return 0;
> > >
> > > Maybe we can move this into evsel__check_attr().
> > >
> > > Thanks,
> > > Namhyung
> >
> > Yes, the following changes in evsel__check_attr() can fix both normal and
> > pipe mode issues, Otherwise, we have to patch everywhere when
> > evsel__check_attr() is called.
> >
> > diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> > index 13580a9c50b8..fb76e3191858 100644
> > --- a/tools/perf/builtin-script.c
> > +++ b/tools/perf/builtin-script.c
> > @@ -451,6 +451,9 @@ static int evsel__check_attr(struct evsel *evsel, struct
> > perf_session *session)
> >         allow_user_set = perf_header__has_feat(&session->header,
> >                                                HEADER_AUXTRACE);
> >
> > +       if (evsel__is_dummy_event(evsel))
> > +               allow_user_set = true;
> > +
>
> hm, do you need to pass allow_user_set to UREGS check then?

Well.. actually I thought we can simply return 0 for a dummy event.

Thanks,
Namhyung

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

* Re: [PATCH] perf script: Skip dummy event attr check
  2022-09-07  8:14             ` Namhyung Kim
@ 2022-09-07 14:16               ` Jiri Olsa
  2022-09-08  6:56                 ` Xing Zhengjun
  0 siblings, 1 reply; 10+ messages in thread
From: Jiri Olsa @ 2022-09-07 14:16 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Jiri Olsa, Xing Zhengjun, Arnaldo Carvalho de Melo, Ian Rogers,
	Hongtao Yu, lkml, Peter Zijlstra, Ingo Molnar, Mark Rutland,
	Alexander Shishkin, linux-perf-users, Liang, Kan

On Wed, Sep 07, 2022 at 01:14:52AM -0700, Namhyung Kim wrote:
> On Wed, Sep 7, 2022 at 1:09 AM Jiri Olsa <olsajiri@gmail.com> wrote:
> >
> > On Wed, Sep 07, 2022 at 01:19:32PM +0800, Xing Zhengjun wrote:
> > >
> > >
> > > On 9/7/2022 12:50 PM, Namhyung Kim wrote:
> > > > Hello,
> > > >
> > > > On Tue, Sep 6, 2022 at 7:49 PM Xing Zhengjun
> > > > <zhengjun.xing@linux.intel.com> wrote:
> > > > >
> > > > > Hi,
> > > > >
> > > > > On 9/1/2022 12:23 AM, Arnaldo Carvalho de Melo wrote:
> > > > > > Em Wed, Aug 31, 2022 at 09:02:46AM -0700, Ian Rogers escreveu:
> > > > > > > On Wed, Aug 31, 2022 at 5:40 AM Jiri Olsa <jolsa@kernel.org> wrote:
> > > > > > > >
> > > > > > > > Hongtao Yu reported problem when displaying uregs in perf script
> > > > > > > > for system wide perf.data:
> > > > > > > >
> > > > > > > >     # perf script -F uregs | head -10
> > > > > > > >     Samples for 'dummy:HG' event do not have UREGS attribute set. Cannot print 'uregs' field.
> > > > > > > >
> > > > > > > > The problem is the extra dummy event added for system wide,
> > > > > > > > which does not have proper sample_type setup.
> > > > > > > >
> > > > > > > > Skipping attr check completely for dummy event as suggested
> > > > > > > > by Namhyung, because it does not have any samples anyway.
> > > > > > > >
> > > > > > > > Reported-by: Hongtao Yu <hoy@fb.com>
> > > > > > > > Suggested-by: Namhyung Kim <namhyung@kernel.org>
> > > > > > > > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > > > > > >
> > > > > > > Acked-by: Ian Rogers <irogers@google.com>
> > > > > >
> > > > > > Thanks, applied to perf/urgent.
> > > > > >
> > > > > > - Arnaldo
> > > > >
> > > > > I have met a similar issue on hybrid systems such as ADL, I apply the
> > > > > patch, and it works OK for the normal mode.
> > > > >    # ./perf record  --intr-regs=di,r8,dx,cx -e
> > > > > br_inst_retired.near_call:p -c 1000 --per-thread true
> > > > > [ perf record: Woken up 1 times to write data ]
> > > > > [ perf record: Captured and wrote 0.024 MB perf.data (25 samples) ]
> > > > >
> > > > > # ./perf script -F iregs |head -5
> > > > >    ABI:2    CX:0xffff90e19d024ed8    DX:0x1    DI:0xffff90e19d024ed8
> > > > > R8:0xffffba5e437e7b30
> > > > >    ABI:2    CX:0x7f5239783000    DX:0x80000000    DI:0xffff90e1801eea00
> > > > >    R8:0x71
> > > > >    ABI:2    CX:0x40    DX:0x60    DI:0xffffffff9fde5ab8    R8:0x40
> > > > >    ABI:2    CX:0x0    DX:0xffffffffffffffff    DI:0xffff90e1877408e8
> > > > > R8:0x1
> > > > >    ABI:2    CX:0xcc0    DX:0x1    DI:0xffff90e187d17c60    R8:0x40
> > > > >
> > > > > But the issue still happened when running the test in the pipe mode. In
> > > > > the pipe mode, it calls process_attr() which still checks the attr for
> > > > > the dummy event, so the issue happened.
> > > > >
> > > > >    # ./perf record -o - --intr-regs=di,r8,dx,cx -e
> > > > > br_inst_retired.near_call:p -c 1000 --per-thread true 2>/dev/null|./perf
> > > > > script -F iregs |head -5
> > > > > Samples for 'dummy:HG' event do not have IREGS attribute set. Cannot
> > > > > print 'iregs' field.
> > > > > 0x120 [0x90]: failed to process type: 64
> > > > >
> > > > > I have one test patch which can fix the pipe mode issue.
> > > > >
> > > > >    ./perf record -o - --intr-regs=di,r8,dx,cx -e
> > > > > br_inst_retired.near_call:p -c 1000 --per-thread true 2>/dev/null|./perf
> > > > > script -F iregs |head -5
> > > > >    ABI:2    CX:0xffff90e18119e278    DX:0x0    DI:0xffff90e18119f858
> > > > > R8:0xffff90e18119e278
> > > > >    ABI:2    CX:0x0    DX:0x1    DI:0xfffffa2844a91580    R8:0x402
> > > > >    ABI:2    CX:0x0    DX:0x0    DI:0x100cca    R8:0x0
> > > > >    ABI:2    CX:0x0    DX:0x0    DI:0xffffffff9e997ca5    R8:0x0
> > > > >    ABI:2    CX:0x113ce8000    DX:0xffff90e198f46600
> > > > > DI:0xffff90e189de8000    R8:0x290
> > > > >
> > > > >
> > > > > Fixes: b91e5492f9d7 ("perf record: Add a dummy event on hybrid systems
> > > > > to collect metadata records")
> > > > > Signed-off-by: Zhengjun Xing <zhengjun.xing@linux.intel.com>
> > > > > ---
> > > > >    tools/perf/builtin-script.c | 2 ++
> > > > >    1 file changed, 2 insertions(+)
> > > > >
> > > > > diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> > > > > index 9152e3e45b69..2d863cdb19fe 100644
> > > > > --- a/tools/perf/builtin-script.c
> > > > > +++ b/tools/perf/builtin-script.c
> > > > > @@ -2429,6 +2429,8 @@ static int process_attr(struct perf_tool *tool,
> > > > > union perf_event *event,
> > > > >           }
> > > > >
> > > > >           if (evsel->core.attr.sample_type) {
> > > > > +               if (evsel__is_dummy_event(evsel))
> > > > > +                       return 0;
> > > >
> > > > Maybe we can move this into evsel__check_attr().
> > > >
> > > > Thanks,
> > > > Namhyung
> > >
> > > Yes, the following changes in evsel__check_attr() can fix both normal and
> > > pipe mode issues, Otherwise, we have to patch everywhere when
> > > evsel__check_attr() is called.
> > >
> > > diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> > > index 13580a9c50b8..fb76e3191858 100644
> > > --- a/tools/perf/builtin-script.c
> > > +++ b/tools/perf/builtin-script.c
> > > @@ -451,6 +451,9 @@ static int evsel__check_attr(struct evsel *evsel, struct
> > > perf_session *session)
> > >         allow_user_set = perf_header__has_feat(&session->header,
> > >                                                HEADER_AUXTRACE);
> > >
> > > +       if (evsel__is_dummy_event(evsel))
> > > +               allow_user_set = true;
> > > +
> >
> > hm, do you need to pass allow_user_set to UREGS check then?
> 
> Well.. actually I thought we can simply return 0 for a dummy event.

true :-)

jirka

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

* Re: [PATCH] perf script: Skip dummy event attr check
  2022-09-07 14:16               ` Jiri Olsa
@ 2022-09-08  6:56                 ` Xing Zhengjun
  0 siblings, 0 replies; 10+ messages in thread
From: Xing Zhengjun @ 2022-09-08  6:56 UTC (permalink / raw)
  To: Jiri Olsa, Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Ian Rogers, Hongtao Yu, lkml,
	Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	linux-perf-users, Liang, Kan



On 9/7/2022 10:16 PM, Jiri Olsa wrote:
> On Wed, Sep 07, 2022 at 01:14:52AM -0700, Namhyung Kim wrote:
>> On Wed, Sep 7, 2022 at 1:09 AM Jiri Olsa <olsajiri@gmail.com> wrote:
>>>
>>> On Wed, Sep 07, 2022 at 01:19:32PM +0800, Xing Zhengjun wrote:
>>>>
>>>>
>>>> On 9/7/2022 12:50 PM, Namhyung Kim wrote:
>>>>> Hello,
>>>>>
>>>>> On Tue, Sep 6, 2022 at 7:49 PM Xing Zhengjun
>>>>> <zhengjun.xing@linux.intel.com> wrote:
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> On 9/1/2022 12:23 AM, Arnaldo Carvalho de Melo wrote:
>>>>>>> Em Wed, Aug 31, 2022 at 09:02:46AM -0700, Ian Rogers escreveu:
>>>>>>>> On Wed, Aug 31, 2022 at 5:40 AM Jiri Olsa <jolsa@kernel.org> wrote:
>>>>>>>>>
>>>>>>>>> Hongtao Yu reported problem when displaying uregs in perf script
>>>>>>>>> for system wide perf.data:
>>>>>>>>>
>>>>>>>>>      # perf script -F uregs | head -10
>>>>>>>>>      Samples for 'dummy:HG' event do not have UREGS attribute set. Cannot print 'uregs' field.
>>>>>>>>>
>>>>>>>>> The problem is the extra dummy event added for system wide,
>>>>>>>>> which does not have proper sample_type setup.
>>>>>>>>>
>>>>>>>>> Skipping attr check completely for dummy event as suggested
>>>>>>>>> by Namhyung, because it does not have any samples anyway.
>>>>>>>>>
>>>>>>>>> Reported-by: Hongtao Yu <hoy@fb.com>
>>>>>>>>> Suggested-by: Namhyung Kim <namhyung@kernel.org>
>>>>>>>>> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
>>>>>>>>
>>>>>>>> Acked-by: Ian Rogers <irogers@google.com>
>>>>>>>
>>>>>>> Thanks, applied to perf/urgent.
>>>>>>>
>>>>>>> - Arnaldo
>>>>>>
>>>>>> I have met a similar issue on hybrid systems such as ADL, I apply the
>>>>>> patch, and it works OK for the normal mode.
>>>>>>     # ./perf record  --intr-regs=di,r8,dx,cx -e
>>>>>> br_inst_retired.near_call:p -c 1000 --per-thread true
>>>>>> [ perf record: Woken up 1 times to write data ]
>>>>>> [ perf record: Captured and wrote 0.024 MB perf.data (25 samples) ]
>>>>>>
>>>>>> # ./perf script -F iregs |head -5
>>>>>>     ABI:2    CX:0xffff90e19d024ed8    DX:0x1    DI:0xffff90e19d024ed8
>>>>>> R8:0xffffba5e437e7b30
>>>>>>     ABI:2    CX:0x7f5239783000    DX:0x80000000    DI:0xffff90e1801eea00
>>>>>>     R8:0x71
>>>>>>     ABI:2    CX:0x40    DX:0x60    DI:0xffffffff9fde5ab8    R8:0x40
>>>>>>     ABI:2    CX:0x0    DX:0xffffffffffffffff    DI:0xffff90e1877408e8
>>>>>> R8:0x1
>>>>>>     ABI:2    CX:0xcc0    DX:0x1    DI:0xffff90e187d17c60    R8:0x40
>>>>>>
>>>>>> But the issue still happened when running the test in the pipe mode. In
>>>>>> the pipe mode, it calls process_attr() which still checks the attr for
>>>>>> the dummy event, so the issue happened.
>>>>>>
>>>>>>     # ./perf record -o - --intr-regs=di,r8,dx,cx -e
>>>>>> br_inst_retired.near_call:p -c 1000 --per-thread true 2>/dev/null|./perf
>>>>>> script -F iregs |head -5
>>>>>> Samples for 'dummy:HG' event do not have IREGS attribute set. Cannot
>>>>>> print 'iregs' field.
>>>>>> 0x120 [0x90]: failed to process type: 64
>>>>>>
>>>>>> I have one test patch which can fix the pipe mode issue.
>>>>>>
>>>>>>     ./perf record -o - --intr-regs=di,r8,dx,cx -e
>>>>>> br_inst_retired.near_call:p -c 1000 --per-thread true 2>/dev/null|./perf
>>>>>> script -F iregs |head -5
>>>>>>     ABI:2    CX:0xffff90e18119e278    DX:0x0    DI:0xffff90e18119f858
>>>>>> R8:0xffff90e18119e278
>>>>>>     ABI:2    CX:0x0    DX:0x1    DI:0xfffffa2844a91580    R8:0x402
>>>>>>     ABI:2    CX:0x0    DX:0x0    DI:0x100cca    R8:0x0
>>>>>>     ABI:2    CX:0x0    DX:0x0    DI:0xffffffff9e997ca5    R8:0x0
>>>>>>     ABI:2    CX:0x113ce8000    DX:0xffff90e198f46600
>>>>>> DI:0xffff90e189de8000    R8:0x290
>>>>>>
>>>>>>
>>>>>> Fixes: b91e5492f9d7 ("perf record: Add a dummy event on hybrid systems
>>>>>> to collect metadata records")
>>>>>> Signed-off-by: Zhengjun Xing <zhengjun.xing@linux.intel.com>
>>>>>> ---
>>>>>>     tools/perf/builtin-script.c | 2 ++
>>>>>>     1 file changed, 2 insertions(+)
>>>>>>
>>>>>> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
>>>>>> index 9152e3e45b69..2d863cdb19fe 100644
>>>>>> --- a/tools/perf/builtin-script.c
>>>>>> +++ b/tools/perf/builtin-script.c
>>>>>> @@ -2429,6 +2429,8 @@ static int process_attr(struct perf_tool *tool,
>>>>>> union perf_event *event,
>>>>>>            }
>>>>>>
>>>>>>            if (evsel->core.attr.sample_type) {
>>>>>> +               if (evsel__is_dummy_event(evsel))
>>>>>> +                       return 0;
>>>>>
>>>>> Maybe we can move this into evsel__check_attr().
>>>>>
>>>>> Thanks,
>>>>> Namhyung
>>>>
>>>> Yes, the following changes in evsel__check_attr() can fix both normal and
>>>> pipe mode issues, Otherwise, we have to patch everywhere when
>>>> evsel__check_attr() is called.
>>>>
>>>> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
>>>> index 13580a9c50b8..fb76e3191858 100644
>>>> --- a/tools/perf/builtin-script.c
>>>> +++ b/tools/perf/builtin-script.c
>>>> @@ -451,6 +451,9 @@ static int evsel__check_attr(struct evsel *evsel, struct
>>>> perf_session *session)
>>>>          allow_user_set = perf_header__has_feat(&session->header,
>>>>                                                 HEADER_AUXTRACE);
>>>>
>>>> +       if (evsel__is_dummy_event(evsel))
>>>> +               allow_user_set = true;
>>>> +
>>>
>>> hm, do you need to pass allow_user_set to UREGS check then?
>>
>> Well.. actually I thought we can simply return 0 for a dummy event.
> 
> true :-)
> 
> jirka

Thanks all, I will post a patch based on it soon.

-- 
Zhengjun Xing

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

end of thread, other threads:[~2022-09-08  6:56 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-31 12:40 [PATCH] perf script: Skip dummy event attr check Jiri Olsa
2022-08-31 16:02 ` Ian Rogers
2022-08-31 16:23   ` Arnaldo Carvalho de Melo
2022-09-07  2:49     ` Xing Zhengjun
2022-09-07  4:50       ` Namhyung Kim
2022-09-07  5:19         ` Xing Zhengjun
2022-09-07  8:09           ` Jiri Olsa
2022-09-07  8:14             ` Namhyung Kim
2022-09-07 14:16               ` Jiri Olsa
2022-09-08  6:56                 ` Xing Zhengjun

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).