From: Vlastimil Babka <vbabka@suse.cz>
To: Joshua Hahn <joshua.hahnjy@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Chris Mason <clm@fb.com>, Kiryl Shutsemau <kirill@shutemov.name>,
Brendan Jackman <jackmanb@google.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@suse.com>,
Suren Baghdasaryan <surenb@google.com>, Zi Yan <ziy@nvidia.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
kernel-team@meta.com
Subject: Re: [PATCH v3 2/3] mm/page_alloc: Batch page freeing in decay_pcp_high
Date: Fri, 10 Oct 2025 14:48:45 +0200 [thread overview]
Message-ID: <63bbcf0d-5a02-4eba-8fc1-680eeb4e09cb@suse.cz> (raw)
In-Reply-To: <20251002204636.4016712-3-joshua.hahnjy@gmail.com>
On 10/2/25 22:46, Joshua Hahn wrote:
> It is possible for pcp->count - pcp->high to exceed pcp->batch by a lot.
> When this happens, we should perform batching to ensure that
> free_pcppages_bulk isn't called with too many pages to free at once and
> starve out other threads that need the pcp lock.
... or the zone lock.
> Since we are still only freeing the difference between the initial
> pcp->count and pcp->high values, there should be no change to how many
> pages are freed.
>
> Suggested-by: Chris Mason <clm@fb.com>
> Suggested-by: Andrew Morton <akpm@linux-foundation.org>
> Co-developed-by: Johannes Weiner <hannes@cmpxchg.org>
> Signed-off-by: Joshua Hahn <joshua.hahnjy@gmail.com>
Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
> ---
> mm/page_alloc.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index b9fc357d2d48..f525f197c5fd 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -2559,7 +2559,7 @@ static int rmqueue_bulk(struct zone *zone, unsigned int order,
> */
> bool decay_pcp_high(struct zone *zone, struct per_cpu_pages *pcp)
> {
> - int high_min, to_drain, batch;
> + int high_min, to_drain, to_drain_batched, batch;
> bool todo = false;
>
> high_min = READ_ONCE(pcp->high_min);
> @@ -2577,11 +2577,14 @@ bool decay_pcp_high(struct zone *zone, struct per_cpu_pages *pcp)
> }
>
> to_drain = pcp->count - pcp->high;
> - if (to_drain > 0) {
> + while (to_drain > 0) {
> + to_drain_batched = min(to_drain, batch);
> spin_lock(&pcp->lock);
> - free_pcppages_bulk(zone, to_drain, pcp, 0);
> + free_pcppages_bulk(zone, to_drain_batched, pcp, 0);
> spin_unlock(&pcp->lock);
> todo = true;
> +
> + to_drain -= to_drain_batched;
> }
>
> return todo;
next prev parent reply other threads:[~2025-10-10 12:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-02 20:46 [PATCH v3 0/3] mm/page_alloc: Batch callers of free_pcppages_bulk Joshua Hahn
2025-10-02 20:46 ` [PATCH v3 1/3] mm/page_alloc/vmstat: Simplify refresh_cpu_vm_stats change detection Joshua Hahn
2025-10-10 12:44 ` Vlastimil Babka
2025-10-10 18:30 ` SeongJae Park
2025-10-02 20:46 ` [PATCH v3 2/3] mm/page_alloc: Batch page freeing in decay_pcp_high Joshua Hahn
2025-10-10 12:48 ` Vlastimil Babka [this message]
2025-10-02 20:46 ` [PATCH v3 3/3] mm/page_alloc: Batch page freeing in free_frozen_page_commit Joshua Hahn
2025-10-10 13:37 ` Vlastimil Babka
2025-10-10 15:13 ` Joshua Hahn
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=63bbcf0d-5a02-4eba-8fc1-680eeb4e09cb@suse.cz \
--to=vbabka@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=clm@fb.com \
--cc=hannes@cmpxchg.org \
--cc=jackmanb@google.com \
--cc=joshua.hahnjy@gmail.com \
--cc=kernel-team@meta.com \
--cc=kirill@shutemov.name \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=surenb@google.com \
--cc=ziy@nvidia.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
Powered by JetHome