Re: [PATCH v3 12/26] fs/resctrl: Add hook for architecture code to set monitor event attributes

Reinette Chatre
2025-04-18T23:11:34Z

Hi Tony,

On 4/7/25 4:40 PM, Tony Luck wrote:
> Architecture code knows whether an event can be read from any CPU, or
> from a CPU on a specific domain. It also knows what format to use
> when printing each event value.
>
> Add a hook to set mon_event.any_cpu and mon_event.type.

If the architecture modifies the output format then the values exposed
to user space will look different between architectures. User space will
need to know how to parse the data. We do not want user space to need to
know which architecture it is running on to determine how to interact with
user space so this makes me think that this change needs to be accompanied
with a change that exposes the event format to user space.

>
> Signed-off-by: Tony Luck <tony.luck@intel.com>
> ---
> include/linux/resctrl.h | 3 +++
> fs/resctrl/monitor.c | 12 ++++++++++++
> 2 files changed, 15 insertions(+)
>
> diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
> index 0fce626605b9..8ac77b738de5 100644
> --- a/include/linux/resctrl.h
> +++ b/include/linux/resctrl.h
> @@ -418,6 +418,9 @@ void resctrl_offline_mon_domain(struct rdt_resource *r, struct rdt_mon_domain *d
> void resctrl_online_cpu(unsigned int cpu);
> void resctrl_offline_cpu(unsigned int cpu);
>
> +int resctrl_set_event_attributes(enum resctrl_event_id evt,
> + enum resctrl_event_type type, bool any_cpu);
> +
> /**
> * resctrl_arch_rmid_read() - Read the eventid counter corresponding to rmid
> * for this resource and domain.
> diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
> index 1efad57d1d85..5846a13c631a 100644
> --- a/fs/resctrl/monitor.c
> +++ b/fs/resctrl/monitor.c
> @@ -863,6 +863,18 @@ static struct mon_evt all_events[QOS_NUM_EVENTS] = {
> },
> };
>
> +int resctrl_set_event_attributes(enum resctrl_event_id evt,
> + enum resctrl_event_type type, bool any_cpu)

So this is not actually a hook (in the resctrl_arch sense) but a direct interface
for arch code to change resctrl fs internals ... this needs to be done with care.

> +{
> + if (evt >= QOS_NUM_EVENTS)
> + return -ENOENT;
> +
> + all_events[evt].type = type;
> + all_events[evt].any_cpu = any_cpu;
> +
> + return 0;
> +}
> +
> int rdt_lookup_evtid_by_name(char *name)
> {
> int evt;

Reinette