Frederic Weisbecker | 7863406 | 2017-10-27 04:42:28 +0200 | [diff] [blame] | 1 | #ifndef _LINUX_SCHED_ISOLATION_H |
| 2 | #define _LINUX_SCHED_ISOLATION_H |
| 3 | |
| 4 | #include <linux/cpumask.h> |
| 5 | #include <linux/init.h> |
| 6 | #include <linux/tick.h> |
| 7 | |
Frederic Weisbecker | de20155 | 2017-10-27 04:42:35 +0200 | [diff] [blame] | 8 | enum hk_flags { |
| 9 | HK_FLAG_TIMER = 1, |
| 10 | HK_FLAG_RCU = (1 << 1), |
| 11 | HK_FLAG_MISC = (1 << 2), |
| 12 | HK_FLAG_SCHED = (1 << 3), |
Frederic Weisbecker | 6f1982f | 2017-10-27 04:42:36 +0200 | [diff] [blame] | 13 | HK_FLAG_TICK = (1 << 4), |
Frederic Weisbecker | edb9382 | 2017-10-27 04:42:37 +0200 | [diff] [blame] | 14 | HK_FLAG_DOMAIN = (1 << 5), |
Frederic Weisbecker | de20155 | 2017-10-27 04:42:35 +0200 | [diff] [blame] | 15 | }; |
| 16 | |
Frederic Weisbecker | 5c4991e | 2017-10-27 04:42:34 +0200 | [diff] [blame] | 17 | #ifdef CONFIG_CPU_ISOLATION |
Frederic Weisbecker | e179f5a | 2017-10-27 04:42:32 +0200 | [diff] [blame] | 18 | DECLARE_STATIC_KEY_FALSE(housekeeping_overriden); |
Frederic Weisbecker | de20155 | 2017-10-27 04:42:35 +0200 | [diff] [blame] | 19 | extern int housekeeping_any_cpu(enum hk_flags flags); |
| 20 | extern const struct cpumask *housekeeping_cpumask(enum hk_flags flags); |
| 21 | extern void housekeeping_affine(struct task_struct *t, enum hk_flags flags); |
| 22 | extern bool housekeeping_test_cpu(int cpu, enum hk_flags flags); |
Frederic Weisbecker | 7863406 | 2017-10-27 04:42:28 +0200 | [diff] [blame] | 23 | extern void __init housekeeping_init(void); |
Frederic Weisbecker | 7e56a1c | 2017-10-27 04:42:31 +0200 | [diff] [blame] | 24 | |
Frederic Weisbecker | 7863406 | 2017-10-27 04:42:28 +0200 | [diff] [blame] | 25 | #else |
Frederic Weisbecker | 7863406 | 2017-10-27 04:42:28 +0200 | [diff] [blame] | 26 | |
Frederic Weisbecker | de20155 | 2017-10-27 04:42:35 +0200 | [diff] [blame] | 27 | static inline int housekeeping_any_cpu(enum hk_flags flags) |
Frederic Weisbecker | 9f0ca2d | 2017-10-27 04:42:30 +0200 | [diff] [blame] | 28 | { |
Frederic Weisbecker | 9f0ca2d | 2017-10-27 04:42:30 +0200 | [diff] [blame] | 29 | return smp_processor_id(); |
| 30 | } |
Frederic Weisbecker | 7863406 | 2017-10-27 04:42:28 +0200 | [diff] [blame] | 31 | |
Frederic Weisbecker | de20155 | 2017-10-27 04:42:35 +0200 | [diff] [blame] | 32 | static inline const struct cpumask *housekeeping_cpumask(enum hk_flags flags) |
Frederic Weisbecker | 7863406 | 2017-10-27 04:42:28 +0200 | [diff] [blame] | 33 | { |
Frederic Weisbecker | 7863406 | 2017-10-27 04:42:28 +0200 | [diff] [blame] | 34 | return cpu_possible_mask; |
| 35 | } |
| 36 | |
Frederic Weisbecker | de20155 | 2017-10-27 04:42:35 +0200 | [diff] [blame] | 37 | static inline void housekeeping_affine(struct task_struct *t, |
| 38 | enum hk_flags flags) { } |
Frederic Weisbecker | 7e56a1c | 2017-10-27 04:42:31 +0200 | [diff] [blame] | 39 | static inline void housekeeping_init(void) { } |
Frederic Weisbecker | 5c4991e | 2017-10-27 04:42:34 +0200 | [diff] [blame] | 40 | #endif /* CONFIG_CPU_ISOLATION */ |
Frederic Weisbecker | 7e56a1c | 2017-10-27 04:42:31 +0200 | [diff] [blame] | 41 | |
Frederic Weisbecker | de20155 | 2017-10-27 04:42:35 +0200 | [diff] [blame] | 42 | static inline bool housekeeping_cpu(int cpu, enum hk_flags flags) |
Frederic Weisbecker | 7863406 | 2017-10-27 04:42:28 +0200 | [diff] [blame] | 43 | { |
Frederic Weisbecker | 5c4991e | 2017-10-27 04:42:34 +0200 | [diff] [blame] | 44 | #ifdef CONFIG_CPU_ISOLATION |
Frederic Weisbecker | e179f5a | 2017-10-27 04:42:32 +0200 | [diff] [blame] | 45 | if (static_branch_unlikely(&housekeeping_overriden)) |
Frederic Weisbecker | de20155 | 2017-10-27 04:42:35 +0200 | [diff] [blame] | 46 | return housekeeping_test_cpu(cpu, flags); |
Frederic Weisbecker | 7863406 | 2017-10-27 04:42:28 +0200 | [diff] [blame] | 47 | #endif |
| 48 | return true; |
| 49 | } |
| 50 | |
Frederic Weisbecker | 7863406 | 2017-10-27 04:42:28 +0200 | [diff] [blame] | 51 | #endif /* _LINUX_SCHED_ISOLATION_H */ |