Re: [PATCH v8 13/32] x86,fs/resctrl: Handle events that can be read from any CPU
From: Reinette Chatre
Date: Thu Aug 14 2025 - 00:12:27 EST
Hi Tony,
On 8/11/25 11:16 AM, Tony Luck wrote:
...
> diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
> index c3f697da612b..d6585f7d1c9e 100644
> --- a/fs/resctrl/monitor.c
> +++ b/fs/resctrl/monitor.c
> @@ -356,15 +356,47 @@ static struct mbm_state *get_mbm_state(struct rdt_l3_mon_domain *d, u32 closid,
> return state ? &state[idx] : NULL;
> }
>
> +/*
> + * Called from preemptible context via a direct call of mon_event_count() for
> + * events that can be read on any CPU.
> + * Called from preemptible but non-migratable process context (mon_event_count()
> + * via smp_call_on_cpu()) OR non-preemptible context (mon_event_count() via
> + * smp_call_function_any()) for events that need to be read on a specific CPU.
> + */
> +static bool cpu_on_correct_domain(struct rmid_read *rr)
Function returns bool ...
> +{
> + struct cacheinfo *ci;
> + int cpu;
> +
> + /* Any CPU is OK for this event */
> + if (rr->evt->any_cpu)
> + return true;
> +
> + cpu = smp_processor_id();
> +
> + /* Single domain. Must be on a CPU in that domain. */
> + if (rr->hdr)
> + return cpumask_test_cpu(cpu, &rr->hdr->cpu_mask);
> +
> + if (WARN_ON_ONCE(rr->r->rid != RDT_RESOURCE_L3))
> + return -EINVAL;
return false?
> +
> + /* Summing domains that share a cache, must be on a CPU for that cache. */
> + ci = get_cpu_cacheinfo_level(cpu, RESCTRL_L3_CACHE);
> +
> + return ci && ci->id == rr->ci_id;
> +}
> +
Reinette