1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 #ifndef _LINUX_LIVEPATCH_SCHED_H_
3 #define _LINUX_LIVEPATCH_SCHED_H_
5 #include <linux/jump_label.h>
6 #include <linux/static_call_types.h>
8 #ifdef CONFIG_LIVEPATCH
10 void __klp_sched_try_switch(void);
12 #if !defined(CONFIG_PREEMPT_DYNAMIC) || !defined(CONFIG_HAVE_PREEMPT_DYNAMIC_CALL)
14 DECLARE_STATIC_KEY_FALSE(klp_sched_try_switch_key);
16 static __always_inline void klp_sched_try_switch(void)
18 if (static_branch_unlikely(&klp_sched_try_switch_key))
19 __klp_sched_try_switch();
22 #endif /* !CONFIG_PREEMPT_DYNAMIC || !CONFIG_HAVE_PREEMPT_DYNAMIC_CALL */
24 #else /* !CONFIG_LIVEPATCH */
25 static inline void klp_sched_try_switch(void) {}
26 static inline void __klp_sched_try_switch(void) {}
27 #endif /* CONFIG_LIVEPATCH */
29 #endif /* _LINUX_LIVEPATCH_SCHED_H_ */