From: Joshua Hahn <joshua.hahnjy@gmail.com>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Chris Mason <clm@fb.com>, Kiryl Shutsemau <kirill@shutemov.name>,
"Liam R. Howlett" <Liam.Howlett@oracle.com>,
Brendan Jackman <jackmanb@google.com>,
David Hildenbrand <david@redhat.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
Michal Hocko <mhocko@suse.com>, Mike Rapoport <rppt@kernel.org>,
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 v5 0/3] mm/page_alloc: Batch callers of free_pcppages_bulk
Date: Tue, 14 Oct 2025 12:17:27 -0700 [thread overview]
Message-ID: <20251014191727.788875-1-joshua.hahnjy@gmail.com> (raw)
In-Reply-To: <6d62386c-242a-4735-add3-fee9c6e0ba96@suse.cz>
On Tue, 14 Oct 2025 19:54:28 +0200 Vlastimil Babka <vbabka@suse.cz> wrote:
> On 10/14/25 16:50, Joshua Hahn wrote:
> > Changelog
> > =========
> > v4 --> v5:
> > - Wordsmithing
> > - Patches 1/3 and 2/3 were left untouched.
> > - Patch 3/3 no longer checks for the to_free == 0 case. It also now checks
> > for pcp->count > 0 as the condition inside the while loop, and the early
> > break checks for the opposite condition. Note that both to_free and
> > pcp->count can become negative due to high-order pages that are freed, so
> > we must check for (to_free <= 0 || pcp->count <= 0), instead of just
> > checking for == 0.
Hello Vlastimil,
> I don't see how that's possible?
> - to_free is decremented by to_free_batched = min(to_free, batch); so it
> can't go negative.
> - pcp->count indeed decrements by nr_pages but it should be exactly zero
> once pcp becomes empty. It's true that internally in free_pcppages_bulk()
> the count parameter (where we pass to_free_batched) can go negative, but
> that doesn't affect to_free_batched in the caller free_frozen_page_commit().
> So testing for <= is unnecessary and only looks weird?
You are totally right. For the first point, that must have been a slip up in
my mind, for some reason, I thought it could go negative after looking at
free_pcppages_bulk, but it obviously can't since we are taking the min as you
pointed out.
The same goes for pcp->count, I realize that it cannot become negative. I think
I was being too careful without really thinking too hard about what I was
protecting against. I'll send in a fixlet in 3/3 which should hopefully be
folded in.
Sorry about these mistakes, I think they could have been avoided had I
thought more about the code. I hope you have a great day!
Joshua
prev parent reply other threads:[~2025-10-14 19:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-14 14:50 Joshua Hahn
2025-10-14 14:50 ` [PATCH v5 1/3] mm/page_alloc/vmstat: Simplify refresh_cpu_vm_stats change detection Joshua Hahn
2025-10-14 14:50 ` [PATCH v5 2/3] mm/page_alloc: Batch page freeing in decay_pcp_high Joshua Hahn
2025-10-14 14:50 ` [PATCH v5 3/3] mm/page_alloc: Batch page freeing in free_frozen_page_commit Joshua Hahn
2025-10-14 19:28 ` Joshua Hahn
2025-10-14 20:45 ` Vlastimil Babka
2025-10-14 17:54 ` [PATCH v5 0/3] mm/page_alloc: Batch callers of free_pcppages_bulk Vlastimil Babka
2025-10-14 19:17 ` Joshua Hahn [this message]
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=20251014191727.788875-1-joshua.hahnjy@gmail.com \
--to=joshua.hahnjy@gmail.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=clm@fb.com \
--cc=david@redhat.com \
--cc=hannes@cmpxchg.org \
--cc=jackmanb@google.com \
--cc=kernel-team@meta.com \
--cc=kirill@shutemov.name \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=mhocko@suse.com \
--cc=rppt@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
--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