linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] static_call: Fix return type of static_call_init
@ 2020-09-28 23:09 Nathan Chancellor
  2020-09-29 15:39 ` Sami Tolvanen
  0 siblings, 1 reply; 2+ messages in thread
From: Nathan Chancellor @ 2020-09-28 23:09 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Josh Poimboeuf, Steven Rostedt (VMware)
  Cc: linux-kernel, clang-built-linux, Sami Tolvanen, Nathan Chancellor

Functions that are passed to early_initcall should be of type
initcall_t, which expects a return type of int. This is not currently an
error but a patch in the Clang LTO series could change that in the
future.

Fixes: 9183c3f9ed71 ("static_call: Add inline static call infrastructure")
Link: https://lore.kernel.org/lkml/20200904044559.GA507165@ubuntu-n2-xlarge-x86/
Link: https://lore.kernel.org/lkml/20200903203053.3411268-17-samitolvanen@google.com/
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 include/linux/static_call.h | 6 +++---
 kernel/static_call.c        | 5 +++--
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/include/linux/static_call.h b/include/linux/static_call.h
index bfa2ba39be57..695da4c9b338 100644
--- a/include/linux/static_call.h
+++ b/include/linux/static_call.h
@@ -136,7 +136,7 @@ extern void arch_static_call_transform(void *site, void *tramp, void *func, bool
 
 #ifdef CONFIG_HAVE_STATIC_CALL_INLINE
 
-extern void __init static_call_init(void);
+extern int __init static_call_init(void);
 
 struct static_call_mod {
 	struct static_call_mod *next;
@@ -187,7 +187,7 @@ extern int static_call_text_reserved(void *start, void *end);
 
 #elif defined(CONFIG_HAVE_STATIC_CALL)
 
-static inline void static_call_init(void) { }
+static inline int static_call_init(void) { return 0; }
 
 struct static_call_key {
 	void *func;
@@ -234,7 +234,7 @@ static inline int static_call_text_reserved(void *start, void *end)
 
 #else /* Generic implementation */
 
-static inline void static_call_init(void) { }
+static inline int static_call_init(void) { return 0; }
 
 struct static_call_key {
 	void *func;
diff --git a/kernel/static_call.c b/kernel/static_call.c
index f8362b3f8fd5..84565c2a41b8 100644
--- a/kernel/static_call.c
+++ b/kernel/static_call.c
@@ -410,12 +410,12 @@ int static_call_text_reserved(void *start, void *end)
 	return __static_call_mod_text_reserved(start, end);
 }
 
-void __init static_call_init(void)
+int __init static_call_init(void)
 {
 	int ret;
 
 	if (static_call_initialized)
-		return;
+		return 0;
 
 	cpus_read_lock();
 	static_call_lock();
@@ -434,6 +434,7 @@ void __init static_call_init(void)
 #ifdef CONFIG_MODULES
 	register_module_notifier(&static_call_module_nb);
 #endif
+	return 0;
 }
 early_initcall(static_call_init);
 

base-commit: de394e7568ce2cdb4643ed230169f484f25f9442
-- 
2.28.0


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

* Re: [PATCH] static_call: Fix return type of static_call_init
  2020-09-28 23:09 [PATCH] static_call: Fix return type of static_call_init Nathan Chancellor
@ 2020-09-29 15:39 ` Sami Tolvanen
  0 siblings, 0 replies; 2+ messages in thread
From: Sami Tolvanen @ 2020-09-29 15:39 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Ingo Molnar, Peter Zijlstra, Josh Poimboeuf,
	Steven Rostedt (VMware),
	LKML, clang-built-linux

Hi Nathan,

On Mon, Sep 28, 2020 at 4:09 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> Functions that are passed to early_initcall should be of type
> initcall_t, which expects a return type of int. This is not currently an
> error but a patch in the Clang LTO series could change that in the
> future.
>
> Fixes: 9183c3f9ed71 ("static_call: Add inline static call infrastructure")
> Link: https://lore.kernel.org/lkml/20200904044559.GA507165@ubuntu-n2-xlarge-x86/
> Link: https://lore.kernel.org/lkml/20200903203053.3411268-17-samitolvanen@google.com/
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
>  include/linux/static_call.h | 6 +++---
>  kernel/static_call.c        | 5 +++--
>  2 files changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/include/linux/static_call.h b/include/linux/static_call.h
> index bfa2ba39be57..695da4c9b338 100644
> --- a/include/linux/static_call.h
> +++ b/include/linux/static_call.h
> @@ -136,7 +136,7 @@ extern void arch_static_call_transform(void *site, void *tramp, void *func, bool
>
>  #ifdef CONFIG_HAVE_STATIC_CALL_INLINE
>
> -extern void __init static_call_init(void);
> +extern int __init static_call_init(void);
>
>  struct static_call_mod {
>         struct static_call_mod *next;Thank you for sending the patch, this looks correct to me.
> @@ -187,7 +187,7 @@ extern int static_call_text_reserved(void *start, void *end);
>
>  #elif defined(CONFIG_HAVE_STATIC_CALL)
>
> -static inline void static_call_init(void) { }
> +static inline int static_call_init(void) { return 0; }
>
>  struct static_call_key {
>         void *func;
> @@ -234,7 +234,7 @@ static inline int static_call_text_reserved(void *start, void *end)
>
>  #else /* Generic implementation */
>
> -static inline void static_call_init(void) { }
> +static inline int static_call_init(void) { return 0; }
>
>  struct static_call_key {
>         void *func;
> diff --git a/kernel/static_call.c b/kernel/static_call.c
> index f8362b3f8fd5..84565c2a41b8 100644
> --- a/kernel/static_call.c
> +++ b/kernel/static_call.c
> @@ -410,12 +410,12 @@ int static_call_text_reserved(void *start, void *end)
>         return __static_call_mod_text_reserved(start, end);
>  }
>
> -void __init static_call_init(void)
> +int __init static_call_init(void)
>  {
>         int ret;
>
>         if (static_call_initialized)
> -               return;
> +               return 0;
>
>         cpus_read_lock();
>         static_call_lock();
> @@ -434,6 +434,7 @@ void __init static_call_init(void)
>  #ifdef CONFIG_MODULES
>         register_module_notifier(&static_call_module_nb);
>  #endif
> +       return 0;
>  }
>  early_initcall(static_call_init);
>
>
> base-commit: de394e7568ce2cdb4643ed230169f484f25f9442
> --
> 2.28.0

Thank you for sending the patch, this looks correct to me.

Reviewed-by: Sami Tolvanen <samitolvanen@google.com>

Sami

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

end of thread, other threads:[~2020-09-29 15:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-28 23:09 [PATCH] static_call: Fix return type of static_call_init Nathan Chancellor
2020-09-29 15:39 ` Sami Tolvanen

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