blob: d849431c8060a17c49ac247745ae1afd5f88f3f2 [file] [log] [blame]
Frederic Weisbecker78634062017-10-27 04:42:28 +02001#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 Weisbeckerde201552017-10-27 04:42:35 +02008enum 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 Weisbecker6f1982f2017-10-27 04:42:36 +020013 HK_FLAG_TICK = (1 << 4),
Frederic Weisbeckeredb93822017-10-27 04:42:37 +020014 HK_FLAG_DOMAIN = (1 << 5),
Frederic Weisbeckerde201552017-10-27 04:42:35 +020015};
16
Frederic Weisbecker5c4991e2017-10-27 04:42:34 +020017#ifdef CONFIG_CPU_ISOLATION
Frederic Weisbeckere179f5a2017-10-27 04:42:32 +020018DECLARE_STATIC_KEY_FALSE(housekeeping_overriden);
Frederic Weisbeckerde201552017-10-27 04:42:35 +020019extern int housekeeping_any_cpu(enum hk_flags flags);
20extern const struct cpumask *housekeeping_cpumask(enum hk_flags flags);
21extern void housekeeping_affine(struct task_struct *t, enum hk_flags flags);
22extern bool housekeeping_test_cpu(int cpu, enum hk_flags flags);
Frederic Weisbecker78634062017-10-27 04:42:28 +020023extern void __init housekeeping_init(void);
Frederic Weisbecker7e56a1c2017-10-27 04:42:31 +020024
Frederic Weisbecker78634062017-10-27 04:42:28 +020025#else
Frederic Weisbecker78634062017-10-27 04:42:28 +020026
Frederic Weisbeckerde201552017-10-27 04:42:35 +020027static inline int housekeeping_any_cpu(enum hk_flags flags)
Frederic Weisbecker9f0ca2d2017-10-27 04:42:30 +020028{
Frederic Weisbecker9f0ca2d2017-10-27 04:42:30 +020029 return smp_processor_id();
30}
Frederic Weisbecker78634062017-10-27 04:42:28 +020031
Frederic Weisbeckerde201552017-10-27 04:42:35 +020032static inline const struct cpumask *housekeeping_cpumask(enum hk_flags flags)
Frederic Weisbecker78634062017-10-27 04:42:28 +020033{
Frederic Weisbecker78634062017-10-27 04:42:28 +020034 return cpu_possible_mask;
35}
36
Frederic Weisbeckerde201552017-10-27 04:42:35 +020037static inline void housekeeping_affine(struct task_struct *t,
38 enum hk_flags flags) { }
Frederic Weisbecker7e56a1c2017-10-27 04:42:31 +020039static inline void housekeeping_init(void) { }
Frederic Weisbecker5c4991e2017-10-27 04:42:34 +020040#endif /* CONFIG_CPU_ISOLATION */
Frederic Weisbecker7e56a1c2017-10-27 04:42:31 +020041
Frederic Weisbeckerde201552017-10-27 04:42:35 +020042static inline bool housekeeping_cpu(int cpu, enum hk_flags flags)
Frederic Weisbecker78634062017-10-27 04:42:28 +020043{
Frederic Weisbecker5c4991e2017-10-27 04:42:34 +020044#ifdef CONFIG_CPU_ISOLATION
Frederic Weisbeckere179f5a2017-10-27 04:42:32 +020045 if (static_branch_unlikely(&housekeeping_overriden))
Frederic Weisbeckerde201552017-10-27 04:42:35 +020046 return housekeeping_test_cpu(cpu, flags);
Frederic Weisbecker78634062017-10-27 04:42:28 +020047#endif
48 return true;
49}
50
Frederic Weisbecker78634062017-10-27 04:42:28 +020051#endif /* _LINUX_SCHED_ISOLATION_H */