[2/2] perf stat: Fix invalid output handle

Message ID 20221130111521.334152-2-james.clark@arm.com
State New
Headers
Series [1/2] perf tests: Fix "perf stat JSON output linter" test for new output |

Commit Message

James Clark Nov. 30, 2022, 11:15 a.m. UTC
  In this context, 'os' is already a pointer so the extra dereference
isn't required. This fixes the following test failure on aarch64:

  $ ./perf test "json output" -vvv
  92: perf stat JSON output linter                                    :
  --- start ---
  Checking json output: no args Test failed for input:
  ...
  Fatal error: glibc detected an invalid stdio handle
  ---- end ----
  perf stat JSON output linter: FAILED!

Fixes: e7f4da312259 ("perf stat: Pass struct outstate to printout()")
Signed-off-by: James Clark <james.clark@arm.com>
---
 tools/perf/util/stat-display.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Namhyung Kim Nov. 30, 2022, 6:32 p.m. UTC | #1
On Wed, Nov 30, 2022 at 3:15 AM James Clark <james.clark@arm.com> wrote:
>
> In this context, 'os' is already a pointer so the extra dereference
> isn't required. This fixes the following test failure on aarch64:
>
>   $ ./perf test "json output" -vvv
>   92: perf stat JSON output linter                                    :
>   --- start ---
>   Checking json output: no args Test failed for input:
>   ...
>   Fatal error: glibc detected an invalid stdio handle
>   ---- end ----
>   perf stat JSON output linter: FAILED!
>
> Fixes: e7f4da312259 ("perf stat: Pass struct outstate to printout()")
> Signed-off-by: James Clark <james.clark@arm.com>

Thanks for fixing this.  I'm not sure how I missed it.. :(

Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung


> ---
>  tools/perf/util/stat-display.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
> index 847acdb5dc40..eac5ac3a734c 100644
> --- a/tools/perf/util/stat-display.c
> +++ b/tools/perf/util/stat-display.c
> @@ -741,7 +741,7 @@ static void printout(struct perf_stat_config *config, struct outstate *os,
>                 perf_stat__print_shadow_stats(config, counter, uval, map_idx,
>                                               &out, &config->metric_events, &rt_stat);
>         } else {
> -               pm(config, &os, /*color=*/NULL, /*format=*/NULL, /*unit=*/"", /*val=*/0);
> +               pm(config, os, /*color=*/NULL, /*format=*/NULL, /*unit=*/"", /*val=*/0);
>         }
>
>         if (!config->metric_only) {
> --
> 2.25.1
>
  
James Clark Dec. 1, 2022, 10:06 a.m. UTC | #2
On 30/11/2022 18:32, Namhyung Kim wrote:
> On Wed, Nov 30, 2022 at 3:15 AM James Clark <james.clark@arm.com> wrote:
>>
>> In this context, 'os' is already a pointer so the extra dereference
>> isn't required. This fixes the following test failure on aarch64:
>>
>>   $ ./perf test "json output" -vvv
>>   92: perf stat JSON output linter                                    :
>>   --- start ---
>>   Checking json output: no args Test failed for input:
>>   ...
>>   Fatal error: glibc detected an invalid stdio handle
>>   ---- end ----
>>   perf stat JSON output linter: FAILED!
>>
>> Fixes: e7f4da312259 ("perf stat: Pass struct outstate to printout()")
>> Signed-off-by: James Clark <james.clark@arm.com>
> 
> Thanks for fixing this.  I'm not sure how I missed it.. :(
> 

It seems to only go down that path on some configuration. At least on
x86 the test was passing fine for me.

> Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks for the review!

> 
> Thanks,
> Namhyung
> 
> 
>> ---
>>  tools/perf/util/stat-display.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
>> index 847acdb5dc40..eac5ac3a734c 100644
>> --- a/tools/perf/util/stat-display.c
>> +++ b/tools/perf/util/stat-display.c
>> @@ -741,7 +741,7 @@ static void printout(struct perf_stat_config *config, struct outstate *os,
>>                 perf_stat__print_shadow_stats(config, counter, uval, map_idx,
>>                                               &out, &config->metric_events, &rt_stat);
>>         } else {
>> -               pm(config, &os, /*color=*/NULL, /*format=*/NULL, /*unit=*/"", /*val=*/0);
>> +               pm(config, os, /*color=*/NULL, /*format=*/NULL, /*unit=*/"", /*val=*/0);
>>         }
>>
>>         if (!config->metric_only) {
>> --
>> 2.25.1
>>
  
Athira Rajeev Dec. 4, 2022, 5:08 p.m. UTC | #3
> On 01-Dec-2022, at 3:36 PM, James Clark <james.clark@arm.com> wrote:
> 
> 
> 
> On 30/11/2022 18:32, Namhyung Kim wrote:
>> On Wed, Nov 30, 2022 at 3:15 AM James Clark <james.clark@arm.com> wrote:
>>> 
>>> In this context, 'os' is already a pointer so the extra dereference
>>> isn't required. This fixes the following test failure on aarch64:
>>> 
>>>  $ ./perf test "json output" -vvv
>>>  92: perf stat JSON output linter                                    :
>>>  --- start ---
>>>  Checking json output: no args Test failed for input:
>>>  ...
>>>  Fatal error: glibc detected an invalid stdio handle
>>>  ---- end ----
>>>  perf stat JSON output linter: FAILED!
>>> 
>>> Fixes: e7f4da312259 ("perf stat: Pass struct outstate to printout()")
>>> Signed-off-by: James Clark <james.clark@arm.com>
>> 
>> Thanks for fixing this.  I'm not sure how I missed it.. :(
>> 
> 
> It seems to only go down that path on some configuration. At least on
> x86 the test was passing fine for me.
> 
>> Acked-by: Namhyung Kim <namhyung@kernel.org>
> 
> Thanks for the review!

Faced same issue on powerpc. Tested with this change and it works with this patch.

Tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>

Thanks
Athira
> 
>> 
>> Thanks,
>> Namhyung
>> 
>> 
>>> ---
>>> tools/perf/util/stat-display.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>> 
>>> diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
>>> index 847acdb5dc40..eac5ac3a734c 100644
>>> --- a/tools/perf/util/stat-display.c
>>> +++ b/tools/perf/util/stat-display.c
>>> @@ -741,7 +741,7 @@ static void printout(struct perf_stat_config *config, struct outstate *os,
>>>                perf_stat__print_shadow_stats(config, counter, uval, map_idx,
>>>                                              &out, &config->metric_events, &rt_stat);
>>>        } else {
>>> -               pm(config, &os, /*color=*/NULL, /*format=*/NULL, /*unit=*/"", /*val=*/0);
>>> +               pm(config, os, /*color=*/NULL, /*format=*/NULL, /*unit=*/"", /*val=*/0);
>>>        }
>>> 
>>>        if (!config->metric_only) {
>>> --
>>> 2.25.1
  
Arnaldo Carvalho de Melo Dec. 5, 2022, 1:07 p.m. UTC | #4
Em Sun, Dec 04, 2022 at 10:38:28PM +0530, Athira Rajeev escreveu:
> 
> 
> > On 01-Dec-2022, at 3:36 PM, James Clark <james.clark@arm.com> wrote:
> > 
> > 
> > 
> > On 30/11/2022 18:32, Namhyung Kim wrote:
> >> On Wed, Nov 30, 2022 at 3:15 AM James Clark <james.clark@arm.com> wrote:
> >>> 
> >>> In this context, 'os' is already a pointer so the extra dereference
> >>> isn't required. This fixes the following test failure on aarch64:
> >>> 
> >>>  $ ./perf test "json output" -vvv
> >>>  92: perf stat JSON output linter                                    :
> >>>  --- start ---
> >>>  Checking json output: no args Test failed for input:
> >>>  ...
> >>>  Fatal error: glibc detected an invalid stdio handle
> >>>  ---- end ----
> >>>  perf stat JSON output linter: FAILED!
> >>> 
> >>> Fixes: e7f4da312259 ("perf stat: Pass struct outstate to printout()")
> >>> Signed-off-by: James Clark <james.clark@arm.com>
> >> 
> >> Thanks for fixing this.  I'm not sure how I missed it.. :(
> >> 
> > 
> > It seems to only go down that path on some configuration. At least on
> > x86 the test was passing fine for me.
> > 
> >> Acked-by: Namhyung Kim <namhyung@kernel.org>
> > 
> > Thanks for the review!
> 
> Faced same issue on powerpc. Tested with this change and it works with this patch.
> 
> Tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>

Thanks, applied.

- Arnaldo
  

Patch

diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
index 847acdb5dc40..eac5ac3a734c 100644
--- a/tools/perf/util/stat-display.c
+++ b/tools/perf/util/stat-display.c
@@ -741,7 +741,7 @@  static void printout(struct perf_stat_config *config, struct outstate *os,
 		perf_stat__print_shadow_stats(config, counter, uval, map_idx,
 					      &out, &config->metric_events, &rt_stat);
 	} else {
-		pm(config, &os, /*color=*/NULL, /*format=*/NULL, /*unit=*/"", /*val=*/0);
+		pm(config, os, /*color=*/NULL, /*format=*/NULL, /*unit=*/"", /*val=*/0);
 	}
 
 	if (!config->metric_only) {