From: Arnd Bergmann <arnd@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>,
Josh Poimboeuf <jpoimboe@redhat.com>,
Jason Baron <jbaron@akamai.com>, Ingo Molnar <mingo@redhat.com>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
Steven Rostedt <rostedt@goodmis.org>,
Ard Biesheuvel <ardb@kernel.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Daniel Bristot de Oliveira <bristot@redhat.com>,
Frederic Weisbecker <frederic@kernel.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH] static_call: fix function type mismatch
Date: Mon, 22 Mar 2021 18:06:37 +0100 [thread overview]
Message-ID: <20210322170711.1855115-1-arnd@kernel.org> (raw)
From: Arnd Bergmann <arnd@arndb.de>
The __static_call_return0() function is declared to return a 'long',
while it aliases a couple of functions that all return 'int'. When
building with 'make W=1', gcc warns about this:
kernel/sched/core.c:5420:37: error: cast between incompatible function types from 'long int (*)(void)' to 'int (*)(void)' [-Werror=cast-function-type]
5420 | static_call_update(might_resched, (typeof(&__cond_resched)) __static_call_return0);
Change the function to return 'int' as well, but remove the cast to
ensure we get a warning if any of the types ever change.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
include/linux/static_call.h | 6 +++---
kernel/sched/core.c | 6 +++---
kernel/static_call.c | 2 +-
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/include/linux/static_call.h b/include/linux/static_call.h
index 85ecc789f4ff..3fc2975906ad 100644
--- a/include/linux/static_call.h
+++ b/include/linux/static_call.h
@@ -148,7 +148,7 @@ extern void __static_call_update(struct static_call_key *key, void *tramp, void
extern int static_call_mod_init(struct module *mod);
extern int static_call_text_reserved(void *start, void *end);
-extern long __static_call_return0(void);
+extern int __static_call_return0(void);
#define __DEFINE_STATIC_CALL(name, _func, _func_init) \
DECLARE_STATIC_CALL(name, _func); \
@@ -221,7 +221,7 @@ static inline int static_call_text_reserved(void *start, void *end)
return 0;
}
-static inline long __static_call_return0(void)
+static inline int __static_call_return0(void)
{
return 0;
}
@@ -247,7 +247,7 @@ struct static_call_key {
void *func;
};
-static inline long __static_call_return0(void)
+static inline int __static_call_return0(void)
{
return 0;
}
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 3a36f0b0742e..d22c609b9484 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5399,7 +5399,7 @@ static void sched_dynamic_update(int mode)
switch (mode) {
case preempt_dynamic_none:
static_call_update(cond_resched, __cond_resched);
- static_call_update(might_resched, (typeof(&__cond_resched)) __static_call_return0);
+ static_call_update(might_resched, __static_call_return0);
static_call_update(preempt_schedule, (typeof(&preempt_schedule)) NULL);
static_call_update(preempt_schedule_notrace, (typeof(&preempt_schedule_notrace)) NULL);
static_call_update(irqentry_exit_cond_resched, (typeof(&irqentry_exit_cond_resched)) NULL);
@@ -5416,8 +5416,8 @@ static void sched_dynamic_update(int mode)
break;
case preempt_dynamic_full:
- static_call_update(cond_resched, (typeof(&__cond_resched)) __static_call_return0);
- static_call_update(might_resched, (typeof(&__cond_resched)) __static_call_return0);
+ static_call_update(cond_resched, __static_call_return0);
+ static_call_update(might_resched, __static_call_return0);
static_call_update(preempt_schedule, __preempt_schedule_func);
static_call_update(preempt_schedule_notrace, __preempt_schedule_notrace_func);
static_call_update(irqentry_exit_cond_resched, irqentry_exit_cond_resched);
diff --git a/kernel/static_call.c b/kernel/static_call.c
index 6906c6ec4c97..11aa4bcee315 100644
--- a/kernel/static_call.c
+++ b/kernel/static_call.c
@@ -489,7 +489,7 @@ int __init static_call_init(void)
}
early_initcall(static_call_init);
-long __static_call_return0(void)
+int __static_call_return0(void)
{
return 0;
}
--
2.29.2
next reply other threads:[~2021-03-22 17:08 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-22 17:06 Arnd Bergmann [this message]
2021-03-22 19:32 ` [PATCH] static_call: fix function type mismatch Steven Rostedt
2021-03-22 20:47 ` Peter Zijlstra
2021-03-22 21:18 ` Arnd Bergmann
2021-03-22 21:29 ` Steven Rostedt
2021-03-23 7:47 ` Peter Zijlstra
2021-03-24 12:46 ` Rasmus Villemoes
2021-03-24 16:01 ` Sami Tolvanen
2021-03-24 16:45 ` Rasmus Villemoes
2021-03-24 17:33 ` Peter Zijlstra
2021-03-24 19:16 ` Peter Zijlstra
2021-03-24 21:51 ` Rasmus Villemoes
2021-03-24 22:34 ` Sami Tolvanen
2021-03-24 22:53 ` Rasmus Villemoes
2021-03-24 23:40 ` Sami Tolvanen
2021-03-25 0:42 ` Rasmus Villemoes
2021-03-25 7:42 ` Peter Zijlstra
2021-03-25 7:45 ` Ard Biesheuvel
2021-03-25 8:27 ` Rasmus Villemoes
2021-03-23 7:35 ` Peter Zijlstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210322170711.1855115-1-arnd@kernel.org \
--to=arnd@kernel.org \
--cc=ardb@kernel.org \
--cc=arnd@arndb.de \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=frederic@kernel.org \
--cc=jbaron@akamai.com \
--cc=jpoimboe@redhat.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.