Skip to contentSkip to conversation

ARM/arm64: Mark all accessor functions inline

PATCH Applied Geert Uytterhoeven 4 participants 11 messages May 8, 2023 – May 16, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover ARM/arm64: Mark all accessor functions inline

Hi all,

This patch series adds missing "inline" keywords to the few perf accessors that lack them.

BTW, I tried converting my local timing code to the new unified system. This works fine on arm64, but broke on arm32. Is read_pmccntr() supposed to work on arm32? I get an undefined instruction exception on Cortex A15 and A9. Before, my custom code used "mrc p15, 0, %0, c9, c13, 0" (as is also used in arch/arm/kernel/perf_event_v7.c), for which there is no accessor yet.

Thanks for your comments!

Geert Uytterhoeven (2):
ARM: perf: Mark all accessor functions inline
arm64: perf: Mark all accessor functions inline

 arch/arm/include/asm/arm_pmuv3.h   | 6 +++---
 arch/arm64/include/asm/arm_pmuv3.h | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)
Signature · 12 lines
2.34.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds
#1 lore raw

PATCH 1/2 ARM: perf: Mark all accessor functions inline

When just including <asm/arm_pmuv3.h>:

arch/arm/include/asm/arm_pmuv3.h:110:13: error: ‘write_pmevtypern’ defined but not used [-Werror=unused-function]
110 | static void write_pmevtypern(int n, unsigned long val)
| ^~~~~~~~~~~~~~~~
arch/arm/include/asm/arm_pmuv3.h:103:13: error: ‘write_pmevcntrn’ defined but not used [-Werror=unused-function]
103 | static void write_pmevcntrn(int n, unsigned long val)
| ^~~~~~~~~~~~~~~
arch/arm/include/asm/arm_pmuv3.h:95:22: error: ‘read_pmevcntrn’ defined but not used [-Werror=unused-function]
95 | static unsigned long read_pmevcntrn(int n)
| ^~~~~~~~~~~~~~

Fix this by adding the missing "inline" keywords to the three accessor functions that lack them.

Fixes 009d6dc87a568db6 ("ARM: perf: Allow the use of the PMUv3 driver on 32bit ARM")
---
 arch/arm/include/asm/arm_pmuv3.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/include/asm/arm_pmuv3.h +3 -3
index 78d3d4b82c6c2598..f4db3e75d75f024e 100644
@@ -92,7 +92,7 @@
 
 #define RETURN_READ_PMEVCNTRN(n) \
 	return read_sysreg(PMEVCNTR##n)
-static unsigned long read_pmevcntrn(int n)
+static inline unsigned long read_pmevcntrn(int n)
 {
 	PMEVN_SWITCH(n, RETURN_READ_PMEVCNTRN);
 	return 0;
@@ -100,14 +100,14 @@ static unsigned long read_pmevcntrn(int n)
 
 #define WRITE_PMEVCNTRN(n) \
 	write_sysreg(val, PMEVCNTR##n)
-static void write_pmevcntrn(int n, unsigned long val)
+static inline void write_pmevcntrn(int n, unsigned long val)
 {
 	PMEVN_SWITCH(n, WRITE_PMEVCNTRN);
 }
 
 #define WRITE_PMEVTYPERN(n) \
 	write_sysreg(val, PMEVTYPER##n)
-static void write_pmevtypern(int n, unsigned long val)
+static inline void write_pmevtypern(int n, unsigned long val)
 {
 	PMEVN_SWITCH(n, WRITE_PMEVTYPERN);
 }
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/2 arm64: perf: Mark all accessor functions inline

When just including <asm/arm_pmuv3.h>:

arch/arm64/include/asm/arm_pmuv3.h:31:13: error: ‘write_pmevtypern’ defined but not used [-Werror=unused-function]
31 | static void write_pmevtypern(int n, unsigned long val)
| ^~~~~~~~~~~~~~~~
arch/arm64/include/asm/arm_pmuv3.h:24:13: error: ‘write_pmevcntrn’ defined but not used [-Werror=unused-function]
24 | static void write_pmevcntrn(int n, unsigned long val)
| ^~~~~~~~~~~~~~~
arch/arm64/include/asm/arm_pmuv3.h:16:22: error: ‘read_pmevcntrn’ defined but not used [-Werror=unused-function]
16 | static unsigned long read_pmevcntrn(int n)
| ^~~~~~~~~~~~~~

Fix this by adding the missing "inline" keywords to the three accessor functions that lack them.

Fixes df29ddf4f04b00cf ("arm64: perf: Abstract system register accesses away")
---
 arch/arm64/include/asm/arm_pmuv3.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm64/include/asm/arm_pmuv3.h +3 -3
index d6b51deb7bf0ff2f..18dc2fb3d7b7b2d0 100644
@@ -13,7 +13,7 @@
 
 #define RETURN_READ_PMEVCNTRN(n) \
 	return read_sysreg(pmevcntr##n##_el0)
-static unsigned long read_pmevcntrn(int n)
+static inline unsigned long read_pmevcntrn(int n)
 {
 	PMEVN_SWITCH(n, RETURN_READ_PMEVCNTRN);
 	return 0;
@@ -21,14 +21,14 @@ static unsigned long read_pmevcntrn(int n)
 
 #define WRITE_PMEVCNTRN(n) \
 	write_sysreg(val, pmevcntr##n##_el0)
-static void write_pmevcntrn(int n, unsigned long val)
+static inline void write_pmevcntrn(int n, unsigned long val)
 {
 	PMEVN_SWITCH(n, WRITE_PMEVCNTRN);
 }
 
 #define WRITE_PMEVTYPERN(n) \
 	write_sysreg(val, pmevtyper##n##_el0)
-static void write_pmevtypern(int n, unsigned long val)
+static inline void write_pmevtypern(int n, unsigned long val)
 {
 	PMEVN_SWITCH(n, WRITE_PMEVTYPERN);
 }
Signature · 1 line
2.34.1
Reviewed-by on v1 2/2
#3 lore raw

Re: [PATCH 2/2] arm64: perf: Mark all accessor functions inline

Quoted 13 lines · Geert Uytterhoeven

When just including <asm/arm_pmuv3.h>:

arch/arm64/include/asm/arm_pmuv3.h:31:13: error: ‘write_pmevtypern’ defined but not used [-Werror=unused-function]
31 | static void write_pmevtypern(int n, unsigned long val)
| ^~~~~~~~~~~~~~~~
arch/arm64/include/asm/arm_pmuv3.h:24:13: error: ‘write_pmevcntrn’ defined but not used [-Werror=unused-function]
24 | static void write_pmevcntrn(int n, unsigned long val)
| ^~~~~~~~~~~~~~~
arch/arm64/include/asm/arm_pmuv3.h:16:22: error: ‘read_pmevcntrn’ defined but not used [-Werror=unused-function]
16 | static unsigned long read_pmevcntrn(int n)
| ^~~~~~~~~~~~~~

Quoted 2 lines

Fix this by adding the missing "inline" keywords to the three accessor functions that lack them.

Looks reasonable to me. Each of these accessors is used exactly once in the PMUv3 driver, so the inlining doesn't result in extra bloat.

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
reviewer Acked-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] arm64: perf: Mark all accessor functions inline

In reply to Geert Uytterhoeven
Quoted 12 lines · Geert Uytterhoeven

When just including <asm/arm_pmuv3.h>:

arch/arm64/include/asm/arm_pmuv3.h:31:13: error: ‘write_pmevtypern’ defined but not used [-Werror=unused-function]
31 | static void write_pmevtypern(int n, unsigned long val)
| ^~~~~~~~~~~~~~~~
arch/arm64/include/asm/arm_pmuv3.h:24:13: error: ‘write_pmevcntrn’ defined but not used [-Werror=unused-function]
24 | static void write_pmevcntrn(int n, unsigned long val)
| ^~~~~~~~~~~~~~~
arch/arm64/include/asm/arm_pmuv3.h:16:22: error: ‘read_pmevcntrn’ defined but not used [-Werror=unused-function]
16 | static unsigned long read_pmevcntrn(int n)
| ^~~~~~~~~~~~~~

Quoted 5 lines

Fix this by adding the missing "inline" keywords to the three accessor functions that lack them.

Fixes df29ddf4f04b00cf ("arm64: perf: Abstract system register accesses away")

Mark.

Quoted 37 lines
---
 arch/arm64/include/asm/arm_pmuv3.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm64/include/asm/arm_pmuv3.h +3 -3
index d6b51deb7bf0ff2f..18dc2fb3d7b7b2d0 100644
@@ -13,7 +13,7 @@
 
 #define RETURN_READ_PMEVCNTRN(n) \
 	return read_sysreg(pmevcntr##n##_el0)
-static unsigned long read_pmevcntrn(int n)
+static inline unsigned long read_pmevcntrn(int n)
 {
 	PMEVN_SWITCH(n, RETURN_READ_PMEVCNTRN);
 	return 0;
@@ -21,14 +21,14 @@ static unsigned long read_pmevcntrn(int n)
 
 #define WRITE_PMEVCNTRN(n) \
 	write_sysreg(val, pmevcntr##n##_el0)
-static void write_pmevcntrn(int n, unsigned long val)
+static inline void write_pmevcntrn(int n, unsigned long val)
 {
 	PMEVN_SWITCH(n, WRITE_PMEVCNTRN);
 }
 
 #define WRITE_PMEVTYPERN(n) \
 	write_sysreg(val, pmevtyper##n##_el0)
-static void write_pmevtypern(int n, unsigned long val)
+static inline void write_pmevtypern(int n, unsigned long val)
 {
 	PMEVN_SWITCH(n, WRITE_PMEVTYPERN);
 }
Signature · 1 line
2.34.1
Reviewed-by on v1 1/2
#5 lore raw

Re: [PATCH 1/2] ARM: perf: Mark all accessor functions inline

In reply to Geert Uytterhoeven
Quoted 13 lines · Geert Uytterhoeven

When just including <asm/arm_pmuv3.h>:

arch/arm/include/asm/arm_pmuv3.h:110:13: error: ‘write_pmevtypern’ defined but not used [-Werror=unused-function]
110 | static void write_pmevtypern(int n, unsigned long val)
| ^~~~~~~~~~~~~~~~
arch/arm/include/asm/arm_pmuv3.h:103:13: error: ‘write_pmevcntrn’ defined but not used [-Werror=unused-function]
103 | static void write_pmevcntrn(int n, unsigned long val)
| ^~~~~~~~~~~~~~~
arch/arm/include/asm/arm_pmuv3.h:95:22: error: ‘read_pmevcntrn’ defined but not used [-Werror=unused-function]
95 | static unsigned long read_pmevcntrn(int n)
| ^~~~~~~~~~~~~~

Quoted 5 lines

Fix this by adding the missing "inline" keywords to the three accessor functions that lack them.

Fixes 009d6dc87a568db6 ("ARM: perf: Allow the use of the PMUv3 driver on 32bit ARM")
	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
reviewer Acked-by on v1 1/2
#6 lore raw

Re: [PATCH 1/2] ARM: perf: Mark all accessor functions inline

In reply to Geert Uytterhoeven
Quoted 12 lines · Geert Uytterhoeven

When just including <asm/arm_pmuv3.h>:

arch/arm/include/asm/arm_pmuv3.h:110:13: error: ‘write_pmevtypern’ defined but not used [-Werror=unused-function]
110 | static void write_pmevtypern(int n, unsigned long val)
| ^~~~~~~~~~~~~~~~
arch/arm/include/asm/arm_pmuv3.h:103:13: error: ‘write_pmevcntrn’ defined but not used [-Werror=unused-function]
103 | static void write_pmevcntrn(int n, unsigned long val)
| ^~~~~~~~~~~~~~~
arch/arm/include/asm/arm_pmuv3.h:95:22: error: ‘read_pmevcntrn’ defined but not used [-Werror=unused-function]
95 | static unsigned long read_pmevcntrn(int n)
| ^~~~~~~~~~~~~~

Quoted 5 lines

Fix this by adding the missing "inline" keywords to the three accessor functions that lack them.

Fixes 009d6dc87a568db6 ("ARM: perf: Allow the use of the PMUv3 driver on 32bit ARM")

Mark.

Quoted 37 lines
---
 arch/arm/include/asm/arm_pmuv3.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/include/asm/arm_pmuv3.h +3 -3
index 78d3d4b82c6c2598..f4db3e75d75f024e 100644
@@ -92,7 +92,7 @@
 
 #define RETURN_READ_PMEVCNTRN(n) \
 	return read_sysreg(PMEVCNTR##n)
-static unsigned long read_pmevcntrn(int n)
+static inline unsigned long read_pmevcntrn(int n)
 {
 	PMEVN_SWITCH(n, RETURN_READ_PMEVCNTRN);
 	return 0;
@@ -100,14 +100,14 @@ static unsigned long read_pmevcntrn(int n)
 
 #define WRITE_PMEVCNTRN(n) \
 	write_sysreg(val, PMEVCNTR##n)
-static void write_pmevcntrn(int n, unsigned long val)
+static inline void write_pmevcntrn(int n, unsigned long val)
 {
 	PMEVN_SWITCH(n, WRITE_PMEVCNTRN);
 }
 
 #define WRITE_PMEVTYPERN(n) \
 	write_sysreg(val, PMEVTYPER##n)
-static void write_pmevtypern(int n, unsigned long val)
+static inline void write_pmevtypern(int n, unsigned long val)
 {
 	PMEVN_SWITCH(n, WRITE_PMEVTYPERN);
 }
Signature · 1 line
2.34.1
#7 lore raw
In reply to Geert Uytterhoeven

Hi Geert,

Quoted 5 lines · Geert Uytterhoeven

Hi all,

This patch series adds missing "inline" keywords to the few perf accessors that lack them.

I'll get to that shortly.

Quoted 7 lines

BTW, I tried converting my local timing code to the new unified system. This works fine on arm64, but broke on arm32. Is read_pmccntr() supposed to work on arm32? I get an undefined instruction exception on Cortex A15 and A9. Before, my custom code used "mrc p15, 0, %0, c9, c13, 0" (as is also used in arch/arm/kernel/perf_event_v7.c), for which there is no accessor yet.

You can only use this instruction on a CPU that implements PMUv3, which limits it to an ARMv8 implementation (either a 64bit CPU in 32bit mode, or something like an A32). A15 and A9 being firmly in the ARMv7 camp, they cannot make use of this (hence the UNDEF you're getting).

Thanks,

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
reviewer
#8 lore raw
In reply to Geert Uytterhoeven
Quoted 9 lines · Geert Uytterhoeven

Hi all,

This patch series adds missing "inline" keywords to the few perf accessors that lack them.

BTW, I tried converting my local timing code to the new unified system. This works fine on arm64, but broke on arm32. Is read_pmccntr() supposed to work on arm32? I get an undefined instruction exception on Cortex A15 and A9.

That's expected.

This code is for PMUv3 (which was added as part of ARMv8), and one of the things changed in PMUv3 was that PMCCNTR was expanded to 64 bits accessible via MRRC and MCRR.

Previously, PMCCNTR was only 32 bits, and that's what Cortex-A9 and Cortex-A15 implement.

Thanks,
Mark.

Quoted 27 lines

Before, my custom code used "mrc p15, 0, %0, c9,
c13, 0" (as is also used in arch/arm/kernel/perf_event_v7.c), for which there is no accessor yet.

Thanks for your comments!

Geert Uytterhoeven (2):
ARM: perf: Mark all accessor functions inline
arm64: perf: Mark all accessor functions inline

 arch/arm/include/asm/arm_pmuv3.h   | 6 +++---
 arch/arm64/include/asm/arm_pmuv3.h | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)
Signature · 12 lines
2.34.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds
reviewer
#9 lore raw
In reply to Geert Uytterhoeven
Quoted 4 lines · Geert Uytterhoeven

Hi all,

This patch series adds missing "inline" keywords to the few perf accessors that lack them.

Will, I assume that you'll pick these up as a cleanup/fix.

Thanks,
Mark.

Quoted 30 lines

BTW, I tried converting my local timing code to the new unified system. This works fine on arm64, but broke on arm32. Is read_pmccntr() supposed to work on arm32? I get an undefined instruction exception on Cortex A15 and A9. Before, my custom code used "mrc p15, 0, %0, c9, c13, 0" (as is also used in arch/arm/kernel/perf_event_v7.c), for which there is no accessor yet.

Thanks for your comments!

Geert Uytterhoeven (2):
ARM: perf: Mark all accessor functions inline
arm64: perf: Mark all accessor functions inline

 arch/arm/include/asm/arm_pmuv3.h   | 6 +++---
 arch/arm64/include/asm/arm_pmuv3.h | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)
Signature · 12 lines
2.34.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds
maintainer Applied
#10 lore raw
In reply to Geert Uytterhoeven
Quoted 5 lines · Geert Uytterhoeven

Hi all,

This patch series adds missing "inline" keywords to the few perf accessors that lack them.

Quoted 8 lines

BTW, I tried converting my local timing code to the new unified system. This works fine on arm64, but broke on arm32. Is read_pmccntr() supposed to work on arm32? I get an undefined instruction exception on Cortex A15 and A9. Before, my custom code used "mrc p15, 0, %0, c9, c13, 0" (as is also used in arch/arm/kernel/perf_event_v7.c), for which there is no accessor yet.

[...]

Applied to arm64 (for-next/fixes), thanks!

[1/2] ARM: perf: Mark all accessor functions inline

      https://git.kernel.org/arm64/c/68e3f61eb9f5
[2/2] arm64: perf: Mark all accessor functions inline
      https://git.kernel.org/arm64/c/3bc879e355da

Cheers,

Signature · 5 lines
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev