* [PATCH] perf arm64: Fix read PMU cpu slots
@ 2023-07-24 5:06 Haixin Yu
2023-07-24 7:40 ` Jing Zhang
0 siblings, 1 reply; 4+ messages in thread
From: Haixin Yu @ 2023-07-24 5:06 UTC (permalink / raw)
To: John Garry, Will Deacon, James Clark, Mike Leach, Leo Yan,
Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
Ian Rogers, Adrian Hunter, linux-arm-kernel, linux-perf-users,
linux-kernel
Commit f8ad6018ce3c ("perf pmu: Remove duplication around
EVENT_SOURCE_DEVICE_PATH") uses sysfs__read_ull to read a full
sysfs path, which will never success. Fix it by read file directly.
Signed-off-by: Haixin Yu <yuhaixin.yhx@linux.alibaba.com>
---
tools/perf/arch/arm64/util/pmu.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/tools/perf/arch/arm64/util/pmu.c b/tools/perf/arch/arm64/util/pmu.c
index 561de0cb6b95..512a8f13c4de 100644
--- a/tools/perf/arch/arm64/util/pmu.c
+++ b/tools/perf/arch/arm64/util/pmu.c
@@ -54,10 +54,11 @@ double perf_pmu__cpu_slots_per_cycle(void)
perf_pmu__pathname_scnprintf(path, sizeof(path),
pmu->name, "caps/slots");
/*
- * The value of slots is not greater than 32 bits, but sysfs__read_int
- * can't read value with 0x prefix, so use sysfs__read_ull instead.
+ * The value of slots is not greater than 32 bits, but
+ * filename__read_int can't read value with 0x prefix,
+ * so use filename__read_ull instead.
*/
- sysfs__read_ull(path, &slots);
+ filename__read_ull(path, &slots);
}
return slots ? (double)slots : NAN;
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] perf arm64: Fix read PMU cpu slots
2023-07-24 5:06 [PATCH] perf arm64: Fix read PMU cpu slots Haixin Yu
@ 2023-07-24 7:40 ` Jing Zhang
2023-07-24 16:41 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 4+ messages in thread
From: Jing Zhang @ 2023-07-24 7:40 UTC (permalink / raw)
To: Haixin Yu, John Garry, Will Deacon, James Clark, Mike Leach,
Leo Yan, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
Ian Rogers, Adrian Hunter, linux-arm-kernel, linux-perf-users,
linux-kernel
在 2023/7/24 下午1:06, Haixin Yu 写道:
> Commit f8ad6018ce3c ("perf pmu: Remove duplication around
> EVENT_SOURCE_DEVICE_PATH") uses sysfs__read_ull to read a full
> sysfs path, which will never success. Fix it by read file directly.
>
> Signed-off-by: Haixin Yu <yuhaixin.yhx@linux.alibaba.com>
> ---
> tools/perf/arch/arm64/util/pmu.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/tools/perf/arch/arm64/util/pmu.c b/tools/perf/arch/arm64/util/pmu.c
> index 561de0cb6b95..512a8f13c4de 100644
> --- a/tools/perf/arch/arm64/util/pmu.c
> +++ b/tools/perf/arch/arm64/util/pmu.c
> @@ -54,10 +54,11 @@ double perf_pmu__cpu_slots_per_cycle(void)
> perf_pmu__pathname_scnprintf(path, sizeof(path),
> pmu->name, "caps/slots");
> /*
> - * The value of slots is not greater than 32 bits, but sysfs__read_int
> - * can't read value with 0x prefix, so use sysfs__read_ull instead.
> + * The value of slots is not greater than 32 bits, but
> + * filename__read_int can't read value with 0x prefix,
> + * so use filename__read_ull instead.
> */
> - sysfs__read_ull(path, &slots);
> + filename__read_ull(path, &slots);
> }
>
> return slots ? (double)slots : NAN;
Yes, the function perf_pmu__pathname_scnprintf returns the complete slots file path "/sys/bus/xxxxx/caps/slots",
and sysfs__read_ull will add the prefix "/sys" to the path, so the final file path becomes "/sys/sys/bus/xxxx/caps/slots"
which does not exist, and the slots file cannot be successfully read, so sysfs__read_ull needs to be changed to the
filename__read_ull.
I tested it and it works well.
Tested-by: Jing Zhang <renyu.zj@linux.alibaba.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] perf arm64: Fix read PMU cpu slots
2023-07-24 7:40 ` Jing Zhang
@ 2023-07-24 16:41 ` Arnaldo Carvalho de Melo
2023-07-25 10:15 ` James Clark
0 siblings, 1 reply; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-07-24 16:41 UTC (permalink / raw)
To: James Clark, Jing Zhang
Cc: Haixin Yu, John Garry, Will Deacon, Mike Leach, Leo Yan,
Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
Jiri Olsa, Namhyung Kim, Ian Rogers, Adrian Hunter,
linux-arm-kernel, linux-perf-users, linux-kernel
Em Mon, Jul 24, 2023 at 03:40:12PM +0800, Jing Zhang escreveu:
>
>
> 在 2023/7/24 下午1:06, Haixin Yu 写道:
> > Commit f8ad6018ce3c ("perf pmu: Remove duplication around
> > EVENT_SOURCE_DEVICE_PATH") uses sysfs__read_ull to read a full
> > sysfs path, which will never success. Fix it by read file directly.
> >
> > Signed-off-by: Haixin Yu <yuhaixin.yhx@linux.alibaba.com>
> > ---
> > tools/perf/arch/arm64/util/pmu.c | 7 ++++---
> > 1 file changed, 4 insertions(+), 3 deletions(-)
> >
> > diff --git a/tools/perf/arch/arm64/util/pmu.c b/tools/perf/arch/arm64/util/pmu.c
> > index 561de0cb6b95..512a8f13c4de 100644
> > --- a/tools/perf/arch/arm64/util/pmu.c
> > +++ b/tools/perf/arch/arm64/util/pmu.c
> > @@ -54,10 +54,11 @@ double perf_pmu__cpu_slots_per_cycle(void)
> > perf_pmu__pathname_scnprintf(path, sizeof(path),
> > pmu->name, "caps/slots");
> > /*
> > - * The value of slots is not greater than 32 bits, but sysfs__read_int
> > - * can't read value with 0x prefix, so use sysfs__read_ull instead.
> > + * The value of slots is not greater than 32 bits, but
> > + * filename__read_int can't read value with 0x prefix,
> > + * so use filename__read_ull instead.
> > */
> > - sysfs__read_ull(path, &slots);
> > + filename__read_ull(path, &slots);
> > }
> >
> > return slots ? (double)slots : NAN;
>
> Yes, the function perf_pmu__pathname_scnprintf returns the complete slots file path "/sys/bus/xxxxx/caps/slots",
> and sysfs__read_ull will add the prefix "/sys" to the path, so the final file path becomes "/sys/sys/bus/xxxx/caps/slots"
> which does not exist, and the slots file cannot be successfully read, so sysfs__read_ull needs to be changed to the
> filename__read_ull.
>
> I tested it and it works well.
>
> Tested-by: Jing Zhang <renyu.zj@linux.alibaba.com>
I've applied this to my local branch, thanks.
I also added the missing:
Fixes: f8ad6018ce3c065a ("perf pmu: Remove duplication around EVENT_SOURCE_DEVICE_PATH")
This is another case where a 'perf test' entry would come in handy.
James, please check and ack,
- Arnaldo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] perf arm64: Fix read PMU cpu slots
2023-07-24 16:41 ` Arnaldo Carvalho de Melo
@ 2023-07-25 10:15 ` James Clark
0 siblings, 0 replies; 4+ messages in thread
From: James Clark @ 2023-07-25 10:15 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Jing Zhang
Cc: Haixin Yu, John Garry, Will Deacon, Mike Leach, Leo Yan,
Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
Jiri Olsa, Namhyung Kim, Ian Rogers, Adrian Hunter,
linux-arm-kernel, linux-perf-users, linux-kernel
On 24/07/2023 17:41, Arnaldo Carvalho de Melo wrote:
> Em Mon, Jul 24, 2023 at 03:40:12PM +0800, Jing Zhang escreveu:
>>
>>
>> 在 2023/7/24 下午1:06, Haixin Yu 写道:
>>> Commit f8ad6018ce3c ("perf pmu: Remove duplication around
>>> EVENT_SOURCE_DEVICE_PATH") uses sysfs__read_ull to read a full
>>> sysfs path, which will never success. Fix it by read file directly.
>>>
>>> Signed-off-by: Haixin Yu <yuhaixin.yhx@linux.alibaba.com>
>>> ---
>>> tools/perf/arch/arm64/util/pmu.c | 7 ++++---
>>> 1 file changed, 4 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/tools/perf/arch/arm64/util/pmu.c b/tools/perf/arch/arm64/util/pmu.c
>>> index 561de0cb6b95..512a8f13c4de 100644
>>> --- a/tools/perf/arch/arm64/util/pmu.c
>>> +++ b/tools/perf/arch/arm64/util/pmu.c
>>> @@ -54,10 +54,11 @@ double perf_pmu__cpu_slots_per_cycle(void)
>>> perf_pmu__pathname_scnprintf(path, sizeof(path),
>>> pmu->name, "caps/slots");
>>> /*
>>> - * The value of slots is not greater than 32 bits, but sysfs__read_int
>>> - * can't read value with 0x prefix, so use sysfs__read_ull instead.
>>> + * The value of slots is not greater than 32 bits, but
>>> + * filename__read_int can't read value with 0x prefix,
>>> + * so use filename__read_ull instead.
>>> */
>>> - sysfs__read_ull(path, &slots);
>>> + filename__read_ull(path, &slots);
>>> }
>>>
>>> return slots ? (double)slots : NAN;
>>
>> Yes, the function perf_pmu__pathname_scnprintf returns the complete slots file path "/sys/bus/xxxxx/caps/slots",
>> and sysfs__read_ull will add the prefix "/sys" to the path, so the final file path becomes "/sys/sys/bus/xxxx/caps/slots"
>> which does not exist, and the slots file cannot be successfully read, so sysfs__read_ull needs to be changed to the
>> filename__read_ull.
>>
>> I tested it and it works well.
>>
>> Tested-by: Jing Zhang <renyu.zj@linux.alibaba.com>
>
> I've applied this to my local branch, thanks.
>
> I also added the missing:
>
> Fixes: f8ad6018ce3c065a ("perf pmu: Remove duplication around EVENT_SOURCE_DEVICE_PATH")
>
> This is another case where a 'perf test' entry would come in handy.
>
> James, please check and ack,
>
> - Arnaldo
Oops, looks like the system I tested that on doesn't report slots so it
returns NAN whether it successfully reads the file or not.
I can't think of a test that doesn't just repeat that function so I will
probably say to leave it as is (and we're not currently doing any
automated testing on any platforms that report slots either). It's quite
visible when it breaks because the topdown metrics won't work on
platforms where they should.
Sorry for the breakage!
Acked-by: James Clark <james.clark@arm.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-07-25 10:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-24 5:06 [PATCH] perf arm64: Fix read PMU cpu slots Haixin Yu
2023-07-24 7:40 ` Jing Zhang
2023-07-24 16:41 ` Arnaldo Carvalho de Melo
2023-07-25 10:15 ` James Clark
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).