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