Re: [PATCH v12 20/26] x86/resctrl: Provide interface to update the event configurations

Reinette Chatre
2025-04-11T22:07:47Z

Hi Babu,

On 4/3/25 5:18 PM, Babu Moger wrote:
> Users can modify the event configuration by writing to the event_filter
> interface file. The event configurations for mbm_cntr_assign mode are
> located in /sys/fs/resctrl/info/event_configs/.
>
> Update the assignments of all groups when the event configuration is
> modified.
>
> Example:
> $ cd /sys/fs/resctrl/
> $ echo "local_reads, local_non_temporal_writes" >
> info/L3_MON/counter_configs/mbm_total_bytes/event_filter
>
> $ cat info/L3_MON/counter_configs/mbm_total_bytes/event_filter
> local_reads, local_non_temporal_writes
>
> Signed-off-by: Babu Moger <babu.moger@amd.com>
> ---
> v12: New patch to modify event configurations.
> ---
> Documentation/arch/x86/resctrl.rst | 10 +++
> arch/x86/kernel/cpu/resctrl/rdtgroup.c | 115 ++++++++++++++++++++++++-
> 2 files changed, 124 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/resctrl.rst
> index 99f9f4b9b501..4e6feba6fb08 100644
> --- a/Documentation/arch/x86/resctrl.rst
> +++ b/Documentation/arch/x86/resctrl.rst
> @@ -335,6 +335,16 @@ with the following files:
> # cat /sys/fs/resctrl/info/L3_MON/counter_configs/mbm_local_bytes/event_filter
> local_reads, local_non_temporal_writes, local_reads_slow_memory
>
> + The event configuration can be modified by writing to the event_filter file within
> + the configuration directory.

Please use imperative tone.

> + ::
> +
> + # echo "local_reads, local_non_temporal_writes" >
> + /sys/fs/resctrl/info/L3_MON/counter_configs/mbm_total_bytes/event_filter
> +
> + # cat /sys/fs/resctrl/info/L3_MON/counter_configs/mbm_total_bytes/event_filter
> + local_reads, local_non_temporal_writes
> +
> "max_threshold_occupancy":
> Read/write file provides the largest value (in
> bytes) at which a previously used LLC_occupancy
> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> index b2122a1dd36c..7792455f0b26 100644
> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> @@ -1926,6 +1926,118 @@ static int event_filter_show(struct kernfs_open_file *of, struct seq_file *seq,
> return 0;
> }
>

Could you please add comments to these new functions to explain what they do?

> +static int resctrl_group_assign(struct rdt_resource *r, struct rdtgroup *rdtgrp,
> + enum resctrl_event_id evtid, u32 evt_cfg)
> +{
> + struct rdt_mon_domain *d;
> + int cntr_id, ret;
> +
> + list_for_each_entry(d, &r->mon_domains, hdr.list) {
> + cntr_id = mbm_cntr_get(r, d, rdtgrp, evtid);
> + if (cntr_id >= 0 && d->cntr_cfg[cntr_id].evt_cfg != evt_cfg) {
> + d->cntr_cfg[cntr_id].evt_cfg = evt_cfg;
> + ret = resctrl_arch_config_cntr(r, d, evtid, rdtgrp->mon.rmid,
> + rdtgrp->closid, cntr_id, evt_cfg, true);
> + if (ret) {
> + rdt_last_cmd_printf("Assign failed event %d domain %d group %s\n",
> + evtid, d->hdr.id, rdtgrp->kn->name);

Please provide the actual event name to user space. The event IDs are not visible to
user space.

Reinette