From: Michal Hocko <mhocko@suse.com>
To: Yosry Ahmed <yosry@kernel.org>
Cc: Charan Teja Kalla <quic_charante@quicinc.com>,
akpm@linux-foundation.org, mgorman@techsingularity.net,
david@redhat.com, vbabka@suse.cz, hannes@cmpxchg.org,
quic_pkondeti@quicinc.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH V3 3/3] mm: page_alloc: drain pcp lists before oom kill
Date: Fri, 4 Sep 2026 13:21:08 +0200 [thread overview]
Message-ID: <apqppFukssaAQz3w@tiehlicka> (raw)
In-Reply-To: <CAO9r8zPCYNmJbkQEA62z75AB=ziWqGb38_E-ee_6o40Sz=zHXA@mail.gmail.com>
On Thu 03-09-26 07:03:33, Yosry Ahmed wrote:
> On Thu, Sep 3, 2026 at 12:27 AM Michal Hocko <mhocko@suse.com> wrote:
> >
> > On Wed 02-09-26 16:49:48, Yosry Ahmed wrote:
> > > On Sun, Nov 05, 2023 at 06:20:50PM +0530, Charan Teja Kalla wrote:
> > > > pcp lists are drained from __alloc_pages_direct_reclaim(), only if some
> > > > progress is made in the attempt.
> > > >
> > > > struct page *__alloc_pages_direct_reclaim() {
> > > > .....
> > > > *did_some_progress = __perform_reclaim(gfp_mask, order, ac);
> > > > if (unlikely(!(*did_some_progress)))
> > > > goto out;
> > > > retry:
> > > > page = get_page_from_freelist();
> > > > if (!page && !drained) {
> > > > drain_all_pages(NULL);
> > > > drained = true;
> > > > goto retry;
> > > > }
> > > > out:
> > > > }
> > > >
> > > > After the above, allocation attempt can fallback to
> > > > should_reclaim_retry() to decide reclaim retries. If it too return
> > > > false, allocation request will simply fallback to oom kill path without
> > > > even attempting the draining of the pcp pages that might help the
> > > > allocation attempt to succeed.
> > > >
> > > > VM system running with ~50MB of memory shown the below stats during OOM
> > > > kill:
> > > > Normal free:760kB boost:0kB min:768kB low:960kB high:1152kB
> > > > reserved_highatomic:0KB managed:49152kB free_pcp:460kB
> > > >
> > > > Though in such system state OOM kill is imminent, but the current kill
> > > > could have been delayed if the pcp is drained as pcp + free is even
> > > > above the high watermark.
> > > >
> > > > Fix this missing drain of pcp list in should_reclaim_retry() along with
> > > > unreserving the high atomic page blocks, like it is done in
> > > > __alloc_pages_direct_reclaim().
> > > >
> > > > Signed-off-by: Charan Teja Kalla <quic_charante@quicinc.com>
> > >
> > > [Sorry for thread necromancy]
> > >
> > > Hi Charan,
> > >
> > > Are you planning to respin this patch?
> > >
> > > I know that Michal was questioning the need for it. While doing some
> > > stress testing I came across a couple of OOM kills that had significant
> > > amount of memory in pcplists. Something that would have been prevented
> > > by this patch.
> >
> > Could you share some numbers to see the scale of the problem?
>
> Sure, here's a sample from an OOM log (ignore mapped/free_mapped, it's
> from the ALLOC_UNMAPPED series):
>
> [ 40.336188] Mem-Info:
> [ 40.336195] active_anon:96 inactive_anon:1540181 isolated_anon:0
> active_file:51 inactive_file:0 isolated_file:0
> unevictable:382720 dirty:43 writeback:0
> slab_reclaimable:20339 slab_unreclaimable:26597
> mapped:382858 shmem:153 pagetables:8291
> sec_pagetables:0 bounce:0
> kernel_misc_reclaimable:0
> free:17264 free_pcp:16890 free_cma:0
> [ 40.336199] Node 0 active_anon:384kB inactive_anon:6160724kB
> active_file:204kB inactive_file:0kB unevictable:1530880kB
> isolated(anon):0kB isolated(file):0kB mapped:1531432kB dirty:172kB
> writeback:0kB shmem:612kB shmem_thp:0kB shmem_pmdmapped:0kB
> anon_thp:10240kB kernel_stack:2576kB pagetables:33164kB
> sec_pagetables:0kB all_unreclaimable? yes Balloon:0kB gpu_active:0kB
> gpu_reclaim:0kB
> [ 40.336202] DMA32 free:34808kB boost:0kB min:11028kB low:13784kB
> high:16540kB reserved_highatomic:0KB free_highatomic:0KB
> free_mapped:11032KB active_anon:0kB inactive_anon:1487720kB
> active_file:52kB inactive_file:20kB unevictable:393252kB
> writepending:4kB zspages:0kB present:2096760kB managed:1991156kB
> mlocked:393252kB bounce:0kB free_pcp:42404kB local_pcp:2460kB
> free_cma:0kB
> [ 40.336205] lowmem_reserve[]: 0 5976 5976
> [ 40.336210] Normal free:34248kB boost:0kB min:34024kB low:42528kB
> high:51032kB reserved_highatomic:0KB free_highatomic:0KB
> free_mapped:34028KB active_anon:384kB inactive_anon:4672764kB
> active_file:180kB inactive_file:0kB unevictable:1137628kB
> writepending:168kB zspages:0kB present:6291456kB managed:6120144kB
> mlocked:1137628kB bounce:0kB free_pcp:25156kB local_pcp:764kB
> free_cma:0kB
> [ 40.336213] lowmem_reserve[]: 0 0 0
>
> As far as I can tell there's about ~65M of free memory stranded on
> pcplists (in an 8G VM), which would have kept the amount of free
> memory above the watermarks and prevented that specific OOM kill.
> Although, as I mentioned before, this is a synthetic stress test.
> Perhaps in practice it doesn't matter all that much in practice, but
> it seems like the logical thing to do.
yes, pcp lists are quite (unusually) high. Is it possible they simply
got repopulated after the first direct reclaim run? Or is there
something else(odd) going on?
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2026-09-04 11:21 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-05 12:50 [PATCH V2 0/3] mm: page_alloc: fixes for early oom kills Charan Teja Kalla
2023-11-05 12:50 ` [PATCH V2 1/3] mm: page_alloc: unreserve highatomic page blocks before oom Charan Teja Kalla
2023-11-09 10:29 ` Michal Hocko
2023-11-05 12:50 ` [PATCH V2 2/3] mm: page_alloc: correct high atomic reserve calculations Charan Teja Kalla
2023-11-16 9:59 ` Mel Gorman
2023-11-16 12:52 ` Michal Hocko
2023-11-17 16:19 ` Mel Gorman
2023-11-05 12:50 ` [PATCH V3 3/3] mm: page_alloc: drain pcp lists before oom kill Charan Teja Kalla
2023-11-05 12:55 ` Charan Teja Kalla
2023-11-09 10:33 ` Michal Hocko
2023-11-10 16:36 ` Charan Teja Kalla
2023-11-14 10:48 ` Michal Hocko
2023-11-14 16:36 ` Charan Teja Kalla
2023-11-15 14:09 ` Michal Hocko
2023-11-16 6:00 ` Charan Teja Kalla
2023-11-16 12:55 ` Michal Hocko
2023-11-17 5:43 ` Charan Teja Kalla
2024-01-25 16:36 ` Zach O'Keefe
2024-01-26 10:47 ` Charan Teja Kalla
2024-01-26 10:57 ` Michal Hocko
2024-01-26 22:51 ` Zach O'Keefe
2024-01-29 15:04 ` Michal Hocko
2024-02-06 23:15 ` Zach O'Keefe
2026-09-02 16:49 ` Yosry Ahmed
2026-09-02 16:56 ` Yosry Ahmed
2026-09-03 7:27 ` Michal Hocko
2026-09-03 14:03 ` Yosry Ahmed
2026-09-04 11:21 ` Michal Hocko [this message]
2026-09-04 16:09 ` Yosry Ahmed
2026-09-04 16:27 ` Michal Hocko
2026-09-04 16:35 ` Yosry Ahmed
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=apqppFukssaAQz3w@tiehlicka \
--to=mhocko@suse.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=quic_charante@quicinc.com \
--cc=quic_pkondeti@quicinc.com \
--cc=vbabka@suse.cz \
--cc=yosry@kernel.org \
/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
all inboxes | Powered by JetHome®