Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cgroup/cpuset: Include isolated cpuset CPUs in cpu_is_isolated() check

Currently, the cpu_is_isolated() function checks only the statically
isolated CPUs specified via the "isolcpus" and "nohz_full" kernel
command line options. This function is used by vmstat and memcg to
reduce interference with isolated CPUs by not doing stat flushing
or scheduling works on those CPUs.

Workloads running on isolated CPUs within isolated cpuset
partitions should receive the same treatment to reduce unnecessary
interference. This patch introduces a new cpuset_cpu_is_isolated()
function to be called by cpu_is_isolated() so that the set of dynamically
created cpuset isolated CPUs will be included in the check.

Assuming that testing a bit in a cpumask is atomic, no synchronization
primitive is currently used to synchronize access to the cpuset's
isolated_cpus mask.

Signed-off-by: Waiman Long <longman@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

Waiman Long and committed by
Tejun Heo
3232e7aa 77070eeb

+20 -1
+6
include/linux/cpuset.h
··· 77 77 extern void cpuset_unlock(void); 78 78 extern void cpuset_cpus_allowed(struct task_struct *p, struct cpumask *mask); 79 79 extern bool cpuset_cpus_allowed_fallback(struct task_struct *p); 80 + extern bool cpuset_cpu_is_isolated(int cpu); 80 81 extern nodemask_t cpuset_mems_allowed(struct task_struct *p); 81 82 #define cpuset_current_mems_allowed (current->mems_allowed) 82 83 void cpuset_init_current_mems_allowed(void); ··· 204 203 } 205 204 206 205 static inline bool cpuset_cpus_allowed_fallback(struct task_struct *p) 206 + { 207 + return false; 208 + } 209 + 210 + static inline bool cpuset_cpu_is_isolated(int cpu) 207 211 { 208 212 return false; 209 213 }
+3 -1
include/linux/sched/isolation.h
··· 2 2 #define _LINUX_SCHED_ISOLATION_H 3 3 4 4 #include <linux/cpumask.h> 5 + #include <linux/cpuset.h> 5 6 #include <linux/init.h> 6 7 #include <linux/tick.h> 7 8 ··· 68 67 static inline bool cpu_is_isolated(int cpu) 69 68 { 70 69 return !housekeeping_test_cpu(cpu, HK_TYPE_DOMAIN) || 71 - !housekeeping_test_cpu(cpu, HK_TYPE_TICK); 70 + !housekeeping_test_cpu(cpu, HK_TYPE_TICK) || 71 + cpuset_cpu_is_isolated(cpu); 72 72 } 73 73 74 74 #endif /* _LINUX_SCHED_ISOLATION_H */
+11
kernel/cgroup/cpuset.c
··· 1518 1518 WARN_ON_ONCE(ret < 0); 1519 1519 } 1520 1520 1521 + /** 1522 + * cpuset_cpu_is_isolated - Check if the given CPU is isolated 1523 + * @cpu: the CPU number to be checked 1524 + * Return: true if CPU is used in an isolated partition, false otherwise 1525 + */ 1526 + bool cpuset_cpu_is_isolated(int cpu) 1527 + { 1528 + return cpumask_test_cpu(cpu, isolated_cpus); 1529 + } 1530 + EXPORT_SYMBOL_GPL(cpuset_cpu_is_isolated); 1531 + 1521 1532 /* 1522 1533 * compute_effective_exclusive_cpumask - compute effective exclusive CPUs 1523 1534 * @cs: cpuset