Skip to content

Commit

Permalink
x86/intel_rdt: Add diagnostics when making directories
Browse files Browse the repository at this point in the history
Mostly this is about running out of RMIDs or CLOSIDs. Other
errors are various internal errors.

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/027cf1ffb3a3695f2d54525813a1d644887353cf.1506382469.git.tony.luck@intel.com
  • Loading branch information
aegl authored and KAGA-KOKO committed Sep 27, 2017
1 parent 94457b3 commit cfd0f34
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -1593,15 +1593,18 @@ static int mkdir_rdt_prepare(struct kernfs_node *parent_kn,
int ret;

prdtgrp = rdtgroup_kn_lock_live(prgrp_kn);
rdt_last_cmd_clear();
if (!prdtgrp) {
ret = -ENODEV;
rdt_last_cmd_puts("directory was removed\n");
goto out_unlock;
}

/* allocate the rdtgroup. */
rdtgrp = kzalloc(sizeof(*rdtgrp), GFP_KERNEL);
if (!rdtgrp) {
ret = -ENOSPC;
rdt_last_cmd_puts("kernel out of memory\n");
goto out_unlock;
}
*r = rdtgrp;
Expand All @@ -1613,6 +1616,7 @@ static int mkdir_rdt_prepare(struct kernfs_node *parent_kn,
kn = kernfs_create_dir(parent_kn, name, mode, rdtgrp);
if (IS_ERR(kn)) {
ret = PTR_ERR(kn);
rdt_last_cmd_puts("kernfs create error\n");
goto out_free_rgrp;
}
rdtgrp->kn = kn;
Expand All @@ -1626,24 +1630,32 @@ static int mkdir_rdt_prepare(struct kernfs_node *parent_kn,
kernfs_get(kn);

ret = rdtgroup_kn_set_ugid(kn);
if (ret)
if (ret) {
rdt_last_cmd_puts("kernfs perm error\n");
goto out_destroy;
}

files = RFTYPE_BASE | RFTYPE_CTRL;
files = RFTYPE_BASE | BIT(RF_CTRLSHIFT + rtype);
ret = rdtgroup_add_files(kn, files);
if (ret)
if (ret) {
rdt_last_cmd_puts("kernfs fill error\n");
goto out_destroy;
}

if (rdt_mon_capable) {
ret = alloc_rmid();
if (ret < 0)
if (ret < 0) {
rdt_last_cmd_puts("out of RMIDs\n");
goto out_destroy;
}
rdtgrp->mon.rmid = ret;

ret = mkdir_mondata_all(kn, rdtgrp, &rdtgrp->mon.mon_data_kn);
if (ret)
if (ret) {
rdt_last_cmd_puts("kernfs subdir error\n");
goto out_idfree;
}
}
kernfs_activate(kn);

Expand Down Expand Up @@ -1721,8 +1733,10 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node *parent_kn,

kn = rdtgrp->kn;
ret = closid_alloc();
if (ret < 0)
if (ret < 0) {
rdt_last_cmd_puts("out of CLOSIDs\n");
goto out_common_fail;
}
closid = ret;

rdtgrp->closid = closid;
Expand All @@ -1734,8 +1748,10 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node *parent_kn,
* of tasks and cpus to monitor.
*/
ret = mongroup_create_dir(kn, NULL, "mon_groups", NULL);
if (ret)
if (ret) {
rdt_last_cmd_puts("kernfs subdir error\n");
goto out_id_free;
}
}

goto out_unlock;
Expand Down

0 comments on commit cfd0f34

Please sign in to comment.