| 1 | #ifndef _LINUX_SCHED_ISOLATION_H | 
|---|
| 2 | #define _LINUX_SCHED_ISOLATION_H | 
|---|
| 3 |  | 
|---|
| 4 | #include <linux/cpumask.h> | 
|---|
| 5 | #include <linux/cpuset.h> | 
|---|
| 6 | #include <linux/init.h> | 
|---|
| 7 | #include <linux/tick.h> | 
|---|
| 8 |  | 
|---|
| 9 | enum hk_type { | 
|---|
| 10 | HK_TYPE_DOMAIN, | 
|---|
| 11 | HK_TYPE_MANAGED_IRQ, | 
|---|
| 12 | HK_TYPE_KERNEL_NOISE, | 
|---|
| 13 | HK_TYPE_MAX, | 
|---|
| 14 |  | 
|---|
| 15 | /* | 
|---|
| 16 | * The following housekeeping types are only set by the nohz_full | 
|---|
| 17 | * boot commandline option. So they can share the same value. | 
|---|
| 18 | */ | 
|---|
| 19 | HK_TYPE_TICK    = HK_TYPE_KERNEL_NOISE, | 
|---|
| 20 | HK_TYPE_TIMER   = HK_TYPE_KERNEL_NOISE, | 
|---|
| 21 | HK_TYPE_RCU     = HK_TYPE_KERNEL_NOISE, | 
|---|
| 22 | HK_TYPE_MISC    = HK_TYPE_KERNEL_NOISE, | 
|---|
| 23 | HK_TYPE_WQ      = HK_TYPE_KERNEL_NOISE, | 
|---|
| 24 | HK_TYPE_KTHREAD = HK_TYPE_KERNEL_NOISE | 
|---|
| 25 | }; | 
|---|
| 26 |  | 
|---|
| 27 | #ifdef CONFIG_CPU_ISOLATION | 
|---|
| 28 | DECLARE_STATIC_KEY_FALSE(housekeeping_overridden); | 
|---|
| 29 | extern int housekeeping_any_cpu(enum hk_type type); | 
|---|
| 30 | extern const struct cpumask *housekeeping_cpumask(enum hk_type type); | 
|---|
| 31 | extern bool housekeeping_enabled(enum hk_type type); | 
|---|
| 32 | extern void housekeeping_affine(struct task_struct *t, enum hk_type type); | 
|---|
| 33 | extern bool housekeeping_test_cpu(int cpu, enum hk_type type); | 
|---|
| 34 | extern void __init housekeeping_init(void); | 
|---|
| 35 |  | 
|---|
| 36 | #else | 
|---|
| 37 |  | 
|---|
| 38 | static inline int housekeeping_any_cpu(enum hk_type type) | 
|---|
| 39 | { | 
|---|
| 40 | return smp_processor_id(); | 
|---|
| 41 | } | 
|---|
| 42 |  | 
|---|
| 43 | static inline const struct cpumask *housekeeping_cpumask(enum hk_type type) | 
|---|
| 44 | { | 
|---|
| 45 | return cpu_possible_mask; | 
|---|
| 46 | } | 
|---|
| 47 |  | 
|---|
| 48 | static inline bool housekeeping_enabled(enum hk_type type) | 
|---|
| 49 | { | 
|---|
| 50 | return false; | 
|---|
| 51 | } | 
|---|
| 52 |  | 
|---|
| 53 | static inline void housekeeping_affine(struct task_struct *t, | 
|---|
| 54 | enum hk_type type) { } | 
|---|
| 55 |  | 
|---|
| 56 | static inline bool housekeeping_test_cpu(int cpu, enum hk_type type) | 
|---|
| 57 | { | 
|---|
| 58 | return true; | 
|---|
| 59 | } | 
|---|
| 60 |  | 
|---|
| 61 | static inline void housekeeping_init(void) { } | 
|---|
| 62 | #endif /* CONFIG_CPU_ISOLATION */ | 
|---|
| 63 |  | 
|---|
| 64 | static inline bool housekeeping_cpu(int cpu, enum hk_type type) | 
|---|
| 65 | { | 
|---|
| 66 | #ifdef CONFIG_CPU_ISOLATION | 
|---|
| 67 | if (static_branch_unlikely(&housekeeping_overridden)) | 
|---|
| 68 | return housekeeping_test_cpu(cpu, type); | 
|---|
| 69 | #endif | 
|---|
| 70 | return true; | 
|---|
| 71 | } | 
|---|
| 72 |  | 
|---|
| 73 | static inline bool cpu_is_isolated(int cpu) | 
|---|
| 74 | { | 
|---|
| 75 | return !housekeeping_test_cpu(cpu, type: HK_TYPE_DOMAIN) || | 
|---|
| 76 | !housekeeping_test_cpu(cpu, type: HK_TYPE_TICK) || | 
|---|
| 77 | cpuset_cpu_is_isolated(cpu); | 
|---|
| 78 | } | 
|---|
| 79 |  | 
|---|
| 80 | #endif /* _LINUX_SCHED_ISOLATION_H */ | 
|---|
| 81 |  | 
|---|