@@ -197,10 +197,8 @@ static struct cpuset top_cpuset = {
197
197
198
198
/*
199
199
* There are two global locks guarding cpuset structures - cpuset_mutex and
200
- * callback_lock. We also require taking task_lock() when dereferencing a
201
- * task's cpuset pointer. See "The task_lock() exception", at the end of this
202
- * comment. The cpuset code uses only cpuset_mutex. Other kernel subsystems
203
- * can use cpuset_lock()/cpuset_unlock() to prevent change to cpuset
200
+ * callback_lock. The cpuset code uses only cpuset_mutex. Other kernel
201
+ * subsystems can use cpuset_lock()/cpuset_unlock() to prevent change to cpuset
204
202
* structures. Note that cpuset_mutex needs to be a mutex as it is used in
205
203
* paths that rely on priority inheritance (e.g. scheduler - on RT) for
206
204
* correctness.
@@ -229,9 +227,6 @@ static struct cpuset top_cpuset = {
229
227
* The cpuset_common_seq_show() handlers only hold callback_lock across
230
228
* small pieces of code, such as when reading out possibly multi-word
231
229
* cpumasks and nodemasks.
232
- *
233
- * Accessing a task's cpuset should be done in accordance with the
234
- * guidelines for accessing subsystem state in kernel/cgroup.c
235
230
*/
236
231
237
232
static DEFINE_MUTEX (cpuset_mutex );
@@ -890,7 +885,15 @@ static int generate_sched_domains(cpumask_var_t **domains,
890
885
*/
891
886
if (cgrpv2 ) {
892
887
for (i = 0 ; i < ndoms ; i ++ ) {
893
- cpumask_copy (doms [i ], csa [i ]-> effective_cpus );
888
+ /*
889
+ * The top cpuset may contain some boot time isolated
890
+ * CPUs that need to be excluded from the sched domain.
891
+ */
892
+ if (csa [i ] == & top_cpuset )
893
+ cpumask_and (doms [i ], csa [i ]-> effective_cpus ,
894
+ housekeeping_cpumask (HK_TYPE_DOMAIN ));
895
+ else
896
+ cpumask_copy (doms [i ], csa [i ]-> effective_cpus );
894
897
if (dattr )
895
898
dattr [i ] = SD_ATTR_INIT ;
896
899
}
@@ -3121,29 +3124,6 @@ ssize_t cpuset_write_resmask(struct kernfs_open_file *of,
3121
3124
int retval = - ENODEV ;
3122
3125
3123
3126
buf = strstrip (buf );
3124
-
3125
- /*
3126
- * CPU or memory hotunplug may leave @cs w/o any execution
3127
- * resources, in which case the hotplug code asynchronously updates
3128
- * configuration and transfers all tasks to the nearest ancestor
3129
- * which can execute.
3130
- *
3131
- * As writes to "cpus" or "mems" may restore @cs's execution
3132
- * resources, wait for the previously scheduled operations before
3133
- * proceeding, so that we don't end up keep removing tasks added
3134
- * after execution capability is restored.
3135
- *
3136
- * cpuset_handle_hotplug may call back into cgroup core asynchronously
3137
- * via cgroup_transfer_tasks() and waiting for it from a cgroupfs
3138
- * operation like this one can lead to a deadlock through kernfs
3139
- * active_ref protection. Let's break the protection. Losing the
3140
- * protection is okay as we check whether @cs is online after
3141
- * grabbing cpuset_mutex anyway. This only happens on the legacy
3142
- * hierarchies.
3143
- */
3144
- css_get (& cs -> css );
3145
- kernfs_break_active_protection (of -> kn );
3146
-
3147
3127
cpus_read_lock ();
3148
3128
mutex_lock (& cpuset_mutex );
3149
3129
if (!is_cpuset_online (cs ))
@@ -3176,8 +3156,6 @@ ssize_t cpuset_write_resmask(struct kernfs_open_file *of,
3176
3156
out_unlock :
3177
3157
mutex_unlock (& cpuset_mutex );
3178
3158
cpus_read_unlock ();
3179
- kernfs_unbreak_active_protection (of -> kn );
3180
- css_put (& cs -> css );
3181
3159
flush_workqueue (cpuset_migrate_mm_wq );
3182
3160
return retval ?: nbytes ;
3183
3161
}
0 commit comments