[PATCH 03/33] memcg: Prepare to protect against concurrent isolated cpuset change
Michal Hocko
mhocko at suse.com
Mon Jan 26 08:41:38 PST 2026
On Sun 25-01-26 23:45:10, Frederic Weisbecker wrote:
> The HK_TYPE_DOMAIN housekeeping cpumask will soon be made modifiable at
> runtime. In order to synchronize against memcg workqueue to make sure
> that no asynchronous draining is pending or executing on a newly made
> isolated CPU, target and queue a drain work under the same RCU critical
> section.
>
> Whenever housekeeping will update the HK_TYPE_DOMAIN cpumask, a memcg
> workqueue flush will also be issued in a further change to make sure
> that no work remains pending after a CPU has been made isolated.
>
> Signed-off-by: Frederic Weisbecker <frederic at kernel.org>
> ---
> mm/memcontrol.c | 21 +++++++++++++++++----
> 1 file changed, 17 insertions(+), 4 deletions(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index be810c1fbfc3..2289a0299331 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -2003,6 +2003,19 @@ static bool is_memcg_drain_needed(struct memcg_stock_pcp *stock,
> return flush;
> }
>
> +static void schedule_drain_work(int cpu, struct work_struct *work)
> +{
> + /*
> + * Protect housekeeping cpumask read and work enqueue together
> + * in the same RCU critical section so that later cpuset isolated
> + * partition update only need to wait for an RCU GP and flush the
> + * pending work on newly isolated CPUs.
> + */
> + guard(rcu)();
> + if (!cpu_is_isolated(cpu))
> + schedule_work_on(cpu, work);
Shouldn't this in the guarded rcu section?
--
Michal Hocko
SUSE Labs
More information about the linux-arm-kernel
mailing list