LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 1/2] perf script: Fix PERF_SAMPLE_WEIGHT_STRUCT support
@ 2021-09-29 15:38 kan.liang
  2021-09-29 15:38 ` [PATCH 2/2] perf script: Support instruction latency kan.liang
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: kan.liang @ 2021-09-29 15:38 UTC (permalink / raw)
  To: acme, jolsa, jmario, linux-kernel; +Cc: ak, Kan Liang

From: Kan Liang <kan.liang@linux.intel.com>

-F weight in perf script is broken.

  # ./perf mem record
  # ./perf script -F weight
  Samples for 'dummy:HG' event do not have WEIGHT attribute set. Cannot
print 'weight' field.

The sample type, PERF_SAMPLE_WEIGHT_STRUCT, is an alternative of the
PERF_SAMPLE_WEIGHT sample type. They share the same space, weight. The
lower 32 bits are exactly the same for both sample type. The higher 32
bits may be different for different architecture. For a new kernel on
x86, the PERF_SAMPLE_WEIGHT_STRUCT is used. For an old kernel or other
ARCHs, the PERF_SAMPLE_WEIGHT is used.

With -F weight, current perf script will only check the input string
"weight" with the PERF_SAMPLE_WEIGHT sample type. Because the commit
ea8d0ed6eae3 ("perf tools: Support PERF_SAMPLE_WEIGHT_STRUCT") didn't
update the PERF_SAMPLE_WEIGHT_STRUCT sample type for perf script. For a
new kernel on x86, the check fails.

Use PERF_SAMPLE_WEIGHT_TYPE, which supports both sample types, to
replace PERF_SAMPLE_WEIGHT.

Reported-by: Joe Mario <jmario@redhat.com>
Fixes: ea8d0ed6eae3 ("perf tools: Support PERF_SAMPLE_WEIGHT_STRUCT")
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
---
 tools/perf/builtin-script.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 6211d0b..9f62ac6 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -459,7 +459,7 @@ static int evsel__check_attr(struct evsel *evsel, struct perf_session *session)
 		return -EINVAL;
 
 	if (PRINT_FIELD(WEIGHT) &&
-	    evsel__check_stype(evsel, PERF_SAMPLE_WEIGHT, "WEIGHT", PERF_OUTPUT_WEIGHT))
+	    evsel__check_stype(evsel, PERF_SAMPLE_WEIGHT_TYPE, "WEIGHT", PERF_OUTPUT_WEIGHT))
 		return -EINVAL;
 
 	if (PRINT_FIELD(SYM) &&
-- 
2.7.4


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

* [PATCH 2/2] perf script: Support instruction latency
  2021-09-29 15:38 [PATCH 1/2] perf script: Fix PERF_SAMPLE_WEIGHT_STRUCT support kan.liang
@ 2021-09-29 15:38 ` kan.liang
  2021-09-29 16:54 ` [PATCH 1/2] perf script: Fix PERF_SAMPLE_WEIGHT_STRUCT support Arnaldo Carvalho de Melo
  2021-09-30 10:48 ` kajoljain
  2 siblings, 0 replies; 7+ messages in thread
From: kan.liang @ 2021-09-29 15:38 UTC (permalink / raw)
  To: acme, jolsa, jmario, linux-kernel; +Cc: ak, Kan Liang

From: Kan Liang <kan.liang@linux.intel.com>

The instruction latency information can be recorded on
some platforms, e.g., the Intel Sapphire Rapids server. With both memory
latency (weight) and the new instruction latency information, users can
easily locate the expensive load instructions, and also understand the time
spent in different stages. The users can optimize their applications in
different pipeline stages.

Add a new field "ins_lat" to filter the instruction latency information,
which is available with sample type PERF_SAMPLE_WEIGHT_STRUCT.

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
---
 tools/perf/Documentation/perf-script.txt |  2 +-
 tools/perf/builtin-script.c              | 14 ++++++++++++--
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt
index c805152..b007071 100644
--- a/tools/perf/Documentation/perf-script.txt
+++ b/tools/perf/Documentation/perf-script.txt
@@ -130,7 +130,7 @@ OPTIONS
         comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff,
         srcline, period, iregs, uregs, brstack, brstacksym, flags, bpf-output,
         brstackinsn, brstackoff, callindent, insn, insnlen, synth, phys_addr,
-        metric, misc, srccode, ipc, data_page_size, code_page_size.
+        metric, misc, srccode, ipc, data_page_size, code_page_size, ins_lat.
         Field list can be prepended with the type, trace, sw or hw,
         to indicate to which event type the field list applies.
         e.g., -F sw:comm,tid,time,ip,sym  and -F trace:time,cpu,trace
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 9f62ac6..4ac47e3 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -122,6 +122,7 @@ enum perf_output_field {
 	PERF_OUTPUT_TOD             = 1ULL << 32,
 	PERF_OUTPUT_DATA_PAGE_SIZE  = 1ULL << 33,
 	PERF_OUTPUT_CODE_PAGE_SIZE  = 1ULL << 34,
+	PERF_OUTPUT_INS_LAT         = 1ULL << 35,
 };
 
 struct perf_script {
@@ -188,6 +189,7 @@ struct output_option {
 	{.str = "tod", .field = PERF_OUTPUT_TOD},
 	{.str = "data_page_size", .field = PERF_OUTPUT_DATA_PAGE_SIZE},
 	{.str = "code_page_size", .field = PERF_OUTPUT_CODE_PAGE_SIZE},
+	{.str = "ins_lat", .field = PERF_OUTPUT_INS_LAT},
 };
 
 enum {
@@ -262,7 +264,8 @@ static struct {
 			      PERF_OUTPUT_DSO | PERF_OUTPUT_PERIOD |
 			      PERF_OUTPUT_ADDR | PERF_OUTPUT_DATA_SRC |
 			      PERF_OUTPUT_WEIGHT | PERF_OUTPUT_PHYS_ADDR |
-			      PERF_OUTPUT_DATA_PAGE_SIZE | PERF_OUTPUT_CODE_PAGE_SIZE,
+			      PERF_OUTPUT_DATA_PAGE_SIZE | PERF_OUTPUT_CODE_PAGE_SIZE |
+			      PERF_OUTPUT_INS_LAT,
 
 		.invalid_fields = PERF_OUTPUT_TRACE | PERF_OUTPUT_BPF_OUTPUT,
 	},
@@ -522,6 +525,10 @@ static int evsel__check_attr(struct evsel *evsel, struct perf_session *session)
 	    evsel__check_stype(evsel, PERF_SAMPLE_CODE_PAGE_SIZE, "CODE_PAGE_SIZE", PERF_OUTPUT_CODE_PAGE_SIZE))
 		return -EINVAL;
 
+	if (PRINT_FIELD(INS_LAT) &&
+	    evsel__check_stype(evsel, PERF_SAMPLE_WEIGHT_STRUCT, "WEIGHT_STRUCT", PERF_OUTPUT_INS_LAT))
+		return -EINVAL;
+
 	return 0;
 }
 
@@ -2039,6 +2046,9 @@ static void process_event(struct perf_script *script,
 	if (PRINT_FIELD(WEIGHT))
 		fprintf(fp, "%16" PRIu64, sample->weight);
 
+	if (PRINT_FIELD(INS_LAT))
+		fprintf(fp, "%16" PRIu16, sample->ins_lat);
+
 	if (PRINT_FIELD(IP)) {
 		struct callchain_cursor *cursor = NULL;
 
@@ -3715,7 +3725,7 @@ int cmd_script(int argc, const char **argv)
 		     "addr,symoff,srcline,period,iregs,uregs,brstack,"
 		     "brstacksym,flags,bpf-output,brstackinsn,brstackoff,"
 		     "callindent,insn,insnlen,synth,phys_addr,metric,misc,ipc,tod,"
-		     "data_page_size,code_page_size",
+		     "data_page_size,code_page_size,ins_lat",
 		     parse_output_fields),
 	OPT_BOOLEAN('a', "all-cpus", &system_wide,
 		    "system-wide collection from all CPUs"),
-- 
2.7.4


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

* Re: [PATCH 1/2] perf script: Fix PERF_SAMPLE_WEIGHT_STRUCT support
  2021-09-29 15:38 [PATCH 1/2] perf script: Fix PERF_SAMPLE_WEIGHT_STRUCT support kan.liang
  2021-09-29 15:38 ` [PATCH 2/2] perf script: Support instruction latency kan.liang
@ 2021-09-29 16:54 ` Arnaldo Carvalho de Melo
  2021-09-29 18:42   ` Jiri Olsa
  2021-09-30 10:48 ` kajoljain
  2 siblings, 1 reply; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-09-29 16:54 UTC (permalink / raw)
  To: Joe Mario, kan.liang; +Cc: Jiri Olsa, linux-kernel, Andi Kleen

Em Wed, Sep 29, 2021 at 08:38:13AM -0700, kan.liang@linux.intel.com escreveu:
> From: Kan Liang <kan.liang@linux.intel.com>
> 
> -F weight in perf script is broken.
> 
>   # ./perf mem record
>   # ./perf script -F weight
>   Samples for 'dummy:HG' event do not have WEIGHT attribute set. Cannot
> print 'weight' field.
> 
> The sample type, PERF_SAMPLE_WEIGHT_STRUCT, is an alternative of the
> PERF_SAMPLE_WEIGHT sample type. They share the same space, weight. The
> lower 32 bits are exactly the same for both sample type. The higher 32
> bits may be different for different architecture. For a new kernel on
> x86, the PERF_SAMPLE_WEIGHT_STRUCT is used. For an old kernel or other
> ARCHs, the PERF_SAMPLE_WEIGHT is used.
> 
> With -F weight, current perf script will only check the input string
> "weight" with the PERF_SAMPLE_WEIGHT sample type. Because the commit
> ea8d0ed6eae3 ("perf tools: Support PERF_SAMPLE_WEIGHT_STRUCT") didn't
> update the PERF_SAMPLE_WEIGHT_STRUCT sample type for perf script. For a
> new kernel on x86, the check fails.
> 
> Use PERF_SAMPLE_WEIGHT_TYPE, which supports both sample types, to
> replace PERF_SAMPLE_WEIGHT.
> 
> Reported-by: Joe Mario <jmario@redhat.com>
> Fixes: ea8d0ed6eae3 ("perf tools: Support PERF_SAMPLE_WEIGHT_STRUCT")

Hey Joe, Jiri,

	Can I have your Tested-by?

Thanks,

- Arnaldo

> Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
> ---
>  tools/perf/builtin-script.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> index 6211d0b..9f62ac6 100644
> --- a/tools/perf/builtin-script.c
> +++ b/tools/perf/builtin-script.c
> @@ -459,7 +459,7 @@ static int evsel__check_attr(struct evsel *evsel, struct perf_session *session)
>  		return -EINVAL;
>  
>  	if (PRINT_FIELD(WEIGHT) &&
> -	    evsel__check_stype(evsel, PERF_SAMPLE_WEIGHT, "WEIGHT", PERF_OUTPUT_WEIGHT))
> +	    evsel__check_stype(evsel, PERF_SAMPLE_WEIGHT_TYPE, "WEIGHT", PERF_OUTPUT_WEIGHT))
>  		return -EINVAL;
>  
>  	if (PRINT_FIELD(SYM) &&
> -- 
> 2.7.4

-- 

- Arnaldo

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

* Re: [PATCH 1/2] perf script: Fix PERF_SAMPLE_WEIGHT_STRUCT support
  2021-09-29 16:54 ` [PATCH 1/2] perf script: Fix PERF_SAMPLE_WEIGHT_STRUCT support Arnaldo Carvalho de Melo
@ 2021-09-29 18:42   ` Jiri Olsa
  2021-09-29 20:22     ` Joe Mario
  0 siblings, 1 reply; 7+ messages in thread
From: Jiri Olsa @ 2021-09-29 18:42 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: Joe Mario, kan.liang, linux-kernel, Andi Kleen

On Wed, Sep 29, 2021 at 01:54:39PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Wed, Sep 29, 2021 at 08:38:13AM -0700, kan.liang@linux.intel.com escreveu:
> > From: Kan Liang <kan.liang@linux.intel.com>
> > 
> > -F weight in perf script is broken.
> > 
> >   # ./perf mem record
> >   # ./perf script -F weight
> >   Samples for 'dummy:HG' event do not have WEIGHT attribute set. Cannot
> > print 'weight' field.
> > 
> > The sample type, PERF_SAMPLE_WEIGHT_STRUCT, is an alternative of the
> > PERF_SAMPLE_WEIGHT sample type. They share the same space, weight. The
> > lower 32 bits are exactly the same for both sample type. The higher 32
> > bits may be different for different architecture. For a new kernel on
> > x86, the PERF_SAMPLE_WEIGHT_STRUCT is used. For an old kernel or other
> > ARCHs, the PERF_SAMPLE_WEIGHT is used.
> > 
> > With -F weight, current perf script will only check the input string
> > "weight" with the PERF_SAMPLE_WEIGHT sample type. Because the commit
> > ea8d0ed6eae3 ("perf tools: Support PERF_SAMPLE_WEIGHT_STRUCT") didn't
> > update the PERF_SAMPLE_WEIGHT_STRUCT sample type for perf script. For a
> > new kernel on x86, the check fails.
> > 
> > Use PERF_SAMPLE_WEIGHT_TYPE, which supports both sample types, to
> > replace PERF_SAMPLE_WEIGHT.
> > 
> > Reported-by: Joe Mario <jmario@redhat.com>
> > Fixes: ea8d0ed6eae3 ("perf tools: Support PERF_SAMPLE_WEIGHT_STRUCT")
> 
> Hey Joe, Jiri,
> 
> 	Can I have your Tested-by?

Acked/Tested-by: Jiri Olsa <jolsa@redhat.com>

thanks,
jirka

> 
> Thanks,
> 
> - Arnaldo
> 
> > Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
> > ---
> >  tools/perf/builtin-script.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> > index 6211d0b..9f62ac6 100644
> > --- a/tools/perf/builtin-script.c
> > +++ b/tools/perf/builtin-script.c
> > @@ -459,7 +459,7 @@ static int evsel__check_attr(struct evsel *evsel, struct perf_session *session)
> >  		return -EINVAL;
> >  
> >  	if (PRINT_FIELD(WEIGHT) &&
> > -	    evsel__check_stype(evsel, PERF_SAMPLE_WEIGHT, "WEIGHT", PERF_OUTPUT_WEIGHT))
> > +	    evsel__check_stype(evsel, PERF_SAMPLE_WEIGHT_TYPE, "WEIGHT", PERF_OUTPUT_WEIGHT))
> >  		return -EINVAL;
> >  
> >  	if (PRINT_FIELD(SYM) &&
> > -- 
> > 2.7.4
> 
> -- 
> 
> - Arnaldo
> 


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

* Re: [PATCH 1/2] perf script: Fix PERF_SAMPLE_WEIGHT_STRUCT support
  2021-09-29 18:42   ` Jiri Olsa
@ 2021-09-29 20:22     ` Joe Mario
  2021-10-27 20:10       ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 7+ messages in thread
From: Joe Mario @ 2021-09-29 20:22 UTC (permalink / raw)
  To: kan.liang; +Cc: linux-kernel, Andi Kleen, Arnaldo Carvalho de Melo, Jiri Olsa



On 9/29/21 2:42 PM, Jiri Olsa wrote:
> On Wed, Sep 29, 2021 at 01:54:39PM -0300, Arnaldo Carvalho de Melo wrote:
>> Em Wed, Sep 29, 2021 at 08:38:13AM -0700, kan.liang@linux.intel.com escreveu:
>>> From: Kan Liang <kan.liang@linux.intel.com>
>>>
>>> -F weight in perf script is broken.
>>>
>>>   # ./perf mem record
>>>   # ./perf script -F weight
>>>   Samples for 'dummy:HG' event do not have WEIGHT attribute set. Cannot
>>> print 'weight' field.
>>>
>>> The sample type, PERF_SAMPLE_WEIGHT_STRUCT, is an alternative of the
>>> PERF_SAMPLE_WEIGHT sample type. They share the same space, weight. The
>>> lower 32 bits are exactly the same for both sample type. The higher 32
>>> bits may be different for different architecture. For a new kernel on
>>> x86, the PERF_SAMPLE_WEIGHT_STRUCT is used. For an old kernel or other
>>> ARCHs, the PERF_SAMPLE_WEIGHT is used.
>>>
>>> With -F weight, current perf script will only check the input string
>>> "weight" with the PERF_SAMPLE_WEIGHT sample type. Because the commit
>>> ea8d0ed6eae3 ("perf tools: Support PERF_SAMPLE_WEIGHT_STRUCT") didn't
>>> update the PERF_SAMPLE_WEIGHT_STRUCT sample type for perf script. For a
>>> new kernel on x86, the check fails.
>>>
>>> Use PERF_SAMPLE_WEIGHT_TYPE, which supports both sample types, to
>>> replace PERF_SAMPLE_WEIGHT.
>>>
>>> Reported-by: Joe Mario <jmario@redhat.com>
>>> Fixes: ea8d0ed6eae3 ("perf tools: Support PERF_SAMPLE_WEIGHT_STRUCT")
>>
>> Hey Joe, Jiri,
>>
>> 	Can I have your Tested-by?
> 
> Acked/Tested-by: Jiri Olsa <jolsa@redhat.com>
> 
> thanks,
> jirka

 Acked/Tested-by: Joe Mario <jmario@redhat.com>

 The "perf script -F weight" command works correctly.

 And I also verified that when just issuing "perf script", that the weight (cycle latency) 
 column that was missing with this bug, is now fixed and working properly.

 Thanks,
 Joe
> 
>>
>> Thanks,
>>
>> - Arnaldo
>>
>>> Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
>>> ---
>>>  tools/perf/builtin-script.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
>>> index 6211d0b..9f62ac6 100644
>>> --- a/tools/perf/builtin-script.c
>>> +++ b/tools/perf/builtin-script.c
>>> @@ -459,7 +459,7 @@ static int evsel__check_attr(struct evsel *evsel, struct perf_session *session)
>>>  		return -EINVAL;
>>>  
>>>  	if (PRINT_FIELD(WEIGHT) &&
>>> -	    evsel__check_stype(evsel, PERF_SAMPLE_WEIGHT, "WEIGHT", PERF_OUTPUT_WEIGHT))
>>> +	    evsel__check_stype(evsel, PERF_SAMPLE_WEIGHT_TYPE, "WEIGHT", PERF_OUTPUT_WEIGHT))
>>>  		return -EINVAL;
>>>  
>>>  	if (PRINT_FIELD(SYM) &&
>>> -- 
>>> 2.7.4
>>
>> -- 
>>
>> - Arnaldo
>>
> 


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

* Re: [PATCH 1/2] perf script: Fix PERF_SAMPLE_WEIGHT_STRUCT support
  2021-09-29 15:38 [PATCH 1/2] perf script: Fix PERF_SAMPLE_WEIGHT_STRUCT support kan.liang
  2021-09-29 15:38 ` [PATCH 2/2] perf script: Support instruction latency kan.liang
  2021-09-29 16:54 ` [PATCH 1/2] perf script: Fix PERF_SAMPLE_WEIGHT_STRUCT support Arnaldo Carvalho de Melo
@ 2021-09-30 10:48 ` kajoljain
  2 siblings, 0 replies; 7+ messages in thread
From: kajoljain @ 2021-09-30 10:48 UTC (permalink / raw)
  To: kan.liang, acme, jolsa, jmario, linux-kernel; +Cc: ak



On 9/29/21 9:08 PM, kan.liang@linux.intel.com wrote:
> From: Kan Liang <kan.liang@linux.intel.com>
> 
> -F weight in perf script is broken.
> 
>   # ./perf mem record
>   # ./perf script -F weight
>   Samples for 'dummy:HG' event do not have WEIGHT attribute set. Cannot
> print 'weight' field.

Hi Kan,
    This issue can also be reproduce in powerpc box.
Given patch fix the issue.

Reviewed-by: Kajol Jain<kjain@linux.ibm.com>

Thanks,
Kajol Jain

> 
> The sample type, PERF_SAMPLE_WEIGHT_STRUCT, is an alternative of the
> PERF_SAMPLE_WEIGHT sample type. They share the same space, weight. The
> lower 32 bits are exactly the same for both sample type. The higher 32
> bits may be different for different architecture. For a new kernel on
> x86, the PERF_SAMPLE_WEIGHT_STRUCT is used. For an old kernel or other
> ARCHs, the PERF_SAMPLE_WEIGHT is used.
> 
> With -F weight, current perf script will only check the input string
> "weight" with the PERF_SAMPLE_WEIGHT sample type. Because the commit
> ea8d0ed6eae3 ("perf tools: Support PERF_SAMPLE_WEIGHT_STRUCT") didn't
> update the PERF_SAMPLE_WEIGHT_STRUCT sample type for perf script. For a
> new kernel on x86, the check fails.
> 
> Use PERF_SAMPLE_WEIGHT_TYPE, which supports both sample types, to
> replace PERF_SAMPLE_WEIGHT.
> 
> Reported-by: Joe Mario <jmario@redhat.com>
> Fixes: ea8d0ed6eae3 ("perf tools: Support PERF_SAMPLE_WEIGHT_STRUCT")
> Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
> ---
>  tools/perf/builtin-script.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> index 6211d0b..9f62ac6 100644
> --- a/tools/perf/builtin-script.c
> +++ b/tools/perf/builtin-script.c
> @@ -459,7 +459,7 @@ static int evsel__check_attr(struct evsel *evsel, struct perf_session *session)
>  		return -EINVAL;
>  
>  	if (PRINT_FIELD(WEIGHT) &&
> -	    evsel__check_stype(evsel, PERF_SAMPLE_WEIGHT, "WEIGHT", PERF_OUTPUT_WEIGHT))
> +	    evsel__check_stype(evsel, PERF_SAMPLE_WEIGHT_TYPE, "WEIGHT", PERF_OUTPUT_WEIGHT))
>  		return -EINVAL;
>  
>  	if (PRINT_FIELD(SYM) &&
> 

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

* Re: [PATCH 1/2] perf script: Fix PERF_SAMPLE_WEIGHT_STRUCT support
  2021-09-29 20:22     ` Joe Mario
@ 2021-10-27 20:10       ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-10-27 20:10 UTC (permalink / raw)
  To: Joe Mario; +Cc: kan.liang, linux-kernel, Andi Kleen, Jiri Olsa

Em Wed, Sep 29, 2021 at 04:22:19PM -0400, Joe Mario escreveu:
> 
> 
> On 9/29/21 2:42 PM, Jiri Olsa wrote:
> > On Wed, Sep 29, 2021 at 01:54:39PM -0300, Arnaldo Carvalho de Melo wrote:
> >> Em Wed, Sep 29, 2021 at 08:38:13AM -0700, kan.liang@linux.intel.com escreveu:
> >>> From: Kan Liang <kan.liang@linux.intel.com>
> >>>
> >>> -F weight in perf script is broken.
> >>>
> >>>   # ./perf mem record
> >>>   # ./perf script -F weight
> >>>   Samples for 'dummy:HG' event do not have WEIGHT attribute set. Cannot
> >>> print 'weight' field.
> >>>
> >>> The sample type, PERF_SAMPLE_WEIGHT_STRUCT, is an alternative of the
> >>> PERF_SAMPLE_WEIGHT sample type. They share the same space, weight. The
> >>> lower 32 bits are exactly the same for both sample type. The higher 32
> >>> bits may be different for different architecture. For a new kernel on
> >>> x86, the PERF_SAMPLE_WEIGHT_STRUCT is used. For an old kernel or other
> >>> ARCHs, the PERF_SAMPLE_WEIGHT is used.
> >>>
> >>> With -F weight, current perf script will only check the input string
> >>> "weight" with the PERF_SAMPLE_WEIGHT sample type. Because the commit
> >>> ea8d0ed6eae3 ("perf tools: Support PERF_SAMPLE_WEIGHT_STRUCT") didn't
> >>> update the PERF_SAMPLE_WEIGHT_STRUCT sample type for perf script. For a
> >>> new kernel on x86, the check fails.
> >>>
> >>> Use PERF_SAMPLE_WEIGHT_TYPE, which supports both sample types, to
> >>> replace PERF_SAMPLE_WEIGHT.
> >>>
> >>> Reported-by: Joe Mario <jmario@redhat.com>
> >>> Fixes: ea8d0ed6eae3 ("perf tools: Support PERF_SAMPLE_WEIGHT_STRUCT")
> >>
> >> Hey Joe, Jiri,
> >>
> >> 	Can I have your Tested-by?
> > 
> > Acked/Tested-by: Jiri Olsa <jolsa@redhat.com>
> > 
> > thanks,
> > jirka
> 
>  Acked/Tested-by: Joe Mario <jmario@redhat.com>
> 
>  The "perf script -F weight" command works correctly.
> 
>  And I also verified that when just issuing "perf script", that the weight (cycle latency) 
>  column that was missing with this bug, is now fixed and working properly.

Thanks, applied.

- Arnaldo

 
>  Thanks,
>  Joe
> > 
> >>
> >> Thanks,
> >>
> >> - Arnaldo
> >>
> >>> Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
> >>> ---
> >>>  tools/perf/builtin-script.c | 2 +-
> >>>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>>
> >>> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> >>> index 6211d0b..9f62ac6 100644
> >>> --- a/tools/perf/builtin-script.c
> >>> +++ b/tools/perf/builtin-script.c
> >>> @@ -459,7 +459,7 @@ static int evsel__check_attr(struct evsel *evsel, struct perf_session *session)
> >>>  		return -EINVAL;
> >>>  
> >>>  	if (PRINT_FIELD(WEIGHT) &&
> >>> -	    evsel__check_stype(evsel, PERF_SAMPLE_WEIGHT, "WEIGHT", PERF_OUTPUT_WEIGHT))
> >>> +	    evsel__check_stype(evsel, PERF_SAMPLE_WEIGHT_TYPE, "WEIGHT", PERF_OUTPUT_WEIGHT))
> >>>  		return -EINVAL;
> >>>  
> >>>  	if (PRINT_FIELD(SYM) &&
> >>> -- 
> >>> 2.7.4
> >>
> >> -- 
> >>
> >> - Arnaldo
> >>
> > 

-- 

- Arnaldo

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

end of thread, other threads:[~2021-10-27 20:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-29 15:38 [PATCH 1/2] perf script: Fix PERF_SAMPLE_WEIGHT_STRUCT support kan.liang
2021-09-29 15:38 ` [PATCH 2/2] perf script: Support instruction latency kan.liang
2021-09-29 16:54 ` [PATCH 1/2] perf script: Fix PERF_SAMPLE_WEIGHT_STRUCT support Arnaldo Carvalho de Melo
2021-09-29 18:42   ` Jiri Olsa
2021-09-29 20:22     ` Joe Mario
2021-10-27 20:10       ` Arnaldo Carvalho de Melo
2021-09-30 10:48 ` kajoljain

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