Skip to content

Commit a2584e1

Browse files
committed
x86/intel_rdt: Prevent deadlock against hotplug lock
The cpu online/offline callbacks of intel_rdt lock rdtgroup_mutex nested inside of cpu hotplug lock. rdtgroup_cpus_write() does it in reverse order. Remove the get/put_online_cpus() calls from rdtgroup_cpus_write(). This is safe against cpu hotplug as the resource group cpumasks are protected by rdtgroup_mutex. Found by review, but should have been found if authors would have bothered to test cpu hotplug with lockdep enabled. Signed-off-by: Thomas Gleixner <[email protected]> Cc: Shaohua Li <[email protected]> Cc: Fenghua Yu <[email protected]> Cc: Tony Luck <[email protected]>
1 parent f57b308 commit a2584e1

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

arch/x86/kernel/cpu/intel_rdt_rdtgroup.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ static ssize_t rdtgroup_cpus_write(struct kernfs_open_file *of,
207207
free_cpumask_var(tmpmask);
208208
return -ENOMEM;
209209
}
210+
210211
rdtgrp = rdtgroup_kn_lock_live(of->kn);
211212
if (!rdtgrp) {
212213
ret = -ENOENT;
@@ -217,12 +218,11 @@ static ssize_t rdtgroup_cpus_write(struct kernfs_open_file *of,
217218
if (ret)
218219
goto unlock;
219220

220-
get_online_cpus();
221221
/* check that user didn't specify any offline cpus */
222222
cpumask_andnot(tmpmask, newmask, cpu_online_mask);
223223
if (cpumask_weight(tmpmask)) {
224224
ret = -EINVAL;
225-
goto end;
225+
goto unlock;
226226
}
227227

228228
/* Check whether cpus are dropped from this group */
@@ -231,7 +231,7 @@ static ssize_t rdtgroup_cpus_write(struct kernfs_open_file *of,
231231
/* Can't drop from default group */
232232
if (rdtgrp == &rdtgroup_default) {
233233
ret = -EINVAL;
234-
goto end;
234+
goto unlock;
235235
}
236236
/* Give any dropped cpus to rdtgroup_default */
237237
cpumask_or(&rdtgroup_default.cpu_mask,
@@ -258,8 +258,6 @@ static ssize_t rdtgroup_cpus_write(struct kernfs_open_file *of,
258258
/* Done pushing/pulling - update this group with new mask */
259259
cpumask_copy(&rdtgrp->cpu_mask, newmask);
260260

261-
end:
262-
put_online_cpus();
263261
unlock:
264262
rdtgroup_kn_unlock(of->kn);
265263
free_cpumask_var(tmpmask);

0 commit comments

Comments
 (0)