[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3d5fc5eb4ec225b693c59fb1b888c5161794f869.camel@surriel.com>
Date: Wed, 17 Sep 2025 11:17:38 -0400
From: Rik van Riel <riel@...riel.com>
To: Frank van der Linden <fvdl@...gle.com>, akpm@...ux-foundation.org,
muchun.song@...ux.dev, linux-mm@...ck.org, linux-kernel@...r.kernel.org
Cc: hannes@...xchg.org, david@...hat.com, roman.gushchin@...ux.dev
Subject: Re: [RFC PATCH 09/12] mm/cma: introduce CMA balancing
On Mon, 2025-09-15 at 19:51 +0000, Frank van der Linden wrote:
> A longstanding problem with having a lot of CMA pageblocks in
> the system (through hugetlb_cma), is that this limits the amount
> of memory that the kernel can use for its allocations. Kernel
> allocations are unmovable and can not come from CMA pageblocks.
>
> This can lead to situations where kernel allocations cause OOMs,
> when in fact there might still enough memory available.
We are seeing this situation happen even when the
CMA region is relatively small.
When a system has multiple cgroups, and has been
reclaiming the non-CMA memory for a particular cgroup
for long enough, at some point essentially all the
remaining reclaimable memory for that cgroup can be
in CMA, and you get early OOM kills.
>
> To counter this issue, introduce interfaces to explicitly
> move pages in to CMA areas. The number of pages moved
> depends on cma_first_limit. It will use that percentage to
> calculate the target number of pages that should be moved.
>
I've been working on some code for this situation
as well, but your code seems to handle a lot more
corner cases than the small hack I was working on.
I hope this issue can be fixed upstream soon-ish :)
> A later commit will call one of these interfaces to move pages
> to CMA if needed, after CMA-allocated hugetlb pages have been
> freed.
Is that the right place?
The CMA region will also be used by regular 4kB
pages and 2MB THPs, and we may also need to do
CMA balancing if the cgroup is up against its memory
limit, needs to do a kernel allocation, but its
remaining freeable memory is in movable allocations
in the CMA region.
I have the hook for migrating pages to CMA on the
page reclaim side, when the reclaim code notices
that it is doing direct reclaim on behalf of a
non-movable (kernel) allocation, but it has been
reclaiming a bunch of CMA pages.
Hugetlb is not the only case triggering this issue.
>
> Signed-off-by: Frank van der Linden <fvdl@...gle.com>
>
Reviewed-by: Rik van Riel <riel@...riel.com>
--
All Rights Reversed.
Powered by blists - more mailing lists