Skip to content

Commit 0158ed6

Browse files
aeglbp3tk0v
authored andcommitted
x86/resctrl: Create Sub-NUMA Cluster (SNC) monitor files
When SNC mode is enabled, create subdirectories and files to monitor at the SNC node granularity. Legacy behavior is preserved by tagging the monitor files at the L3 granularity with the "sum" attribute. When the user reads these files the kernel will read monitor data from all SNC nodes that share the same L3 cache instance and return the aggregated value to the user. Note that the "domid" field for files that must sum across SNC domains has the L3 cache instance id, while non-summing files use the domain id. The "sum" files do not need to make a call to mon_event_read() to initialize the MBM counters. This will be handled by initializing the individual SNC nodes that share the L3. Signed-off-by: Tony Luck <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Reinette Chatre <[email protected]> Tested-by: Babu Moger <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 92b5d0b commit 0158ed6

File tree

1 file changed

+46
-16
lines changed

1 file changed

+46
-16
lines changed

arch/x86/kernel/cpu/resctrl/rdtgroup.c

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3026,7 +3026,8 @@ static void rmdir_mondata_subdir_allrdtgrp(struct rdt_resource *r,
30263026
}
30273027

30283028
static int mon_add_all_files(struct kernfs_node *kn, struct rdt_mon_domain *d,
3029-
struct rdt_resource *r, struct rdtgroup *prgrp)
3029+
struct rdt_resource *r, struct rdtgroup *prgrp,
3030+
bool do_sum)
30303031
{
30313032
struct rmid_read rr = {0};
30323033
union mon_data_bits priv;
@@ -3037,14 +3038,15 @@ static int mon_add_all_files(struct kernfs_node *kn, struct rdt_mon_domain *d,
30373038
return -EPERM;
30383039

30393040
priv.u.rid = r->rid;
3040-
priv.u.domid = d->hdr.id;
3041+
priv.u.domid = do_sum ? d->ci->id : d->hdr.id;
3042+
priv.u.sum = do_sum;
30413043
list_for_each_entry(mevt, &r->evt_list, list) {
30423044
priv.u.evtid = mevt->evtid;
30433045
ret = mon_addfile(kn, mevt->name, priv.priv);
30443046
if (ret)
30453047
return ret;
30463048

3047-
if (is_mbm_event(mevt->evtid))
3049+
if (!do_sum && is_mbm_event(mevt->evtid))
30483050
mon_event_read(&rr, r, d, prgrp, mevt->evtid, true);
30493051
}
30503052

@@ -3055,23 +3057,51 @@ static int mkdir_mondata_subdir(struct kernfs_node *parent_kn,
30553057
struct rdt_mon_domain *d,
30563058
struct rdt_resource *r, struct rdtgroup *prgrp)
30573059
{
3058-
struct kernfs_node *kn;
3060+
struct kernfs_node *kn, *ckn;
30593061
char name[32];
3060-
int ret;
3062+
bool snc_mode;
3063+
int ret = 0;
30613064

3062-
sprintf(name, "mon_%s_%02d", r->name, d->hdr.id);
3063-
/* create the directory */
3064-
kn = kernfs_create_dir(parent_kn, name, parent_kn->mode, prgrp);
3065-
if (IS_ERR(kn))
3066-
return PTR_ERR(kn);
3065+
lockdep_assert_held(&rdtgroup_mutex);
30673066

3068-
ret = rdtgroup_kn_set_ugid(kn);
3069-
if (ret)
3070-
goto out_destroy;
3067+
snc_mode = r->mon_scope == RESCTRL_L3_NODE;
3068+
sprintf(name, "mon_%s_%02d", r->name, snc_mode ? d->ci->id : d->hdr.id);
3069+
kn = kernfs_find_and_get(parent_kn, name);
3070+
if (kn) {
3071+
/*
3072+
* rdtgroup_mutex will prevent this directory from being
3073+
* removed. No need to keep this hold.
3074+
*/
3075+
kernfs_put(kn);
3076+
} else {
3077+
kn = kernfs_create_dir(parent_kn, name, parent_kn->mode, prgrp);
3078+
if (IS_ERR(kn))
3079+
return PTR_ERR(kn);
30713080

3072-
ret = mon_add_all_files(kn, d, r, prgrp);
3073-
if (ret)
3074-
goto out_destroy;
3081+
ret = rdtgroup_kn_set_ugid(kn);
3082+
if (ret)
3083+
goto out_destroy;
3084+
ret = mon_add_all_files(kn, d, r, prgrp, snc_mode);
3085+
if (ret)
3086+
goto out_destroy;
3087+
}
3088+
3089+
if (snc_mode) {
3090+
sprintf(name, "mon_sub_%s_%02d", r->name, d->hdr.id);
3091+
ckn = kernfs_create_dir(kn, name, parent_kn->mode, prgrp);
3092+
if (IS_ERR(ckn)) {
3093+
ret = -EINVAL;
3094+
goto out_destroy;
3095+
}
3096+
3097+
ret = rdtgroup_kn_set_ugid(ckn);
3098+
if (ret)
3099+
goto out_destroy;
3100+
3101+
ret = mon_add_all_files(ckn, d, r, prgrp, false);
3102+
if (ret)
3103+
goto out_destroy;
3104+
}
30753105

30763106
kernfs_activate(kn);
30773107
return 0;

0 commit comments

Comments
 (0)