Skip to content

Commit 603cf1e

Browse files
aeglbp3tk0v
authored andcommitted
x86/resctrl: Refactor mkdir_mondata_subdir() with a helper function
In Sub-NUMA Cluster (SNC) mode Linux must create the monitor files in the original "mon_L3_XX" directories and also in each of the "mon_sub_L3_YY" directories. Refactor mkdir_mondata_subdir() to move the creation of monitoring files into a helper function to avoid the need to duplicate code later. No functional change. 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 587edd7 commit 603cf1e

File tree

1 file changed

+28
-17
lines changed

1 file changed

+28
-17
lines changed

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

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3025,14 +3025,37 @@ static void rmdir_mondata_subdir_allrdtgrp(struct rdt_resource *r,
30253025
}
30263026
}
30273027

3028+
static int mon_add_all_files(struct kernfs_node *kn, struct rdt_mon_domain *d,
3029+
struct rdt_resource *r, struct rdtgroup *prgrp)
3030+
{
3031+
struct rmid_read rr = {0};
3032+
union mon_data_bits priv;
3033+
struct mon_evt *mevt;
3034+
int ret;
3035+
3036+
if (WARN_ON(list_empty(&r->evt_list)))
3037+
return -EPERM;
3038+
3039+
priv.u.rid = r->rid;
3040+
priv.u.domid = d->hdr.id;
3041+
list_for_each_entry(mevt, &r->evt_list, list) {
3042+
priv.u.evtid = mevt->evtid;
3043+
ret = mon_addfile(kn, mevt->name, priv.priv);
3044+
if (ret)
3045+
return ret;
3046+
3047+
if (is_mbm_event(mevt->evtid))
3048+
mon_event_read(&rr, r, d, prgrp, mevt->evtid, true);
3049+
}
3050+
3051+
return 0;
3052+
}
3053+
30283054
static int mkdir_mondata_subdir(struct kernfs_node *parent_kn,
30293055
struct rdt_mon_domain *d,
30303056
struct rdt_resource *r, struct rdtgroup *prgrp)
30313057
{
3032-
struct rmid_read rr = {0};
3033-
union mon_data_bits priv;
30343058
struct kernfs_node *kn;
3035-
struct mon_evt *mevt;
30363059
char name[32];
30373060
int ret;
30383061

@@ -3046,22 +3069,10 @@ static int mkdir_mondata_subdir(struct kernfs_node *parent_kn,
30463069
if (ret)
30473070
goto out_destroy;
30483071

3049-
if (WARN_ON(list_empty(&r->evt_list))) {
3050-
ret = -EPERM;
3072+
ret = mon_add_all_files(kn, d, r, prgrp);
3073+
if (ret)
30513074
goto out_destroy;
3052-
}
30533075

3054-
priv.u.rid = r->rid;
3055-
priv.u.domid = d->hdr.id;
3056-
list_for_each_entry(mevt, &r->evt_list, list) {
3057-
priv.u.evtid = mevt->evtid;
3058-
ret = mon_addfile(kn, mevt->name, priv.priv);
3059-
if (ret)
3060-
goto out_destroy;
3061-
3062-
if (is_mbm_event(mevt->evtid))
3063-
mon_event_read(&rr, r, d, prgrp, mevt->evtid, true);
3064-
}
30653076
kernfs_activate(kn);
30663077
return 0;
30673078

0 commit comments

Comments
 (0)