linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf: Fix perf_event_{init,exit}_cpu stubs
@ 2022-11-03 22:43 Florian Fainelli
  2022-11-04 13:06 ` Peter Zijlstra
  0 siblings, 1 reply; 4+ messages in thread
From: Florian Fainelli @ 2022-11-03 22:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: anand.gore, william.zhang, Florian Fainelli, Peter Zijlstra,
	Ingo Molnar, Arnaldo Carvalho de Melo, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Namhyung Kim, Anna-Maria Gleixner,
	Sebastian Siewior, Thomas Gleixner,
	open list:PERFORMANCE EVENTS SUBSYSTEM

The original commit that introduced those stubs was already at fault,
but in the absence of a caller of perf_event_{init,exit}_cpu outside of
code that is compiled regardless of CONFIG_PERF_EVENTS, the build
failure cannot be observed. This was observed with the Android kernel to
produce a build failure similar to this:

    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);
      ^~~~~~~~~~~~~~~~~~~

Fixes: 00e16c3d68fc ("perf/core: Convert to hotplug state machine")
Reported-by: Anand Gore <anand.gore@broadcom.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 include/linux/perf_event.h | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 0031f7b4d9ab..592040e2398c 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -1678,8 +1678,15 @@ static struct device_attribute format_attr_##_name = __ATTR_RO(_name)
 int perf_event_init_cpu(unsigned int cpu);
 int perf_event_exit_cpu(unsigned int cpu);
 #else
-#define perf_event_init_cpu	NULL
-#define perf_event_exit_cpu	NULL
+static inline int perf_event_init_cpu(unsigned int cpu)
+{
+	return 0;
+}
+
+static inline int perf_event_exit_cpu(unsigned int cpu)
+{
+	return 0;
+}
 #endif
 
 extern void __weak arch_perf_update_userpage(struct perf_event *event,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] perf: Fix perf_event_{init,exit}_cpu stubs
  2022-11-03 22:43 [PATCH] perf: Fix perf_event_{init,exit}_cpu stubs Florian Fainelli
@ 2022-11-04 13:06 ` Peter Zijlstra
  2022-11-04 17:38   ` Florian Fainelli
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Zijlstra @ 2022-11-04 13:06 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: linux-kernel, anand.gore, william.zhang, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Anna-Maria Gleixner, Sebastian Siewior,
	Thomas Gleixner, open list:PERFORMANCE EVENTS SUBSYSTEM

On Thu, Nov 03, 2022 at 03:43:03PM -0700, Florian Fainelli wrote:
> The original commit that introduced those stubs was already at fault,
> but in the absence of a caller of perf_event_{init,exit}_cpu outside of
> code that is compiled regardless of CONFIG_PERF_EVENTS, the build
> failure cannot be observed. This was observed with the Android kernel to
> produce a build failure similar to this:
> 
>     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);
>       ^~~~~~~~~~~~~~~~~~~

What is the actual problem reported here? Did you see all the other NULL
assignments in cpuhp_hp_states ?

> 
> Fixes: 00e16c3d68fc ("perf/core: Convert to hotplug state machine")
> Reported-by: Anand Gore <anand.gore@broadcom.com>
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
>  include/linux/perf_event.h | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
> index 0031f7b4d9ab..592040e2398c 100644
> --- a/include/linux/perf_event.h
> +++ b/include/linux/perf_event.h
> @@ -1678,8 +1678,15 @@ static struct device_attribute format_attr_##_name = __ATTR_RO(_name)
>  int perf_event_init_cpu(unsigned int cpu);
>  int perf_event_exit_cpu(unsigned int cpu);
>  #else
> -#define perf_event_init_cpu	NULL
> -#define perf_event_exit_cpu	NULL
> +static inline int perf_event_init_cpu(unsigned int cpu)
> +{
> +	return 0;
> +}
> +
> +static inline int perf_event_exit_cpu(unsigned int cpu)
> +{
> +	return 0;
> +}
>  #endif
>  
>  extern void __weak arch_perf_update_userpage(struct perf_event *event,
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] perf: Fix perf_event_{init,exit}_cpu stubs
  2022-11-04 13:06 ` Peter Zijlstra
@ 2022-11-04 17:38   ` Florian Fainelli
  2022-11-10 19:05     ` Florian Fainelli
  0 siblings, 1 reply; 4+ messages in thread
From: Florian Fainelli @ 2022-11-04 17:38 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: linux-kernel, anand.gore, william.zhang, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Anna-Maria Gleixner, Sebastian Siewior,
	Thomas Gleixner, open list:PERFORMANCE EVENTS SUBSYSTEM



On 11/4/2022 6:06 AM, Peter Zijlstra wrote:
> On Thu, Nov 03, 2022 at 03:43:03PM -0700, Florian Fainelli wrote:
>> The original commit that introduced those stubs was already at fault,
>> but in the absence of a caller of perf_event_{init,exit}_cpu outside of
>> code that is compiled regardless of CONFIG_PERF_EVENTS, the build
>> failure cannot be observed. This was observed with the Android kernel to
>> produce a build failure similar to this:
>>
>>      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);
>>        ^~~~~~~~~~~~~~~~~~~
> 
> What is the actual problem reported here? Did you see all the other NULL
> assignments in cpuhp_hp_states ?

Anand reported to me that the following downstream commit in the Android 
common kernel repository:

https://android.googlesource.com/kernel/common/+/ca927bd22ad8bd26fd8dcebf3c7f2a093385d8ea

was resulting in the build failure above.

While this is an Android inflicted change and I still intend to get a 
fix there, upon closer look, the build failure could be experienced 
upstream as well with any code calling perf_event_{init,exit}_cpu() as a 
regular function call as opposed to being used as a function pointer.

This felt worthy of fixing in the upstream kernel, hence this patch.
-- 
Florian


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] perf: Fix perf_event_{init,exit}_cpu stubs
  2022-11-04 17:38   ` Florian Fainelli
@ 2022-11-10 19:05     ` Florian Fainelli
  0 siblings, 0 replies; 4+ messages in thread
From: Florian Fainelli @ 2022-11-10 19:05 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: linux-kernel, anand.gore, william.zhang, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Anna-Maria Gleixner, Sebastian Siewior,
	Thomas Gleixner, open list:PERFORMANCE EVENTS SUBSYSTEM

On 11/4/22 10:38, Florian Fainelli wrote:
> 
> 
> On 11/4/2022 6:06 AM, Peter Zijlstra wrote:
>> On Thu, Nov 03, 2022 at 03:43:03PM -0700, Florian Fainelli wrote:
>>> The original commit that introduced those stubs was already at fault,
>>> but in the absence of a caller of perf_event_{init,exit}_cpu outside of
>>> code that is compiled regardless of CONFIG_PERF_EVENTS, the build
>>> failure cannot be observed. This was observed with the Android kernel to
>>> produce a build failure similar to this:
>>>
>>>      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);
>>>        ^~~~~~~~~~~~~~~~~~~
>>
>> What is the actual problem reported here? Did you see all the other NULL
>> assignments in cpuhp_hp_states ?
> 
> Anand reported to me that the following downstream commit in the Android 
> common kernel repository:
> 
> https://android.googlesource.com/kernel/common/+/ca927bd22ad8bd26fd8dcebf3c7f2a093385d8ea
> 
> was resulting in the build failure above.
> 
> While this is an Android inflicted change and I still intend to get a 
> fix there, upon closer look, the build failure could be experienced 
> upstream as well with any code calling perf_event_{init,exit}_cpu() as a 
> regular function call as opposed to being used as a function pointer.
> 
> This felt worthy of fixing in the upstream kernel, hence this patch.

No response meaning it's a don't care because upstream is not (yet?) 
impacted?
-- 
Florian


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-11-10 19:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-03 22:43 [PATCH] perf: Fix perf_event_{init,exit}_cpu stubs Florian Fainelli
2022-11-04 13:06 ` Peter Zijlstra
2022-11-04 17:38   ` Florian Fainelli
2022-11-10 19:05     ` Florian Fainelli

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).