Skip to content

Commit cdea7c1

Browse files
committed
Merge: cgroup/cpuset: Improve CPU isolation in isolated partitions
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/3611 JIRA: https://issues.redhat.com/browse/RHEL-21798 MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/3611 At present, cpuset isolated partition only disables load balancing for the isolated CPUs within the partition. There are still other sources of OS noises present that may adversely break the target latency limit. One of those noises is the possibility that an isolated CPU may be used by an unbound workqueue to process workqueue items. Specifying the isolcpus (with default domain flag) boot command line will prevent unbound workqueues to use those isolated CPUs for processing. That is not currently the case for isolated cpuset partitions. To make cpuset isolated partition as close to the isolcpus boot option as possible, we need to remove those isolated CPUs from being used by an unbound workqueue. This MR backports the upstream workqueue and cpuset patches to make isolated cpuset partitions more close to isolcpus boot command line option in functionality. In addition, the isolated cpuset CPUs are now also enabled in the cpu_is_isolated() helper which is used by vmstat and memcg to reduce interference with isolated CPUs by not doing stat flushing or scheduling works on those CPUs. Signed-off-by: Waiman Long <longman@redhat.com> Approved-by: Phil Auld <pauld@redhat.com> Approved-by: John B. Wyatt IV <jwyatt@redhat.com> Merged-by: Scott Weaver <scweaver@redhat.com>
2 parents 79ef2f7 + 4cd29b5 commit cdea7c1

File tree

8 files changed

+550
-213
lines changed

8 files changed

+550
-213
lines changed

Documentation/admin-guide/cgroup-v2.rst

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2258,6 +2258,13 @@ Cpuset Interface Files
22582258
treated to have an implicit value of "cpuset.cpus" in the
22592259
formation of local partition.
22602260

2261+
cpuset.cpus.isolated
2262+
A read-only and root cgroup only multiple values file.
2263+
2264+
This file shows the set of all isolated CPUs used in existing
2265+
isolated partitions. It will be empty if no isolated partition
2266+
is created.
2267+
22612268
cpuset.cpus.partition
22622269
A read-write single value file which exists on non-root
22632270
cpuset-enabled cgroups. This flag is owned by the parent cgroup
@@ -2300,11 +2307,11 @@ Cpuset Interface Files
23002307
partition or scheduling domain. The set of exclusive CPUs is
23012308
determined by the value of its "cpuset.cpus.exclusive.effective".
23022309

2303-
When set to "isolated", the CPUs in that partition will
2304-
be in an isolated state without any load balancing from the
2305-
scheduler. Tasks placed in such a partition with multiple
2306-
CPUs should be carefully distributed and bound to each of the
2307-
individual CPUs for optimal performance.
2310+
When set to "isolated", the CPUs in that partition will be in
2311+
an isolated state without any load balancing from the scheduler
2312+
and excluded from the unbound workqueues. Tasks placed in such
2313+
a partition with multiple CPUs should be carefully distributed
2314+
and bound to each of the individual CPUs for optimal performance.
23082315

23092316
A partition root ("root" or "isolated") can be in one of the
23102317
two possible states - valid or invalid. An invalid partition

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6822,6 +6822,13 @@
68226822
disables both lockup detectors. Default is 10
68236823
seconds.
68246824

6825+
workqueue.unbound_cpus=
6826+
[KNL,SMP] Specify to constrain one or some CPUs
6827+
to use in unbound workqueues.
6828+
Format: <cpu-list>
6829+
By default, all online CPUs are available for
6830+
unbound workqueues.
6831+
68256832
workqueue.watchdog_thresh=
68266833
If CONFIG_WQ_WATCHDOG is configured, workqueue can
68276834
warn stall conditions and dump internal state to

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 */

include/linux/workqueue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ struct workqueue_attrs *alloc_workqueue_attrs(void);
434434
void free_workqueue_attrs(struct workqueue_attrs *attrs);
435435
int apply_workqueue_attrs(struct workqueue_struct *wq,
436436
const struct workqueue_attrs *attrs);
437-
int workqueue_set_unbound_cpumask(cpumask_var_t cpumask);
437+
extern int workqueue_unbound_exclude_cpumask(cpumask_var_t cpumask);
438438

439439
extern bool queue_work_on(int cpu, struct workqueue_struct *wq,
440440
struct work_struct *work);

0 commit comments

Comments
 (0)