From 42a63500a90dfb2517179022b2aa2c3d9c0f81c5 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 16 Nov 2022 02:36:59 +0100 Subject: [PATCH] ANDROID: cpu/hotplug: call perf event through function pointer After commit ca927bd22ad8 ("ANDROID: cpu/hotplug: avoid breaking Android ABI by fusing cpuhp steps") a build error appears with CONFIG_PERF_EVENTS disabled: In file included from ./include/uapi/linux/posix_types.h:5, from ./include/uapi/linux/types.h:14, from ./include/linux/types.h:6, from ./include/linux/limits.h:6, from ./include/linux/kernel.h:7, from ./include/linux/sched/mm.h:5, from kernel/cpu.c:6: kernel/cpu.c: In function 'random_and_perf_prepare_fusion': ./include/linux/stddef.h:8:14: error: called object is not a function or function pointer #define NULL ((void *)0) ^ ./include/linux/perf_event.h:1607:29: note: in expansion of macro 'NULL' #define perf_event_init_cpu NULL ^~~~ kernel/cpu.c:1686:2: note: in expansion of macro 'perf_event_init_cpu' perf_event_init_cpu(cpu); ^~~~~~~~~~~~~~~~~~~ CC kernel/power/console.o make[1]: *** [scripts/Makefile.build:287: kernel/cpu.o] Error 1 make[1]: *** Waiting for unfinished jobs.... Fix this by always calling through the function pointers like the original code. Fixes: ca927bd22ad8 ("ANDROID: cpu/hotplug: avoid breaking Android ABI by fusing cpuhp steps") Reported-by: Anand Gore Reported-by: Florian Fainelli Cc: Todd Kjos Change-Id: I46a7c4a056d96eb531c06d8d0bbfdc7eac1cb271 Signed-off-by: Jason A. Donenfeld --- kernel/cpu.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/kernel/cpu.c b/kernel/cpu.c index e3fb370a6766..01866de55679 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -1834,14 +1834,24 @@ int __boot_cpu_id; /* Horrific hacks because we can't add more to cpuhp_hp_states. */ static int random_and_perf_prepare_fusion(unsigned int cpu) { - perf_event_init_cpu(cpu); - random_prepare_cpu(cpu); + int (*fn)(unsigned int cpu); + fn = perf_event_init_cpu; + if (fn) + fn(cpu); + fn = random_prepare_cpu; + if (fn) + fn(cpu); return 0; } static int random_and_workqueue_online_fusion(unsigned int cpu) { - workqueue_online_cpu(cpu); - random_online_cpu(cpu); + int (*fn)(unsigned int cpu); + fn = workqueue_online_cpu; + if (fn) + fn(cpu); + fn = random_online_cpu; + if (fn) + fn(cpu); return 0; }