[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <686d0769-a0f2-4808-b038-9c9735f1ddd5@intel.com>
Date: Tue, 12 Nov 2024 14:18:43 -0800
From: Reinette Chatre <reinette.chatre@...el.com>
To: Tony Luck <tony.luck@...el.com>, Fenghua Yu <fenghua.yu@...el.com>, "Peter
Newman" <peternewman@...gle.com>, Jonathan Corbet <corbet@....net>, Shuah
Khan <skhan@...uxfoundation.org>, <x86@...nel.org>
CC: James Morse <james.morse@....com>, Jamie Iles <quic_jiles@...cinc.com>,
Babu Moger <babu.moger@....com>, Randy Dunlap <rdunlap@...radead.org>,
"Shaopeng Tan (Fujitsu)" <tan.shaopeng@...itsu.com>,
<linux-kernel@...r.kernel.org>, <linux-doc@...r.kernel.org>,
<patches@...ts.linux.dev>
Subject: Re: [PATCH v8 6/7] x86/resctrl: Add write option to "mba_MBps_event"
file
Hi Tony,
On 10/29/24 10:28 AM, Tony Luck wrote:
> A user can choose any of the memory bandwidth monitoring events
> listed in /sys/fs/resctrl/info/L3_mon/mon_features independently
> for each ctrl_mon group by writing to the "mba_MBps_event" file.
Please review the changelog based on tip requirements. Folks used to
tip customs may expect changelog to start with the context, while the
above reads like it describes current context it describes what this patch
makes possible without ever getting to description of the change itself.
>
> Signed-off-by: Tony Luck <tony.luck@...el.com>
> ---
> arch/x86/kernel/cpu/resctrl/internal.h | 2 +
> arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 46 +++++++++++++++++++++++
> arch/x86/kernel/cpu/resctrl/rdtgroup.c | 1 +
> 3 files changed, 49 insertions(+)
>
> diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
> index 5f3438ca9e2b..35483c6615b6 100644
> --- a/arch/x86/kernel/cpu/resctrl/internal.h
> +++ b/arch/x86/kernel/cpu/resctrl/internal.h
> @@ -609,6 +609,8 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
> char *buf, size_t nbytes, loff_t off);
> int rdtgroup_schemata_show(struct kernfs_open_file *of,
> struct seq_file *s, void *v);
> +ssize_t rdtgroup_mba_mbps_event_write(struct kernfs_open_file *of,
> + char *buf, size_t nbytes, loff_t off);
> int rdtgroup_mba_mbps_event_show(struct kernfs_open_file *of,
> struct seq_file *s, void *v);
> bool rdtgroup_cbm_overlaps(struct resctrl_schema *s, struct rdt_ctrl_domain *d,
> diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
> index b9ba419e5c88..fc5585dc688f 100644
> --- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
> +++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
> @@ -518,6 +518,52 @@ static int smp_mon_event_count(void *arg)
> return 0;
> }
>
> +ssize_t rdtgroup_mba_mbps_event_write(struct kernfs_open_file *of,
> + char *buf, size_t nbytes, loff_t off)
> +{
> + struct rdtgroup *rdtgrp;
> + int ret = 0;
> +
> + /* Valid input requires a trailing newline */
> + if (nbytes == 0 || buf[nbytes - 1] != '\n')
> + return -EINVAL;
> + buf[nbytes - 1] = '\0';
> +
> + rdtgrp = rdtgroup_kn_lock_live(of->kn);
> + if (!rdtgrp) {
> + rdtgroup_kn_unlock(of->kn);
> + return -ENOENT;
> + }
> + rdt_last_cmd_clear();
> +
> + if (!strcmp(buf, "mbm_local_bytes")) {
> + if (is_mbm_local_enabled())
> + rdtgrp->mba_mbps_event = QOS_L3_MBM_LOCAL_EVENT_ID;
> + else
> + ret = -ENXIO;
> + } else if (!strcmp(buf, "mbm_total_bytes")) {
> + if (is_mbm_total_enabled())
> + rdtgrp->mba_mbps_event = QOS_L3_MBM_TOTAL_EVENT_ID;
> + else
> + ret = -ENXIO;
> + } else {
> + ret = -EINVAL;
> + }
> +
> + switch (ret) {
> + case -ENXIO:
> + rdt_last_cmd_printf("Unsupported event id '%s'\n", buf);
> + break;
> + case -EINVAL:
> + rdt_last_cmd_printf("Unknown event id '%s'\n", buf);
> + break;
> + }
nit: What is the benefit of distinguishing between these cases in messaging to
user space? I am thinking of the scenario where user may write "llc_occupancy",
this will print "Unknown event id", which is technically not correct since it is
"known", it is just not "supported". Perhaps the default error message can just
always be "Unsupported"?
> +
> + rdtgroup_kn_unlock(of->kn);
> +
> + return ret ?: nbytes;
> +}
> +
> int rdtgroup_mba_mbps_event_show(struct kernfs_open_file *of,
> struct seq_file *s, void *v)
> {
> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> index 3ba81963e981..6fa501ef187f 100644
> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> @@ -1947,6 +1947,7 @@ static struct rftype res_common_files[] = {
> .name = "mba_MBps_event",
> .mode = 0644,
Writable bits can be set in this commit.
> .kf_ops = &rdtgroup_kf_single_ops,
> + .write = rdtgroup_mba_mbps_event_write,
> .seq_show = rdtgroup_mba_mbps_event_show,
> },
> {
Reinette
Powered by blists - more mailing lists