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

From: Paul E. McKenney

Date: Sat Dec 05 2026 - 15:50:35 EST


On Fri, Dec 04, 2026 at 08:37:13AM -0800, Paul E. McKenney wrote:
> On Fri, Dec 04, 2026 at 09:24:02AM +0100, Michal Hocko wrote:

[ . . . ]

> > 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. :-(

One thing that can be done with RCU as it exists today is to invoke
start_poll_synchronize_rcu_expedited(), which starts an expedited RCU
grace period. Given Puranjay Mohan's recent contribution, this will
make RCU callbacks ready to invoke, or at least those that have already
been assigned a grace period. This function uses queue_work(), but on
a WQ_MEM_RECLAIM workqueue.

If this is useful, it would not be hard to create a function that
assigned all currently queued RCU callbacks to a grace period, and
then invoked start_poll_synchronize_rcu_expedited(). This would
have the effect of an asynchronous counterpart to rcu_barrier().

Would that help?

Thanx, Paul