Skip to content

Commit e0bdfe8

Browse files
rchatreKAGA-KOKO
authored andcommitted
x86/intel_rdt: Support creation/removal of pseudo-locked region
The user triggers the creation of a pseudo-locked region when writing a valid schemata to the schemata file of a resource group in the pseudo-locksetup mode. A valid schemata is one that: (1) does not overlap with any other resource group, (2) does not involve a cache that already contains a pseudo-locked region within its hierarchy. After a valid schemata is parsed the system is programmed to associate the to be pseudo-lock bitmask with the closid associated with the resource group. With the system set up the pseudo-locked region can be created. Signed-off-by: Reinette Chatre <reinette.chatre@intel.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: fenghua.yu@intel.com Cc: tony.luck@intel.com Cc: vikas.shivappa@linux.intel.com Cc: gavin.hindman@intel.com Cc: jithu.joseph@intel.com Cc: dave.hansen@intel.com Cc: hpa@zytor.com Link: https://lkml.kernel.org/r/8929c3a9e2ba600e79649abe584aa28b8d0ff639.1529706536.git.reinette.chatre@intel.com
1 parent 018961a commit e0bdfe8

File tree

2 files changed

+62
-5
lines changed

2 files changed

+62
-5
lines changed

arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,26 @@ int parse_cbm(void *_data, struct rdt_resource *r, struct rdt_domain *d)
143143
return -EINVAL;
144144
}
145145

146+
/*
147+
* Cannot set up more than one pseudo-locked region in a cache
148+
* hierarchy.
149+
*/
150+
if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP &&
151+
rdtgroup_pseudo_locked_in_hierarchy(d)) {
152+
rdt_last_cmd_printf("pseudo-locked region in hierarchy\n");
153+
return -EINVAL;
154+
}
155+
146156
if (!cbm_validate(data->buf, &cbm_val, r))
147157
return -EINVAL;
148158

159+
if ((rdtgrp->mode == RDT_MODE_EXCLUSIVE ||
160+
rdtgrp->mode == RDT_MODE_SHAREABLE) &&
161+
rdtgroup_cbm_overlaps_pseudo_locked(d, cbm_val)) {
162+
rdt_last_cmd_printf("CBM overlaps with pseudo-locked region\n");
163+
return -EINVAL;
164+
}
165+
149166
/*
150167
* The CBM may not overlap with the CBM of another closid if
151168
* either is exclusive.
@@ -199,6 +216,21 @@ static int parse_line(char *line, struct rdt_resource *r,
199216
data.rdtgrp = rdtgrp;
200217
if (r->parse_ctrlval(&data, r, d))
201218
return -EINVAL;
219+
if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) {
220+
/*
221+
* In pseudo-locking setup mode and just
222+
* parsed a valid CBM that should be
223+
* pseudo-locked. Only one locked region per
224+
* resource group and domain so just do
225+
* the required initialization for single
226+
* region and return.
227+
*/
228+
rdtgrp->plr->r = r;
229+
rdtgrp->plr->d = d;
230+
rdtgrp->plr->cbm = d->new_ctrl;
231+
d->plr = rdtgrp->plr;
232+
return 0;
233+
}
202234
goto next;
203235
}
204236
}
@@ -322,6 +354,16 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
322354
goto out;
323355
}
324356

357+
if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) {
358+
/*
359+
* If pseudo-locking fails we keep the resource group in
360+
* mode RDT_MODE_PSEUDO_LOCKSETUP with its class of service
361+
* active and updated for just the domain the pseudo-locked
362+
* region was requested for.
363+
*/
364+
ret = rdtgroup_pseudo_lock_create(rdtgrp);
365+
}
366+
325367
out:
326368
rdtgroup_kn_unlock(of->kn);
327369
return ret ?: nbytes;

arch/x86/kernel/cpu/intel_rdt_rdtgroup.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,6 +1771,9 @@ void rdtgroup_kn_unlock(struct kernfs_node *kn)
17711771

17721772
if (atomic_dec_and_test(&rdtgrp->waitcount) &&
17731773
(rdtgrp->flags & RDT_DELETED)) {
1774+
if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP ||
1775+
rdtgrp->mode == RDT_MODE_PSEUDO_LOCKED)
1776+
rdtgroup_pseudo_lock_remove(rdtgrp);
17741777
kernfs_unbreak_active_protection(kn);
17751778
kernfs_put(rdtgrp->kn);
17761779
kfree(rdtgrp);
@@ -2002,6 +2005,10 @@ static void rmdir_all_sub(void)
20022005
if (rdtgrp == &rdtgroup_default)
20032006
continue;
20042007

2008+
if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP ||
2009+
rdtgrp->mode == RDT_MODE_PSEUDO_LOCKED)
2010+
rdtgroup_pseudo_lock_remove(rdtgrp);
2011+
20052012
/*
20062013
* Give any CPUs back to the default group. We cannot copy
20072014
* cpu_online_mask because a CPU might have executed the
@@ -2313,6 +2320,8 @@ static int rdtgroup_init_alloc(struct rdtgroup *rdtgrp)
23132320
d->new_ctrl |= *ctrl;
23142321
}
23152322
}
2323+
if (d->plr && d->plr->cbm > 0)
2324+
used_b |= d->plr->cbm;
23162325
unused_b = used_b ^ (BIT_MASK(r->cache.cbm_len) - 1);
23172326
unused_b &= BIT_MASK(r->cache.cbm_len) - 1;
23182327
d->new_ctrl |= unused_b;
@@ -2696,13 +2705,19 @@ static int rdtgroup_rmdir(struct kernfs_node *kn)
26962705
* If the rdtgroup is a mon group and parent directory
26972706
* is a valid "mon_groups" directory, remove the mon group.
26982707
*/
2699-
if (rdtgrp->type == RDTCTRL_GROUP && parent_kn == rdtgroup_default.kn)
2700-
ret = rdtgroup_rmdir_ctrl(kn, rdtgrp, tmpmask);
2701-
else if (rdtgrp->type == RDTMON_GROUP &&
2702-
is_mon_groups(parent_kn, kn->name))
2708+
if (rdtgrp->type == RDTCTRL_GROUP && parent_kn == rdtgroup_default.kn) {
2709+
if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP ||
2710+
rdtgrp->mode == RDT_MODE_PSEUDO_LOCKED) {
2711+
ret = rdtgroup_ctrl_remove(kn, rdtgrp);
2712+
} else {
2713+
ret = rdtgroup_rmdir_ctrl(kn, rdtgrp, tmpmask);
2714+
}
2715+
} else if (rdtgrp->type == RDTMON_GROUP &&
2716+
is_mon_groups(parent_kn, kn->name)) {
27032717
ret = rdtgroup_rmdir_mon(kn, rdtgrp, tmpmask);
2704-
else
2718+
} else {
27052719
ret = -EPERM;
2720+
}
27062721

27072722
out:
27082723
rdtgroup_kn_unlock(kn);

0 commit comments

Comments
 (0)