perf/core: Drop __weak attribute from arch_perf_update_userpage() prototype
PATCH 1/1 perf/core: Drop __weak attribute from arch_perf_update_userpage() prototype
Reiji reports that the arm64 implementation of arch_perf_update_userpage() is now ignored and replaced by the dummy stub in core code. This seems to happen since the PMUv3 driver was moved to driver/perf.
As it turns out, dropping the __weak attribute from the *prototype* of the function solves the problem. You're right, this doesn't seem to make much sense. And yet... It appears that both symbols get flagged as weak, and that the first one to appear in the link order wins:
$ nm drivers/perf/arm_pmuv3.o|grep arch_perf_update_userpage 0000000000001db0 W arch_perf_update_userpage
Dropping the attribute from the prototype restores the expected behaviour, and arm64 is able to enjoy arch_perf_update_userpage() again.
--- include/linux/perf_event.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
include/linux/perf_event.h +3 -3
@@ -1845,9 +1845,9 @@ int perf_event_exit_cpu(unsigned int cpu);#define perf_event_exit_cpu NULL#endif -extern void __weak arch_perf_update_userpage (struct perf_event *event, -struct perf_event_mmap_page *userpg, -u64 now); +extern void arch_perf_update_userpage (struct perf_event *event, +struct perf_event_mmap_page *userpg, +u64 now);#ifdef CONFIG_MMU extern __weak u64 arch_perf_get_page_size (struct mm_struct *mm,unsigned long addr);
Signature · 1 line
2.34.1
Quoted 17 lines · Marc Zyngier
Reiji reports that the arm64 implementation of
arch_perf_update_userpage()is now ignored and replaced by the dummy stub in core code. This seems to happen since the PMUv3 driver was moved to driver/perf.As it turns out, dropping the
__weakattribute from the *prototype* of the function solves the problem. You're right, this doesn't seem to make much sense. And yet... It appears that both symbols get flagged as weak, and that the first one to appear in the link order wins:$ nm drivers/perf/arm_pmuv3.o|grep arch_perf_update_userpage 0000000000001db0 W arch_perf_update_userpageDropping the attribute from the prototype restores the expected behaviour, and arm64 is able to enjoy
arch_perf_update_userpage()again.
Quoted 5 lines
Reported-by Reiji Watanabe <[email protected]>Signed-off-by Marc Zyngier <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Mark Rutland <[email protected]>Cc Will Deacon <[email protected]>
Quoted 3 lines · Marc Zyngier
Reiji reports that the arm64 implementation of
arch_perf_update_userpage()is now ignored and replaced by the dummy stub in core code. This seems to happen since the PMUv3 driver was moved to driver/perf.
I guess we should have a Cc stable then?
The below implies this has always been on dodgy ground, and so it's probably inaccurate to give this a Fixes tag pointing to the move.
Quoted 8 lines
As it turns out, dropping the
__weakattribute from the *prototype* of the function solves the problem. You're right, this doesn't seem to make much sense. And yet... It appears that both symbols get flagged as weak, and that the first one to appear in the link order wins:$ nm drivers/perf/arm_pmuv3.o|grep arch_perf_update_userpage 0000000000001db0 W arch_perf_update_userpage
Ah, so having it on th *declaration* will apply to any *definition*. :/
That suggests this is a bad pattern generally, and we should probably remove the other __weak instances in headers. Lukcily it seems there aren't that many:
[mark@lakrids:~/src/linux]% git grep __weak -- **/*.h | wc -l 50
IMO we'd should aim to remove __weak entirely; it causes a number of weird things like this and it'd be much easier to manage with a small amount of ifdeffery.
Peter, thoughts?
Quoted 10 lines
Dropping the attribute from the prototype restores the expected behaviour, and arm64 is able to enjoy
arch_perf_update_userpage()again.Reported-by Reiji Watanabe <[email protected]>Signed-off-by Marc Zyngier <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Mark Rutland <[email protected]>Cc Will Deacon <[email protected]>Tested-by Reiji Watanabe <[email protected]>
FWIW, regardless of the above:
Quoted 11 lines
--- include/linux/perf_event.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)include/linux/perf_event.h +0
-0@@ -1845,9 +1845,9 @@ int perf_event_exit_cpu(unsigned int cpu);#define perf_event_exit_cpu NULL#endif
include/linux/perf_event.h int perf_event_exit_cpu(unsigned int cpu); · line 1853
Quoted 10 lines
include/linux/perf_event.h +3
-3-extern void __weak arch_perf_update_userpage (struct perf_event *event, -struct perf_event_mmap_page *userpg, -u64 now); +extern void arch_perf_update_userpage (struct perf_event *event, +struct perf_event_mmap_page *userpg, +u64 now);#ifdef CONFIG_MMU extern __weak u64 arch_perf_get_page_size (struct mm_struct *mm,unsigned long addr);
Luckily, arch_perf_get_page_size() has no callers or definition since commit:
8af26be062721e52 ("perf/core: Fix arch_perf_get_page_size()")
... so we can just delete that prototype.
Mark
Quoted 7 lines · Mark Rutland
Quoted 3 lines · Marc Zyngier
Reiji reports that the arm64 implementation of
arch_perf_update_userpage()is now ignored and replaced by the dummy stub in core code. This seems to happen since the PMUv3 driver was moved to driver/perf.I guess we should have a Cc stable then?
Potentially. I don't think anyone else is affected though, as we're the only one implementing this outside of the arch code.
Quoted 3 lines
The below implies this has always been on dodgy ground, and so it's probably inaccurate to give this a Fixes tag pointing to the move.
Indeed. We just didn't notice.
Quoted 10 lines
Quoted 9 lines
As it turns out, dropping the
__weakattribute from the *prototype* of the function solves the problem. You're right, this doesn't seem to make much sense. And yet... It appears that both symbols get flagged as weak, and that the first one to appear in the link order wins:$ nm drivers/perf/arm_pmuv3.o|grep arch_perf_update_userpage 0000000000001db0 W arch_perf_update_userpage
Quoted 7 lines
Ah, so having it on th *declaration* will apply to any *definition*. :/
That suggests this is a bad pattern generally, and we should probably remove the other
__weakinstances in headers. Lukcily it seems there aren't that many:[mark@lakrids:~/src/linux]% git grep
__weak-- **/*.h | wc -l 50
The majority seems to be in tools (BPF FTW!), but get_c0_perfcount_int in the MIPS code count be an interesting one...
Quoted 18 lines
IMO we'd should aim to remove
__weakentirely; it causes a number of weird things like this and it'd be much easier to manage with a small amount of ifdeffery.Peter, thoughts?
Quoted 10 lines
Dropping the attribute from the prototype restores the expected behaviour, and arm64 is able to enjoy
arch_perf_update_userpage()again.Reported-by Reiji Watanabe <[email protected]>Signed-off-by Marc Zyngier <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Mark Rutland <[email protected]>Cc Will Deacon <[email protected]>Tested-by Reiji Watanabe <[email protected]>
Quoted 3 lines
FWIW, regardless of the above:
Acked-by Mark Rutland <[email protected]>
Cheers for that.
Quoted 20 lines
Quoted 20 lines
--- include/linux/perf_event.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)include/linux/perf_event.h +3
-3@@ -1845,9 +1845,9 @@ int perf_event_exit_cpu(unsigned int cpu);#define perf_event_exit_cpu NULL#endif -extern void __weak arch_perf_update_userpage (struct perf_event *event, -struct perf_event_mmap_page *userpg, -u64 now); +extern void arch_perf_update_userpage (struct perf_event *event, +struct perf_event_mmap_page *userpg, +u64 now);
Quoted 8 lines
include/linux/perf_event.h int perf_event_exit_cpu(unsigned int cpu); · line 1853
Quoted 2 lines
include/linux/perf_event.h +0
-0#ifdef CONFIG_MMU extern __weak u64 arch_perf_get_page_size (struct mm_struct *mm,unsigned long addr);Luckily,
arch_perf_get_page_size()has no callers or definition since commit:
8af26be062721e52("perf/core: Fixarch_perf_get_page_size()")... so we can just delete that prototype.
Yeah, I have a patch for that too, but didn't want to distract with something that is just a basic cleanup, and I'd rather see a sweeping cleanup.
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
Peter Zijlstra
maintainerQuoted 16 lines · Mark Rutland
Quoted 3 lines · Marc Zyngier
Reiji reports that the arm64 implementation of
arch_perf_update_userpage()is now ignored and replaced by the dummy stub in core code. This seems to happen since the PMUv3 driver was moved to driver/perf.I guess we should have a Cc stable then?
The below implies this has always been on dodgy ground, and so it's probably inaccurate to give this a Fixes tag pointing to the move.
Quoted 6 lines
As it turns out, dropping the
__weakattribute from the *prototype* of the function solves the problem. You're right, this doesn't seem to make much sense. And yet... It appears that both symbols get flagged as weak, and that the first one to appear in the link order wins:
Quoted 4 lines
Quoted 2 lines
$ nm drivers/perf/arm_pmuv3.o|grep arch_perf_update_userpage 0000000000001db0 W arch_perf_update_userpageAh, so having it on th *declaration* will apply to any *definition*. :/
Yikes..
Quoted 11 lines
That suggests this is a bad pattern generally, and we should probably remove the other
__weakinstances in headers. Lukcily it seems there aren't that many:[mark@lakrids:~/src/linux]% git grep
__weak-- **/*.h | wc -l 50IMO we'd should aim to remove
__weakentirely; it causes a number of weird things like this and it'd be much easier to manage with a small amount of ifdeffery.Peter, thoughts?
Not a fan of __weak myself, after having had to deal with how the compilers actually make it work.
Where do I queue this? perf/urgent?
Quoted 35 lines · Peter Zijlstra
Quoted 16 lines · Mark Rutland
Quoted 3 lines · Marc Zyngier
Reiji reports that the arm64 implementation of
arch_perf_update_userpage()is now ignored and replaced by the dummy stub in core code. This seems to happen since the PMUv3 driver was moved to driver/perf.I guess we should have a Cc stable then?
The below implies this has always been on dodgy ground, and so it's probably inaccurate to give this a Fixes tag pointing to the move.
Quoted 6 lines
As it turns out, dropping the
__weakattribute from the *prototype* of the function solves the problem. You're right, this doesn't seem to make much sense. And yet... It appears that both symbols get flagged as weak, and that the first one to appear in the link order wins:Quoted 4 lines
Quoted 2 lines
$ nm drivers/perf/arm_pmuv3.o|grep arch_perf_update_userpage 0000000000001db0 W arch_perf_update_userpageAh, so having it on th *declaration* will apply to any *definition*. :/
Yikes..
Quoted 10 lines
That suggests this is a bad pattern generally, and we should probably remove the other
__weakinstances in headers. Lukcily it seems there aren't that many:[mark@lakrids:~/src/linux]% git grep
__weak-- **/*.h | wc -l 50IMO we'd should aim to remove
__weakentirely; it causes a number of weird things like this and it'd be much easier to manage with a small amount of ifdeffery.
Quoted 6 lines
Quoted 1 line
Peter, thoughts?
Not a fan of
__weakmyself, after having had to deal with how the compilers actually make it work.Where do I queue this? perf/urgent?
That'd be my preference, as arm64 is currently a bit broken and I'd like 6.4 to be functional.
Thanks,
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
Peter Zijlstra
maintainerQuoted 39 lines · Marc Zyngier
Quoted 37 lines · Peter Zijlstra
Quoted 16 lines · Mark Rutland
Quoted 3 lines · Marc Zyngier
Reiji reports that the arm64 implementation of
arch_perf_update_userpage()is now ignored and replaced by the dummy stub in core code. This seems to happen since the PMUv3 driver was moved to driver/perf.I guess we should have a Cc stable then?
The below implies this has always been on dodgy ground, and so it's probably inaccurate to give this a Fixes tag pointing to the move.
Quoted 6 lines
As it turns out, dropping the
__weakattribute from the *prototype* of the function solves the problem. You're right, this doesn't seem to make much sense. And yet... It appears that both symbols get flagged as weak, and that the first one to appear in the link order wins:Quoted 4 lines
Quoted 2 lines
$ nm drivers/perf/arm_pmuv3.o|grep arch_perf_update_userpage 0000000000001db0 W arch_perf_update_userpageAh, so having it on th *declaration* will apply to any *definition*. :/
Yikes..
Quoted 11 lines
That suggests this is a bad pattern generally, and we should probably remove the other
__weakinstances in headers. Lukcily it seems there aren't that many:[mark@lakrids:~/src/linux]% git grep
__weak-- **/*.h | wc -l 50IMO we'd should aim to remove
__weakentirely; it causes a number of weird things like this and it'd be much easier to manage with a small amount of ifdeffery.Peter, thoughts?
Quoted 7 lines
Quoted 4 lines
Not a fan of
__weakmyself, after having had to deal with how the compilers actually make it work.Where do I queue this? perf/urgent?
That'd be my preference, as arm64 is currently a bit broken and I'd like 6.4 to be functional.
Can I get a Fixes tag?