Skip to content

Commit 94457b3

Browse files
aeglKAGA-KOKO
authored andcommitted
x86/intel_rdt: Add diagnostics when writing the cpus file
Can't add a cpu to a monitor group unless it belongs to parent group. Can't delete cpus from the default group. Signed-off-by: Tony Luck <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: Fenghua Yu <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: Vikas Shivappa <[email protected]> Cc: Boris Petkov <[email protected]> Cc: Reinette Chatre <[email protected]> Link: https://lkml.kernel.org/r/757a869a25e9fc1b7a2e9bc43e1159455c1964a0.1506382469.git.tony.luck@intel.com
1 parent 29e74f3 commit 94457b3

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

arch/x86/kernel/cpu/intel_rdt_rdtgroup.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,10 @@ static int cpus_mon_write(struct rdtgroup *rdtgrp, cpumask_var_t newmask,
264264

265265
/* Check whether cpus belong to parent ctrl group */
266266
cpumask_andnot(tmpmask, newmask, &prgrp->cpu_mask);
267-
if (cpumask_weight(tmpmask))
267+
if (cpumask_weight(tmpmask)) {
268+
rdt_last_cmd_puts("can only add CPUs to mongroup that belong to parent\n");
268269
return -EINVAL;
270+
}
269271

270272
/* Check whether cpus are dropped from this group */
271273
cpumask_andnot(tmpmask, &rdtgrp->cpu_mask, newmask);
@@ -317,8 +319,10 @@ static int cpus_ctrl_write(struct rdtgroup *rdtgrp, cpumask_var_t newmask,
317319
cpumask_andnot(tmpmask, &rdtgrp->cpu_mask, newmask);
318320
if (cpumask_weight(tmpmask)) {
319321
/* Can't drop from default group */
320-
if (rdtgrp == &rdtgroup_default)
322+
if (rdtgrp == &rdtgroup_default) {
323+
rdt_last_cmd_puts("Can't drop CPUs from default group\n");
321324
return -EINVAL;
325+
}
322326

323327
/* Give any dropped cpus to rdtgroup_default */
324328
cpumask_or(&rdtgroup_default.cpu_mask,
@@ -383,8 +387,10 @@ static ssize_t rdtgroup_cpus_write(struct kernfs_open_file *of,
383387
}
384388

385389
rdtgrp = rdtgroup_kn_lock_live(of->kn);
390+
rdt_last_cmd_clear();
386391
if (!rdtgrp) {
387392
ret = -ENOENT;
393+
rdt_last_cmd_puts("directory was removed\n");
388394
goto unlock;
389395
}
390396

@@ -393,13 +399,16 @@ static ssize_t rdtgroup_cpus_write(struct kernfs_open_file *of,
393399
else
394400
ret = cpumask_parse(buf, newmask);
395401

396-
if (ret)
402+
if (ret) {
403+
rdt_last_cmd_puts("bad cpu list/mask\n");
397404
goto unlock;
405+
}
398406

399407
/* check that user didn't specify any offline cpus */
400408
cpumask_andnot(tmpmask, newmask, cpu_online_mask);
401409
if (cpumask_weight(tmpmask)) {
402410
ret = -EINVAL;
411+
rdt_last_cmd_puts("can only assign online cpus\n");
403412
goto unlock;
404413
}
405414

0 commit comments

Comments
 (0)