The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@suse.com>
To: "Paul E. McKenney" <paulmck@kernel.org>
Cc: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>,
	David Hildenbrand <david@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	David Rientjes <rientjes@google.com>,
	Ben Gardon <bgardon@google.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	linux-mm@kvack.org, LKML <linux-kernel@vger.kernel.org>,
	Chris Mason <mason@kernel.org>
Subject: Re: [PATCH v2] mm, oom: add rcu_barrier before hiding victim from the oom killer
Date: Thu, 3 Dec 2026 19:11:39 +0100	[thread overview]
Message-ID: <axGw2wieU-VXyFdF@tiehlicka> (raw)
In-Reply-To: <d67a9553-e1db-47db-b6d2-203617c988cb@paulmck-laptop>

On Thu 03-12-26 09:39:53, Paul E. McKenney wrote:
[...]
> > And this is a super sensitive point - will this always result in forward
> > progress? Could it be significantly delayed?
> 
> Normal grace period latencies tend to be in the tens or hundreds of
> milliseconds.  And RCU CPU stall warnings happen when a given grace period
> extends for more than 21 *seconds*, so long RCU grace periods can happen.
> On the other hand, grace periods this long are (and should be) treated
> as bugs.

Yes, I guess it is expected that this can take a long time. And this
particular patch adds it to two places: 
	- exit_mmap for an oom_victim
	- oom_reaper

The former is dying and if that takes longer while it is guaranteed to
release its own memory from page tables which are freed through RCU then
this is good. We do not even need a guarantee of a fwd progress here.

The latter is more sensitive as it needs the guarantee of fwd progress. 
Although it doesn't hold any locks explicitly it ensures that the
currently selected oom victims will be torn down - either through them
exiting or remotely through the reaper. In either case they are declared
MMF_OOM_SKIP in the end.
If that takes longer then still not anything really earth shattering as
long as this cannot block for unbound amount of time.

> > Are there any lock dependencies that could be problematic?
> 
> Given that you are asking this, I am assuming that if this rcu_barrier()
> gets stuck, reclaim also gets stuck.
> 
> You are not allowed to acquire sleeplocks in RCU callback functions,
> and you are not allowed to hold spinlocks across an rcu_barrier(), so
> at a high level, no.

Thanks for the confirmation. That was my understanding.

> One theoretical problem would be if RCU allocated
> memory while doing a grace period, and the call to rcu_barrier() blocked
> the grace period that its callback functions were in turn waiting on.
> And there might be something like this that could happen when a CPU
> was coming online for the very first time, especially if that CPU was
> a rcu_nocbs CPU, which needs kthreads to be created.
> 
> No locks involved, but self-deadlock nevertheless.

Could you clarify a bit please? So this would be possible only during
early boot while hitting OOM because RCU internals would be blocked on
the memory allocation which cannot be resolved?

> So maybe make that rcu_barrier() execute asynchronously?

Well the thing is that we need to use it to order MMF_OOM_SKIP setting
in the oom_reaper case.

> And/or do a
> synchronize_rcu_expedited(), also asynchronously?

As this is mostly a best effort to ensure a lot of memory is not sitting
to be freed in rcu callbacks then I would much rather just drop the
rcu_barrier from oom_reap_task.

-- 
Michal Hocko
SUSE Labs

  reply	other threads:[~2026-12-03 18:11 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  9:53 [PATCH 0/10] assorted oom fixes Michal Hocko
2026-12-02  9:53 ` [PATCH 01/10] memcg-v1, oom: do not sleep in worker contexts Michal Hocko
2026-12-02 20:21   ` Joshua Hahn
2026-12-02 21:28     ` Michal Hocko
2026-12-02  9:53 ` [PATCH 02/10] mm/oom_kill: keep the allocating mm eligible Michal Hocko
2026-12-02  9:53 ` [PATCH 03/10] mm, oom: do not panic on constrained OOMs Michal Hocko
2026-12-02  9:53 ` [PATCH 04/10] mm/oom_kill: ratelimit memcg OOM reports with no victim Michal Hocko
2026-12-02  9:53 ` [PATCH 05/10] mm, oom: thaw tasks sharing the mm with the oom victim Michal Hocko
2026-12-02  9:53 ` [PATCH 06/10] mm, oom: check oom victims prior to numa placement Michal Hocko
2026-12-02  9:54 ` [PATCH 07/10] memcg, oom: wait for rcu_call callbacks before retrying reclaim Michal Hocko
2026-12-02 19:22   ` Harry Yoo
2026-12-02 19:33     ` Michal Hocko
2026-12-02  9:54 ` [PATCH 08/10] mm, " Michal Hocko
2026-12-02  9:54 ` [PATCH 09/10] mm, oom: add rcu_barrier before hiding victim from the oom killer Michal Hocko
2026-12-02 21:21   ` [PATCH v2] " Michal Hocko
2026-12-03 12:24     ` Lorenzo Stoakes (ARM)
2026-12-03 17:39       ` Paul E. McKenney
2026-12-03 18:11         ` Michal Hocko [this message]
2026-12-02  9:54 ` [PATCH 10/10] memcg: wake v1 OOM lock contenders on unlock Michal Hocko
2026-12-02 13:06 ` [PATCH 0/10] assorted oom fixes David Hildenbrand (Arm)
2026-12-02 19:01   ` Michal Hocko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=axGw2wieU-VXyFdF@tiehlicka \
    --to=mhocko@suse.com \
    --cc=akpm@linux-foundation.org \
    --cc=bgardon@google.com \
    --cc=david@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mason@kernel.org \
    --cc=paulmck@kernel.org \
    --cc=rientjes@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox