lkml.org 
[lkml]   [2022]   [Sep]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH v4 09/13] x86/resctrl: Add sysfs interface files to read/write event configuration
From
Date
Add two new sysfs files to read/write the event configuration if
the feature Bandwidth Monitoring Event Configuration (BMEC) is
supported. The file mbm_local_config is for the configuration
of the event mbm_local_bytes and the file mbm_total_config is
for the configuration of mbm_total_bytes.

$ls /sys/fs/resctrl/mon_data/mon_L3_00/mbm_local*
/sys/fs/resctrl/mon_data/mon_L3_00/mbm_local_bytes
/sys/fs/resctrl/mon_data/mon_L3_00/mbm_local_config

$ls /sys/fs/resctrl/mon_data/mon_L3_00/mbm_total*
/sys/fs/resctrl/mon_data/mon_L3_00/mbm_total_bytes
/sys/fs/resctrl/mon_data/mon_L3_00/mbm_total_config

Signed-off-by: Babu Moger <babu.moger@amd.com>
---
arch/x86/kernel/cpu/resctrl/rdtgroup.c | 40 ++++++++++++++++++++++++--------
1 file changed, 30 insertions(+), 10 deletions(-)

diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index f55a693fa958..da11fdad204d 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -254,6 +254,10 @@ static const struct kernfs_ops kf_mondata_ops = {
.seq_show = rdtgroup_mondata_show,
};

+static const struct kernfs_ops kf_mondata_config_ops = {
+ .atomic_write_len = PAGE_SIZE,
+};
+
static bool is_cpu_list(struct kernfs_open_file *of)
{
struct rftype *rft = of->kn->priv;
@@ -2478,24 +2482,40 @@ static struct file_system_type rdt_fs_type = {
.kill_sb = rdt_kill_sb,
};

-static int mon_addfile(struct kernfs_node *parent_kn, const char *name,
+static int mon_addfile(struct kernfs_node *parent_kn, struct mon_evt *mevt,
void *priv)
{
- struct kernfs_node *kn;
+ struct kernfs_node *kn_evt, *kn_evt_config;
int ret = 0;

- kn = __kernfs_create_file(parent_kn, name, 0444,
- GLOBAL_ROOT_UID, GLOBAL_ROOT_GID, 0,
- &kf_mondata_ops, priv, NULL, NULL);
- if (IS_ERR(kn))
- return PTR_ERR(kn);
+ kn_evt = __kernfs_create_file(parent_kn, mevt->name, 0444,
+ GLOBAL_ROOT_UID, GLOBAL_ROOT_GID, 0,
+ &kf_mondata_ops, priv, NULL, NULL);
+ if (IS_ERR(kn_evt))
+ return PTR_ERR(kn_evt);

- ret = rdtgroup_kn_set_ugid(kn);
+ ret = rdtgroup_kn_set_ugid(kn_evt);
if (ret) {
- kernfs_remove(kn);
+ kernfs_remove(kn_evt);
return ret;
}

+ if (mevt->configurable) {
+ kn_evt_config = __kernfs_create_file(parent_kn,
+ mevt->config_name, 0644,
+ GLOBAL_ROOT_UID, GLOBAL_ROOT_GID, 0,
+ &kf_mondata_config_ops, priv, NULL, NULL);
+ if (IS_ERR(kn_evt_config))
+ return PTR_ERR(kn_evt_config);
+
+ ret = rdtgroup_kn_set_ugid(kn_evt_config);
+ if (ret) {
+ kernfs_remove(kn_evt_config);
+ kernfs_remove(kn_evt);
+ return ret;
+ }
+ }
+
return ret;
}

@@ -2550,7 +2570,7 @@ static int mkdir_mondata_subdir(struct kernfs_node *parent_kn,
priv.u.domid = d->id;
list_for_each_entry(mevt, &r->evt_list, list) {
priv.u.evtid = mevt->evtid;
- ret = mon_addfile(kn, mevt->name, priv.priv);
+ ret = mon_addfile(kn, mevt, priv.priv);
if (ret)
goto out_destroy;


\
 
 \ /
  Last update: 2022-09-07 20:02    [W:0.156 / U:0.816 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site