Skip to contentSkip to conversation

powerpc/perf: init platform pmu driver from core-book3s

PATCH Superseded Madhavan Srinivasan 2 participants 5 messages Mar 31, 2019 – Apr 2, 2019 PowerPC

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 powerpc/perf: init platform pmu driver from core-book3s

Currenty pmu driver file for each ppc64 generation processor has a __init call in itself. Refactor the code by moving the __init call to core-books.c. This also clean's up compat mode pmu driver registration.

---
 arch/powerpc/include/asm/perf_event_server.h |  8 ++++++++
 arch/powerpc/perf/core-book3s.c              | 22 ++++++++++++++++++++++
 arch/powerpc/perf/power5+-pmu.c              |  4 +---
 arch/powerpc/perf/power5-pmu.c               |  4 +---
 arch/powerpc/perf/power6-pmu.c               |  4 +---
 arch/powerpc/perf/power7-pmu.c               |  4 +---
 arch/powerpc/perf/power8-pmu.c               |  3 +--
 arch/powerpc/perf/power9-pmu.c               |  3 +--
 arch/powerpc/perf/ppc970-pmu.c               |  4 +---
 9 files changed, 37 insertions(+), 19 deletions(-)
arch/powerpc/include/asm/perf_event_server.h +8 -0
index e60aeb46d6a0..c5022f2c62a4 100644
@@ -87,6 +87,14 @@ struct pt_regs;
 extern unsigned long perf_misc_flags(struct pt_regs *regs);
 extern unsigned long perf_instruction_pointer(struct pt_regs *regs);
 extern unsigned long int read_bhrb(int n);
+extern int init_ppc970_pmu(void);
+extern int init_power5_pmu(void);
+extern int init_power5p_pmu(void);
+extern int init_power6_pmu(void);
+extern int init_power7_pmu(void);
+extern int init_power8_pmu(void);
+extern int init_power9_pmu(void);
+
 
 /*
  * Only override the default definitions in include/linux/perf_event.h
arch/powerpc/perf/core-book3s.c +22 -0
index b0723002a396..9ba39a69b0ec 100644
@@ -2294,3 +2294,25 @@ int register_power_pmu(struct power_pmu *pmu)
 			  power_pmu_prepare_cpu, NULL);
 	return 0;
 }
+
+static int __init init_ppc64_pmu(void)
+{
+	/* run through all the pmu drivers one at a time */
+	if (!init_power5_pmu())
+		return 0;
+	else if (!init_power5p_pmu())
+		return 0;
+	else if (!init_power6_pmu())
+		return 0;
+	else if (!init_power7_pmu())
+		return 0;
+	else if (!init_power8_pmu())
+		return 0;
+	else if (!init_power9_pmu())
+		return 0;
+	else if (!init_ppc970_pmu())
+		return 0;
+	else
+		return -ENODEV;
+}
+early_initcall(init_ppc64_pmu);
arch/powerpc/perf/power5+-pmu.c +1 -3
index 0526dac66007..9aa803504cb2 100644
@@ -677,7 +677,7 @@ static struct power_pmu power5p_pmu = {
 	.cache_events		= &power5p_cache_events,
 };
 
-static int __init init_power5p_pmu(void)
+int init_power5p_pmu(void)
 {
 	if (!cur_cpu_spec->oprofile_cpu_type ||
 	    (strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power5+")
@@ -686,5 +686,3 @@ static int __init init_power5p_pmu(void)
 
 	return register_power_pmu(&power5p_pmu);
 }
-
-early_initcall(init_power5p_pmu);
arch/powerpc/perf/power5-pmu.c +1 -3
index 4dc99f9f7962..30cb13d081a9 100644
@@ -618,7 +618,7 @@ static struct power_pmu power5_pmu = {
 	.flags			= PPMU_HAS_SSLOT,
 };
 
-static int __init init_power5_pmu(void)
+int init_power5_pmu(void)
 {
 	if (!cur_cpu_spec->oprofile_cpu_type ||
 	    strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power5"))
@@ -626,5 +626,3 @@ static int __init init_power5_pmu(void)
 
 	return register_power_pmu(&power5_pmu);
 }
-
-early_initcall(init_power5_pmu);
arch/powerpc/perf/power6-pmu.c +1 -3
index 9c9d646b68a1..80ec48632cfe 100644
@@ -540,7 +540,7 @@ static struct power_pmu power6_pmu = {
 	.cache_events		= &power6_cache_events,
 };
 
-static int __init init_power6_pmu(void)
+int init_power6_pmu(void)
 {
 	if (!cur_cpu_spec->oprofile_cpu_type ||
 	    strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power6"))
@@ -548,5 +548,3 @@ static int __init init_power6_pmu(void)
 
 	return register_power_pmu(&power6_pmu);
 }
-
-early_initcall(init_power6_pmu);
arch/powerpc/perf/power7-pmu.c +1 -3
index 6dbae9884ec4..bb6efd5d2530 100644
@@ -445,7 +445,7 @@ static struct power_pmu power7_pmu = {
 	.cache_events		= &power7_cache_events,
 };
 
-static int __init init_power7_pmu(void)
+int init_power7_pmu(void)
 {
 	if (!cur_cpu_spec->oprofile_cpu_type ||
 	    strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power7"))
@@ -456,5 +456,3 @@ static int __init init_power7_pmu(void)
 
 	return register_power_pmu(&power7_pmu);
 }
-
-early_initcall(init_power7_pmu);
arch/powerpc/perf/power8-pmu.c +1 -2
index d12a2db26353..bcc3409a06de 100644
@@ -379,7 +379,7 @@ static struct power_pmu power8_pmu = {
 	.bhrb_nr		= 32,
 };
 
-static int __init init_power8_pmu(void)
+int init_power8_pmu(void)
 {
 	int rc;
 
@@ -399,4 +399,3 @@ static int __init init_power8_pmu(void)
 
 	return 0;
 }
-early_initcall(init_power8_pmu);
arch/powerpc/perf/power9-pmu.c +1 -2
index 030544e35959..3a31ac6f4805 100644
@@ -437,7 +437,7 @@ static struct power_pmu power9_pmu = {
 	.bhrb_nr		= 32,
 };
 
-static int __init init_power9_pmu(void)
+int init_power9_pmu(void)
 {
 	int rc = 0;
 	unsigned int pvr = mfspr(SPRN_PVR);
@@ -467,4 +467,3 @@ static int __init init_power9_pmu(void)
 
 	return 0;
 }
-early_initcall(init_power9_pmu);
arch/powerpc/perf/ppc970-pmu.c +1 -3
index 8b6a8a36fa38..1d3370914022 100644
@@ -490,7 +490,7 @@ static struct power_pmu ppc970_pmu = {
 	.flags			= PPMU_NO_SIPR | PPMU_NO_CONT_SAMPLING,
 };
 
-static int __init init_ppc970_pmu(void)
+int init_ppc970_pmu(void)
 {
 	if (!cur_cpu_spec->oprofile_cpu_type ||
 	    (strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/970")
@@ -499,5 +499,3 @@ static int __init init_ppc970_pmu(void)
 
 	return register_power_pmu(&ppc970_pmu);
 }
-
-early_initcall(init_ppc970_pmu);
Signature · 1 line
2.7.4
#1 lore raw

PATCH 2/2 powerpc/perf: Add generic compat mode pmu driver

Most of the power processor generation performance monitoring unit (PMU) driver code is bundled in the kernel and one of those is enabled/registered based on the oprofile_cpu_type check at the boot.

But things get little tricky incase of "compat" mode boot. IBM POWER System Server based processors has a compactibility mode feature, which simpily put is, Nth generation processor (lets say POWER8) will act and appear in a mode consistent with an earlier generation (N-1) processor (that is POWER7). And in this "compat" mode boot, kernel modify the "oprofile_cpu_type" to be Nth generation (POWER8). If Nth generation pmu driver is bundled (POWER8), it gets registered.

Key dependency here is to have distro support for latest processor performance monitoring support. Patch here adds a generic "compat-mode" performance monitoring driver to be register in absence of powernv platform specific pmu driver.

Driver supports only "cycles" and "instruction" events. "0x0001e" used as event code for "cycles" and "0x00002" used as event code for "instruction" events. New file called "generic-compat-pmu.c" is created to contain the driver specific code. And base raw event code format modeled on PPMU_ARCH_207S.

---
 arch/powerpc/include/asm/perf_event_server.h |   1 +
 arch/powerpc/perf/Makefile                   |   3 +-
 arch/powerpc/perf/core-book3s.c              |   2 +-
 arch/powerpc/perf/generic-compat-pmu.c       | 241 +++++++++++++++++++++++++++
 4 files changed, 245 insertions(+), 2 deletions(-)
 create mode 100644 arch/powerpc/perf/generic-compat-pmu.c
arch/powerpc/include/asm/perf_event_server.h +1 -0
index c5022f2c62a4..eb7e9cf875a4 100644
@@ -94,6 +94,7 @@ extern int init_power6_pmu(void);
 extern int init_power7_pmu(void);
 extern int init_power8_pmu(void);
 extern int init_power9_pmu(void);
+extern int init_generic_compat_pmu(void);
 
 
 /*
arch/powerpc/perf/Makefile +2 -1
index ab26df5bacb9..c155dcbb8691 100644
@@ -5,7 +5,8 @@ obj-$(CONFIG_PERF_EVENTS)	+= callchain.o perf_regs.o
 obj-$(CONFIG_PPC_PERF_CTRS)	+= core-book3s.o bhrb.o
 obj64-$(CONFIG_PPC_PERF_CTRS)	+= ppc970-pmu.o power5-pmu.o \
 				   power5+-pmu.o power6-pmu.o power7-pmu.o \
-				   isa207-common.o power8-pmu.o power9-pmu.o
+				   isa207-common.o power8-pmu.o power9-pmu.o \
+				   generic-compat-pmu.o
 obj32-$(CONFIG_PPC_PERF_CTRS)	+= mpc7450-pmu.o
 
 obj-$(CONFIG_PPC_POWERNV)	+= imc-pmu.o
arch/powerpc/perf/core-book3s.c +1 -1
index 9ba39a69b0ec..bb3672fbc45f 100644
@@ -2313,6 +2313,6 @@ static int __init init_ppc64_pmu(void)
 	else if (!init_ppc970_pmu())
 		return 0;
 	else
-		return -ENODEV;
+		return init_generic_compat_pmu();
 }
 early_initcall(init_ppc64_pmu);
arch/powerpc/perf/generic-compat-pmu.c new file +241 -0

241 lines not on this page · raw message

Signature · 1 line
2.7.4
#2 lore raw

Re: [PATCH 2/2] powerpc/perf: Add generic compat mode pmu driver

Thank you for the patch! Yet something to improve:

Hi Madhavan,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on powerpc/next]
[also build test ERROR on v5.1-rc3 next-20190401]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Madhavan-Srinivasan/powerpc-perf-init-platform-pmu-driver-from-core-book3s/20190401-104458
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc-pmac32_defconfig (attached as .config)
compiler: powerpc-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.2.0 make.cross ARCH=powerpc

All errors (new ones prefixed by >>):

arch/powerpc/perf/core-book3s.o: In function `init_ppc64_pmu':
core-book3s.c:(.init.text+0xc): undefined reference to init_power5_pmu' core-book3s.c:(.init.text+0x18): undefined reference to init_power5p_pmu' core-book3s.c:(.init.text+0x24): undefined reference to init_power6_pmu' core-book3s.c:(.init.text+0x30): undefined reference to init_power7_pmu' core-book3s.c:(.init.text+0x3c): undefined reference to init_power8_pmu' core-book3s.c:(.init.text+0x48): undefined reference to init_power9_pmu' core-book3s.c:(.init.text+0x54): undefined reference to `init_ppc970_pmu'

>> core-book3s.c:(.init.text+0x6c): undefined reference to `init_generic_compat_pmu'

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#3 lore raw

Re: [PATCH 2/2] powerpc/perf: Add generic compat mode pmu driver

Quoted 20 lines · kbuild test robot

Hi Madhavan,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on powerpc/next]
[also build test ERROR on v5.1-rc3 next-20190401]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Madhavan-Srinivasan/powerpc-perf-init-platform-pmu-driver-from-core-book3s/20190401-104458
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc-pmac32_defconfig (attached as .config)
compiler: powerpc-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.2.0 make.cross ARCH=powerpc

All errors (new ones prefixed by >>):

Quoted 9 lines
    arch/powerpc/perf/core-book3s.o: In function `init_ppc64_pmu':
    core-book3s.c:(.init.text+0xc): undefined reference to `init_power5_pmu'
    core-book3s.c:(.init.text+0x18): undefined reference to `init_power5p_pmu'
    core-book3s.c:(.init.text+0x24): undefined reference to `init_power6_pmu'
    core-book3s.c:(.init.text+0x30): undefined reference to `init_power7_pmu'
    core-book3s.c:(.init.text+0x3c): undefined reference to `init_power8_pmu'
    core-book3s.c:(.init.text+0x48): undefined reference to `init_power9_pmu'
    core-book3s.c:(.init.text+0x54): undefined reference to `init_ppc970_pmu'
Quoted 1 line
Quoted 1 line

core-book3s.c:(.init.text+0x6c): undefined reference to `init_generic_compat_pmu'

My bad, missed to add the code under CONFIG_64.
will send out a newer version.

Maddy

Quoted 3 lines

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#4 lore raw
In reply to Madhavan Srinivasan
Thank you for the patch! Yet something to improve:

Hi Madhavan,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on powerpc/next]
[also build test ERROR on v5.1-rc3 next-20190401]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Madhavan-Srinivasan/powerpc-perf-init-platform-pmu-driver-from-core-book3s/20190401-104458
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc-pmac32_defconfig (attached as .config)
compiler: powerpc-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.2.0 make.cross ARCH=powerpc

All errors (new ones prefixed by >>):

arch/powerpc/perf/core-book3s.o: In function `init_ppc64_pmu':

>> core-book3s.c:(.init.text+0xc): undefined reference to `init_power5_pmu'
>> core-book3s.c:(.init.text+0x20): undefined reference to `init_power5p_pmu'
>> core-book3s.c:(.init.text+0x2c): undefined reference to `init_power6_pmu'
>> core-book3s.c:(.init.text+0x38): undefined reference to `init_power7_pmu'
>> core-book3s.c:(.init.text+0x44): undefined reference to `init_power8_pmu'
>> core-book3s.c:(.init.text+0x50): undefined reference to `init_power9_pmu'
>> core-book3s.c:(.init.text+0x5c): undefined reference to `init_ppc970_pmu'

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation