Re: [PATCH] memcg: clear FLUSHING_CACHED_CHARGE on cpu offline
From: Rik van Riel
Date: Fri Aug 28 2026 - 15:54:39 EST
On Fri, 2026-08-28 at 12:24 -0700, Shakeel Butt wrote:
> Sashiko [1] reported that memcg_hotplug_cpu_dead() drains the stocks
> of the CPU which went away but leaves FLUSHING_CACHED_CHARGE alone.
>
> The flag can be set at that point: drain_all_stock() may have claimed
> the stock and queued the drain work shortly before the CPU went down.
> workqueue_offline_cpu() unbinds the per-cpu workers, so such a
> pending
> work item is executed by an unbound worker on some other CPU, where
> drain_local_memcg_stock() operates on this_cpu_ptr() and thus drains
> and clears the flag of that other CPU instead. Nothing clears the
> flag
> of the dead CPU, so drain_all_stock() would skip its stock forever
> once
> the CPU comes back online.
>
> Clear the flag of both stocks after draining them.
>
> Signed-off-by: Shakeel Butt <shakeel.butt@xxxxxxxxx>
> Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
> Link:
> https://sashiko.dev/#/patchset/20260828135036.7d44361f%40fangorn [1]
> ---
>
Funny, my AI came up with the same solution, and
I just asked it to do a safety analysis on it.
It was quite thorough.
Reviewed-by: Rik van Riel <riel@xxxxxxxxxxx>
--
All Rights Reversed.