From: Babu Moger <babu.moger@amd.com>
To: <fenghua.yu@intel.com>, <reinette.chatre@intel.com>,
<tglx@linutronix.de>, <mingo@redhat.com>, <bp@alien8.de>
Cc: <eranian@google.com>, <dave.hansen@linux.intel.com>,
<x86@kernel.org>, <hpa@zytor.com>, <corbet@lwn.net>,
<hpa@zytor.com>, <linux-kernel@vger.kernel.org>,
<linux-doc@vger.kernel.org>
Subject: [PATCH v2 07/10] x86/resctrl: Add sysfs interface files to read/write event configuration
Date: Mon, 1 Aug 2022 15:56:24 -0500 [thread overview]
Message-ID: <165938738481.724959.179823924599228076.stgit@bmoger-ubuntu> (raw)
In-Reply-To: <165938717220.724959.10931629283087443782.stgit@bmoger-ubuntu>
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/internal.h | 3 +++
arch/x86/kernel/cpu/resctrl/monitor.c | 2 ++
arch/x86/kernel/cpu/resctrl/rdtgroup.c | 32 ++++++++++++++++++++++++++++++++
3 files changed, 37 insertions(+)
diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index c049a274383c..fc725f5e9024 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -72,11 +72,13 @@ DECLARE_STATIC_KEY_FALSE(rdt_mon_enable_key);
* struct mon_evt - Entry in the event list of a resource
* @evtid: event id
* @name: name of the event
+ * @config: current configuration
* @list: entry in &rdt_resource->evt_list
*/
struct mon_evt {
u32 evtid;
char *name;
+ char *config;
struct list_head list;
};
@@ -95,6 +97,7 @@ union mon_data_bits {
unsigned int rid : 10;
unsigned int evtid : 8;
unsigned int domid : 14;
+ unsigned int mon_config : 32;
} u;
};
diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
index b9de417dac1c..3f900241dbab 100644
--- a/arch/x86/kernel/cpu/resctrl/monitor.c
+++ b/arch/x86/kernel/cpu/resctrl/monitor.c
@@ -656,11 +656,13 @@ static struct mon_evt llc_occupancy_event = {
static struct mon_evt mbm_total_event = {
.name = "mbm_total_bytes",
.evtid = QOS_L3_MBM_TOTAL_EVENT_ID,
+ .config = "mbm_total_config",
};
static struct mon_evt mbm_local_event = {
.name = "mbm_local_bytes",
.evtid = QOS_L3_MBM_LOCAL_EVENT_ID,
+ .config = "mbm_local_config",
};
/*
diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index 855483b297a8..30d2182d4fda 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;
@@ -2534,6 +2538,25 @@ void rmdir_mondata_subdir_allrdtgrp(struct rdt_resource *r, unsigned int dom_id)
}
}
+static int mon_config_addfile(struct kernfs_node *parent_kn, const char *name,
+ void *priv)
+{
+ struct kernfs_node *kn;
+ int ret = 0;
+
+ kn = __kernfs_create_file(parent_kn, name, 0644,
+ GLOBAL_ROOT_UID, GLOBAL_ROOT_GID, 0,
+ &kf_mondata_config_ops, priv, NULL, NULL);
+ if (IS_ERR(kn))
+ return PTR_ERR(kn);
+
+ ret = rdtgroup_kn_set_ugid(kn);
+ if (ret)
+ kernfs_remove(kn);
+
+ return ret;
+}
+
static int mkdir_mondata_subdir(struct kernfs_node *parent_kn,
struct rdt_domain *d,
struct rdt_resource *r, struct rdtgroup *prgrp)
@@ -2568,6 +2591,15 @@ static int mkdir_mondata_subdir(struct kernfs_node *parent_kn,
if (ret)
goto out_destroy;
+ /* Create the sysfs event configuration files */
+ if (r->mon_configurable &&
+ (mevt->evtid == QOS_L3_MBM_TOTAL_EVENT_ID ||
+ mevt->evtid == QOS_L3_MBM_LOCAL_EVENT_ID)) {
+ ret = mon_config_addfile(kn, mevt->config, priv.priv);
+ if (ret)
+ goto out_destroy;
+ }
+
if (is_mbm_event(mevt->evtid))
mon_event_read(&rr, r, d, prgrp, mevt->evtid, true);
}
next prev parent reply other threads:[~2022-08-01 20:57 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-01 20:55 [PATCH v2 00/10] x86/resctrl: Support for AMD QoS new features and bug fix Babu Moger
2022-08-01 20:55 ` [PATCH v2 01/10] x86/resctrl: Fix min_cbm_bits for AMD Babu Moger
2022-08-01 20:55 ` [PATCH v2 02/10] x86/cpufeatures: Add Slow Memory Bandwidth Allocation feature flag Babu Moger
2022-08-01 20:55 ` [PATCH v2 03/10] x86/resctrl: Add a new resource type RDT_RESOURCE_SMBA Babu Moger
2022-08-01 20:56 ` [PATCH v2 04/10] x86/resctrl: Detect and configure Slow Memory Bandwidth allocation Babu Moger
2022-08-01 20:56 ` [PATCH v2 05/10] x86/cpufeatures: Add Bandwidth Monitoring Event Configuration feature flag Babu Moger
2022-08-01 20:56 ` [PATCH v2 06/10] x86/resctrl: Introduce mon_configurable to detect Bandwidth Monitoring Event Configuration Babu Moger
2022-08-01 20:56 ` Babu Moger [this message]
2022-08-01 20:56 ` [PATCH v2 08/10] x86/resctrl: Add the sysfs interface to read the event configuration Babu Moger
2022-08-01 20:56 ` [PATCH v2 09/10] x86/resctrl: Add sysfs interface to write " Babu Moger
2022-08-01 20:56 ` [PATCH v2 10/10] Documentation/x86: Update resctrl_ui.rst for new features Babu Moger
2022-08-03 3:50 ` Bagas Sanjaya
2022-08-03 15:59 ` Moger, Babu
2022-08-04 7:57 ` Bagas Sanjaya
2022-08-02 2:16 ` [PATCH v2 00/10] x86/resctrl: Support for AMD QoS new features and bug fix Bagas Sanjaya
2022-08-02 9:39 ` Ingo Molnar
2022-08-02 13:41 ` Moger, Babu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=165938738481.724959.179823924599228076.stgit@bmoger-ubuntu \
--to=babu.moger@amd.com \
--cc=bp@alien8.de \
--cc=corbet@lwn.net \
--cc=dave.hansen@linux.intel.com \
--cc=eranian@google.com \
--cc=fenghua.yu@intel.com \
--cc=hpa@zytor.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=reinette.chatre@intel.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®