Skip to content

Commit 472ef09

Browse files
rchatreKAGA-KOKO
authored andcommitted
x86/intel_rdt: Associate mode with each RDT resource group
Each RDT resource group is associated with a mode that will reflect the level of sharing of its allocations. The default, shareable, will be associated with each resource group on creation since it is zero and resource groups are created with kzalloc. The managing of the mode of a resource group will follow. The default resource group always remain though so ensure that it is reset to the default mode when the resctrl filesystem is unmounted. Also introduce a utility that can be used to determine the mode of a resource group when it is searched for based on its class of service. 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/797e4e1de4e4fcdf5b5e0039354d6a28079e2015.1529706536.git.reinette.chatre@intel.com
1 parent eb956a6 commit 472ef09

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

arch/x86/kernel/cpu/intel_rdt.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ struct mongroup {
122122
* @type: indicates type of this rdtgroup - either
123123
* monitor only or ctrl_mon group
124124
* @mon: mongroup related data
125+
* @mode: mode of resource group
125126
*/
126127
struct rdtgroup {
127128
struct kernfs_node *kn;
@@ -132,6 +133,7 @@ struct rdtgroup {
132133
atomic_t waitcount;
133134
enum rdt_group_type type;
134135
struct mongroup mon;
136+
enum rdtgrp_mode mode;
135137
};
136138

137139
/* rdtgroup.flags */
@@ -461,6 +463,7 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
461463
char *buf, size_t nbytes, loff_t off);
462464
int rdtgroup_schemata_show(struct kernfs_open_file *of,
463465
struct seq_file *s, void *v);
466+
enum rdtgrp_mode rdtgroup_mode_by_closid(int closid);
464467
struct rdt_domain *get_domain_from_cpu(int cpu, struct rdt_resource *r);
465468
int alloc_rmid(void);
466469
void free_rmid(u32 rmid);

arch/x86/kernel/cpu/intel_rdt_rdtgroup.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,27 @@ static void closid_free(int closid)
126126
closid_free_map |= 1 << closid;
127127
}
128128

129+
/**
130+
* rdtgroup_mode_by_closid - Return mode of resource group with closid
131+
* @closid: closid if the resource group
132+
*
133+
* Each resource group is associated with a @closid. Here the mode
134+
* of a resource group can be queried by searching for it using its closid.
135+
*
136+
* Return: mode as &enum rdtgrp_mode of resource group with closid @closid
137+
*/
138+
enum rdtgrp_mode rdtgroup_mode_by_closid(int closid)
139+
{
140+
struct rdtgroup *rdtgrp;
141+
142+
list_for_each_entry(rdtgrp, &rdt_all_groups, rdtgroup_list) {
143+
if (rdtgrp->closid == closid)
144+
return rdtgrp->mode;
145+
}
146+
147+
return RDT_NUM_MODES;
148+
}
149+
129150
/* set uid and gid of rdtgroup dirs and files to that of the creator */
130151
static int rdtgroup_kn_set_ugid(struct kernfs_node *kn)
131152
{
@@ -1491,6 +1512,7 @@ static void rdt_kill_sb(struct super_block *sb)
14911512
reset_all_ctrls(r);
14921513
cdp_disable_all();
14931514
rmdir_all_sub();
1515+
rdtgroup_default.mode = RDT_MODE_SHAREABLE;
14941516
static_branch_disable_cpuslocked(&rdt_alloc_enable_key);
14951517
static_branch_disable_cpuslocked(&rdt_mon_enable_key);
14961518
static_branch_disable_cpuslocked(&rdt_enable_key);

0 commit comments

Comments
 (0)