Re: [PATCH] memcg: decouple memcg_hotplug_cpu_dead from stock_lock

From: Sebastian Andrzej Siewior
Date: Fri Apr 11 2025 - 10:08:09 EST


On 2025-04-11 10:55:31 [+0200], Vlastimil Babka wrote:
> > @@ -1964,10 +1964,10 @@ static int memcg_hotplug_cpu_dead(unsigned int cpu)
> >
> > stock = &per_cpu(memcg_stock, cpu);
> >
> > - /* drain_obj_stock requires stock_lock */
> > - local_lock_irqsave(&memcg_stock.stock_lock, flags);
> > - drain_obj_stock(stock);
> > - local_unlock_irqrestore(&memcg_stock.stock_lock, flags);
> > + local_irq_save(flag);
>
> I think for RT this is not great? At least in theory, probably it's not
> actually used together with cpu hotplug? As it relies on memcg_stats_lock()
> I think no irq save/enable is necessary there. local_lock_irqsave wasn't
> actually a irq disable on RT. I don't know if there's a handy wrapper for this.

No seeing the whole context but memcg_hotplug_cpu_dead() should be
invoked the control CPU while "cpu" is already gone. So the local_lock
should be acquired and the target CPU needs no locks since it is
offline. local_irq_save() will break things.

Sebastian