mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
preempt/dynamic: Provide cond_resched() and might_resched() static calls
Provide static calls to control cond_resched() (called in !CONFIG_PREEMPT) and might_resched() (called in CONFIG_PREEMPT_VOLUNTARY) to that we can override their behaviour when preempt= is overriden. Since the default behaviour is full preemption, both their calls are ignored when preempt= isn't passed. [fweisbec: branch might_resched() directly to __cond_resched(), only define static calls when PREEMPT_DYNAMIC] Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Frederic Weisbecker <frederic@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: https://lkml.kernel.org/r/20210118141223.123667-6-frederic@kernel.org
This commit is contained in:
parent
6ef869e064
commit
b965f1ddb4
3 changed files with 56 additions and 10 deletions
|
@ -15,7 +15,7 @@
|
|||
#include <linux/typecheck.h>
|
||||
#include <linux/printk.h>
|
||||
#include <linux/build_bug.h>
|
||||
|
||||
#include <linux/static_call_types.h>
|
||||
#include <asm/byteorder.h>
|
||||
|
||||
#include <uapi/linux/kernel.h>
|
||||
|
@ -81,11 +81,26 @@ struct pt_regs;
|
|||
struct user;
|
||||
|
||||
#ifdef CONFIG_PREEMPT_VOLUNTARY
|
||||
extern int _cond_resched(void);
|
||||
# define might_resched() _cond_resched()
|
||||
|
||||
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)();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
# define might_resched() do { } while (0)
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_PREEMPT_* */
|
||||
|
||||
#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
|
||||
extern void ___might_sleep(const char *file, int line, int preempt_offset);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue