[RFC PATCH 29/86] Revert "preempt/dynamic: Provide cond_resched() and might_resched() static calls"

From: Ankur Arora
Date: Tue Nov 07 2023 - 17:02:59 EST


This reverts commit b965f1ddb47daa5b8b2e2bc9c921431236830367.

Signed-off-by: Ankur Arora <ankur.a.arora@xxxxxxxxxx>
---
include/linux/kernel.h | 22 +++-------------------
include/linux/sched.h | 27 +++------------------------
kernel/sched/core.c | 14 +++-----------
3 files changed, 9 insertions(+), 54 deletions(-)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 5f99720d0cca..cf077cd69643 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -30,7 +30,6 @@
#include <linux/printk.h>
#include <linux/build_bug.h>
#include <linux/sprintf.h>
-#include <linux/static_call_types.h>
#include <linux/instruction_pointer.h>
#include <asm/byteorder.h>

@@ -97,26 +96,11 @@ struct completion;
struct user;

#ifdef CONFIG_PREEMPT_VOLUNTARY
-
-extern int __cond_resched(void);
-# define might_resched() __cond_resched()
-
-#elif defined(CONFIG_PREEMPT_DYNAMIC)
-
-extern int __cond_resched(void);
-
-DECLARE_STATIC_CALL(might_resched, __cond_resched);
-
-static __always_inline void might_resched(void)
-{
- static_call(might_resched)();
-}
-
+extern int _cond_resched(void);
+# define might_resched() _cond_resched()
#else
-
# define might_resched() do { } while (0)
-
-#endif /* CONFIG_PREEMPT_* */
+#endif

#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
extern void __might_resched(const char *file, int line, unsigned int offsets);
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 2b1f3008c90e..95d47783ff6e 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2081,32 +2081,11 @@ static inline int test_tsk_need_resched(struct task_struct *tsk)
* value indicates whether a reschedule was done in fact.
* cond_resched_lock() will drop the spinlock before scheduling,
*/
-#if !defined(CONFIG_PREEMPTION) || defined(CONFIG_PREEMPT_DYNAMIC)
-extern int __cond_resched(void);
-
-#ifdef CONFIG_PREEMPT_DYNAMIC
-
-DECLARE_STATIC_CALL(cond_resched, __cond_resched);
-
-static __always_inline int _cond_resched(void)
-{
- return static_call(cond_resched)();
-}
-
+#ifndef CONFIG_PREEMPTION
+extern int _cond_resched(void);
#else
-
-static inline int _cond_resched(void)
-{
- return __cond_resched();
-}
-
-#endif /* CONFIG_PREEMPT_DYNAMIC */
-
-#else
-
static inline int _cond_resched(void) { return 0; }
-
-#endif /* !defined(CONFIG_PREEMPTION) || defined(CONFIG_PREEMPT_DYNAMIC) */
+#endif

#define cond_resched() ({ \
__might_resched(__FILE__, __LINE__, 0); \
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 2e191992109b..5a0bf43975d4 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -8515,8 +8515,8 @@ SYSCALL_DEFINE0(sched_yield)
return 0;
}

-#if !defined(CONFIG_PREEMPTION) || defined(CONFIG_PREEMPT_DYNAMIC)
-int __sched __cond_resched(void)
+#ifndef CONFIG_PREEMPTION
+int __sched _cond_resched(void)
{
if (should_resched(0)) {
preempt_schedule_common();
@@ -8538,15 +8538,7 @@ int __sched __cond_resched(void)
#endif
return 0;
}
-EXPORT_SYMBOL(__cond_resched);
-#endif
-
-#ifdef CONFIG_PREEMPT_DYNAMIC
-DEFINE_STATIC_CALL_RET0(cond_resched, __cond_resched);
-EXPORT_STATIC_CALL(cond_resched);
-
-DEFINE_STATIC_CALL_RET0(might_resched, __cond_resched);
-EXPORT_STATIC_CALL(might_resched);
+EXPORT_SYMBOL(_cond_resched);
#endif

/*
--
2.31.1