Re: [PATCH v3 10/26] fs/resctrl: Improve handling for events that can be read from any CPU

Luck, Tony
2025-04-21T20:28:31Z

On Fri, Apr 18, 2025 at 03:54:02PM -0700, Reinette Chatre wrote:
> > @@ -619,7 +622,8 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg)
> > goto out;
> > }
> > d = container_of(hdr, struct rdt_mon_domain, hdr);
> > - mon_event_read(&rr, r, d, rdtgrp, &d->hdr.cpu_mask, evtid, false);
> > + mask = md->any_cpu ? cpu_online_mask : &d->hdr.cpu_mask;
> > + mon_event_read(&rr, r, d, rdtgrp, mask, evtid, false);
>
> I do not think this accomplishes the goal of this patch. Looking at mon_event_read() it calls
> cpumask_any_housekeeping(cpumask, RESCTRL_PICK_ANY_CPU) before any of the smp_*() calls.
>
> cpumask_any_housekeeping()
> {
> ...
> if (exclude_cpu == RESCTRL_PICK_ANY_CPU)
> cpu = cpumask_any(mask);
> ...
> }
>
> cpumask_any() is just cpumask_first() so it will pick the first CPU in the
> online mask that may not be the current CPU.
>
> fwiw ... there are some optimizations planned in this area that I have not yet studied:
> https://lore.kernel.org/lkml/20250407153856.133093-1-yury.norov@gmail.com/

I remember Peter complaining[1] about extra context switches when
cpumask_any_housekeeping() was introduced, but it seems that the
discussion died with no fix applied.

The blocking problem is that ARM may not be able to read a counter
on a tick_nohz CPU because it may need to sleep.

Do we need more options for events:

1) Must be read on a CPU in the right domain // Legacy
2) Can be read from any CPU // My addtion
3) Must be read on a "housekeeping" CPU // James' code in upstream
4) Cannot be read on a tick_nohz CPU // Could be combined with 1 or 2?

> Reinette

[1] https://lore.kernel.org/all/20241031142553.3963058-2-peternewman@google.com/
>