From: Michal Hocko <mhocko@suse.com>
To: sashiko-reviews@lists.linux.dev
Cc: David Hildenbrand <david@kernel.org>,
David Rientjes <rientjes@google.com>,
Ben Gardon <bgardon@google.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org
Subject: Re: [PATCH 08/10] mm, oom: wait for rcu_call callbacks before retrying reclaim
Date: Wed, 2 Dec 2026 20:44:34 +0100 [thread overview]
Message-ID: <axB1ItfYo8kyyO_i@tiehlicka> (raw)
In-Reply-To: <sashiko-outbox-246218@kernel.org>
On Wed 02-12-26 16:31:02, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential
> issues to consider:
> - [High] mm: rcu_barrier() in should_reclaim_retry() runs after zone
> watermark check
> - [High] mm: should_reclaim_retry() calls rcu_barrier() even when
> reclaim progresses
> --
>
> commit 80d44083709f0dc6896c3ee8f1c5829f534bd7fa
> Author: Michal Hocko <mhocko@suse.com>
>
> mm, oom: wait for rcu_call callbacks before retrying reclaim
>
> This commit adds an rcu_barrier() call in should_reclaim_retry() to wait
> for in-flight RCU callbacks to free memory before retrying reclaim.
>
> > diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> > index aa1ed599c7c6b..c4dc421e7edf1 100644
> > --- a/mm/page_alloc.c
> > +++ b/mm/page_alloc.c
> > @@ -4713,6 +4713,9 @@ should_reclaim_retry(gfp_t gfp_mask, unsigned order,
> > schedule_timeout_uninterruptible(1);
> > else
> > cond_resched();
> > +
> > + /* Wait for any potential call_rcu memory freers */
> > + rcu_barrier();
> > out:
> > /* Before OOM, exhaust highatomic_reserve */
> > if (!ret)
>
> [Severity: High]
> Does running rcu_barrier() after the zone watermark loop cause
> should_reclaim_retry() to return false without re-checking the memory just
> freed by the RCU callbacks?
>
> Pages waiting on call_rcu() are not counted in zone_reclaimable_pages() or
> NR_FREE_PAGES until their callbacks run. When remaining LRU and free
> pages are below min_wmark, the loop leaves ret as false before
> rcu_barrier() drains the pending callbacks, so should_reclaim_retry()
> still returns false and __alloc_pages_slowpath() proceeds straight to
> __alloc_pages_may_oom() instead of retrying the allocation.
>
> [Severity: High]
> Should rcu_barrier() be skipped when direct reclaim made progress
> (did_some_progress is true and *no_progress_loops is reset to 0), similar
> to how commit "memcg, oom: wait for rcu_call callbacks before retrying
> reclaim" only calls rcu_barrier() in try_charge_memcg() when nr_reclaimed
> is zero?
>
> Calling rcu_barrier() unconditionally on every should_reclaim_retry() pass
> serializes all multi-pass direct-reclaim threads on
> rcu_state.barrier_mutex, sends cross-CPU IPIs, and waits for a full RCU
> grace period even while normal reclaim is actively freeing pages.
Fair point. I will think about some more. I have to admit I am not
entirely convinced about this patch. I should have probably marked it
RFC.
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20261202095450.296675-1-mhocko@kernel.org?part=8
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2026-12-02 19:44 UTC|newest]
Thread overview: 23+ 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 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 16:30 ` sashiko-bot
2026-12-02 19:23 ` 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 16:31 ` sashiko-bot
2026-12-02 19:38 ` 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 16:31 ` sashiko-bot
2026-12-02 19:44 ` Michal Hocko [this message]
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 16:31 ` sashiko-bot
2026-12-02 19:53 ` Michal Hocko
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=axB1ItfYo8kyyO_i@tiehlicka \
--to=mhocko@suse.com \
--cc=akpm@linux-foundation.org \
--cc=bgardon@google.com \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-mm@kvack.org \
--cc=rientjes@google.com \
--cc=sashiko-reviews@lists.linux.dev \
/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