Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 3232e7a

Browse files
Waiman-Longhtejun
authored andcommitted
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 <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 77070ee commit 3232e7a

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

include/linux/cpuset.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ extern void cpuset_lock(void);
7777
extern void cpuset_unlock(void);
7878
extern void cpuset_cpus_allowed(struct task_struct *p, struct cpumask *mask);
7979
extern bool cpuset_cpus_allowed_fallback(struct task_struct *p);
80+
extern bool cpuset_cpu_is_isolated(int cpu);
8081
extern nodemask_t cpuset_mems_allowed(struct task_struct *p);
8182
#define cpuset_current_mems_allowed (current->mems_allowed)
8283
void cpuset_init_current_mems_allowed(void);
@@ -207,6 +208,11 @@ static inline bool cpuset_cpus_allowed_fallback(struct task_struct *p)
207208
return false;
208209
}
209210

211+
static inline bool cpuset_cpu_is_isolated(int cpu)
212+
{
213+
return false;
214+
}
215+
210216
static inline nodemask_t cpuset_mems_allowed(struct task_struct *p)
211217
{
212218
return node_possible_map;

include/linux/sched/isolation.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define _LINUX_SCHED_ISOLATION_H
33

44
#include <linux/cpumask.h>
5+
#include <linux/cpuset.h>
56
#include <linux/init.h>
67
#include <linux/tick.h>
78

@@ -67,7 +68,8 @@ static inline bool housekeeping_cpu(int cpu, enum hk_type type)
6768
static inline bool cpu_is_isolated(int cpu)
6869
{
6970
return !housekeeping_test_cpu(cpu, HK_TYPE_DOMAIN) ||
70-
!housekeeping_test_cpu(cpu, HK_TYPE_TICK);
71+
!housekeeping_test_cpu(cpu, HK_TYPE_TICK) ||
72+
cpuset_cpu_is_isolated(cpu);
7173
}
7274

7375
#endif /* _LINUX_SCHED_ISOLATION_H */

kernel/cgroup/cpuset.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,6 +1518,17 @@ static void update_unbound_workqueue_cpumask(bool isolcpus_updated)
15181518
WARN_ON_ONCE(ret < 0);
15191519
}
15201520

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+
15211532
/*
15221533
* compute_effective_exclusive_cpumask - compute effective exclusive CPUs
15231534
* @cs: cpuset

0 commit comments

Comments
 (0)