Re: [PATCH v2] mm, oom: add rcu_barrier before hiding victim from the oom killer

From: Paul E. McKenney

Date: Fri Dec 04 2026 - 11:37:22 EST


On Fri, Dec 04, 2026 at 09:24:02AM +0100, Michal Hocko wrote:
> On Thu 03-12-26 13:36:50, Paul E. McKenney wrote:
> > On Thu, Dec 03, 2026 at 09:42:24PM +0100, Michal Hocko wrote:
> > > On Thu 03-12-26 12:02:00, Paul E. McKenney wrote:
> [...]
> > > > And yes, my concern is that RCU grace periods are blocked on reclaim
> > > > while reclaim blocks on an RCU grace period. But maybe this code is
> > > > guaranteed to run in its own kthreads or similar?
> > >
> > > Yes, oom_reaper itself is running in a dedicated kernel thread. Is that
> > > sufficient? I thought we could have an indirect dependency chain
> > >
> > > RCU grace period oom_reaper oom_victim
> > > allocates memory [blocked]
> > > looping in reclaim rcu_barrier();
> > > [blocked]
> > > MMF_OOM_SKIP
> >
> > Good point, RCU would need to do non-blocking allocations to avoid
> > that dependency chain.
>
> Or pre-allocate so that it doesn't block from inside of the grace
> period.

I used to do just that, until we encountered systems whose firmware
claimed many more CPUs than actually existed, which caused people to
complain about the resulting useless RCU kthreads. :-(

As a result, now many allocations happen when given CPU first comes
online.

> Anyway, thanks for the insight. I will drop the barrier from the
> oom_reaper and also the global memory reclaim
> https://lore.kernel.org/all/20261202095450.296675-9-mhocko@xxxxxxxxxx/T/#u

Would another approach be to prevent CPU hotplug during reclaim?
Or at least across the rcu_barrier() call? No, that just gets us more
opportunities for deadlock between reclaim and CPU hotplug. :-(

Thanx, Paul