1 /* SPDX-License-Identifier: GPL-2.0-or-later * 1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 #ifndef _LINUX_LIVEPATCH_SCHED_H_ 2 #ifndef _LINUX_LIVEPATCH_SCHED_H_ 3 #define _LINUX_LIVEPATCH_SCHED_H_ 3 #define _LINUX_LIVEPATCH_SCHED_H_ 4 4 5 #include <linux/jump_label.h> 5 #include <linux/jump_label.h> 6 #include <linux/static_call_types.h> 6 #include <linux/static_call_types.h> 7 7 8 #ifdef CONFIG_LIVEPATCH 8 #ifdef CONFIG_LIVEPATCH 9 9 10 void __klp_sched_try_switch(void); 10 void __klp_sched_try_switch(void); 11 11 12 #if !defined(CONFIG_PREEMPT_DYNAMIC) || !defin 12 #if !defined(CONFIG_PREEMPT_DYNAMIC) || !defined(CONFIG_HAVE_PREEMPT_DYNAMIC_CALL) 13 13 14 DECLARE_STATIC_KEY_FALSE(klp_sched_try_switch_ 14 DECLARE_STATIC_KEY_FALSE(klp_sched_try_switch_key); 15 15 16 static __always_inline void klp_sched_try_swit 16 static __always_inline void klp_sched_try_switch(void) 17 { 17 { 18 if (static_branch_unlikely(&klp_sched_ 18 if (static_branch_unlikely(&klp_sched_try_switch_key)) 19 __klp_sched_try_switch(); 19 __klp_sched_try_switch(); 20 } 20 } 21 21 22 #endif /* !CONFIG_PREEMPT_DYNAMIC || !CONFIG_H 22 #endif /* !CONFIG_PREEMPT_DYNAMIC || !CONFIG_HAVE_PREEMPT_DYNAMIC_CALL */ 23 23 24 #else /* !CONFIG_LIVEPATCH */ 24 #else /* !CONFIG_LIVEPATCH */ 25 static inline void klp_sched_try_switch(void) 25 static inline void klp_sched_try_switch(void) {} 26 static inline void __klp_sched_try_switch(void 26 static inline void __klp_sched_try_switch(void) {} 27 #endif /* CONFIG_LIVEPATCH */ 27 #endif /* CONFIG_LIVEPATCH */ 28 28 29 #endif /* _LINUX_LIVEPATCH_SCHED_H_ */ 29 #endif /* _LINUX_LIVEPATCH_SCHED_H_ */ 30 30
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.