From: Joshua Hahn <joshua.hahnjy@gmail.com>
To: Gregory Price <gourry@gourry.net>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Alistair Popple <apopple@nvidia.com>,
Byungchul Park <byungchul@sk.com>,
David Hildenbrand <david@redhat.com>,
Matthew Brost <matthew.brost@intel.com>,
Rakie Kim <rakie.kim@sk.com>,
Ying Huang <ying.huang@linux.alibaba.com>,
Zi Yan <ziy@nvidia.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
kernel-team@meta.com
Subject: Re: [PATCH 2/2] mm/mempolicy: Skip extra call to __alloc_pages_bulk in weighted interleave
Date: Fri, 27 Jun 2025 09:13:18 -0700 [thread overview]
Message-ID: <20250627161318.1898633-1-joshua.hahnjy@gmail.com> (raw)
In-Reply-To: <aF4d8YcGbfTktnu6@gourry-fedora-PF4VCD3F>
On Fri, 27 Jun 2025 00:28:33 -0400 Gregory Price <gourry@gourry.net> wrote:
Hi Gregory,
Hope you are doing well : -) Thanks for the review!
> On Thu, Jun 26, 2025 at 01:09:34PM -0700, Joshua Hahn wrote:
> > Currently, alloc_pages_bulk_weighted_interleave can make up to nr_node_ids+1
> > calls to __alloc_pages_bulk. The additional allocation can happen if the
> > previous call to this function finished the weighted round robin allocation
> > partially on a node. To make up for this, the next time this function is
> > called, an extra allocation is made to finish cleanly on the node boundaries
> > before performing the weighted round-robin cycles again.
> >
>
> task->il_weight can be operated on by other weighted_interleave
> functions in mempolicy, so it's not just
> alloc_pages_bulk_weighted_interleave that affects this.
This is true, and I think that's what makes testing this part of the code
tricky. I'll elaborate more below.
> Observations here are still true, just a correction for clarity.
>
> i.e.:
>
> The additional allocation happens for the current il_node/il_weight.
>
> I *think* I did it this way just because it was easier to reason about
> the two chunks separately. So I don't see a reason not to improve this.
> I will say that, at least at the time, I took the core math and
> validated the edge conditions in a separate program.
>
> If you get it wrong in the kernel, you'd either fail to allocate - or more
> likely just get the wrong distribution of pages. The latter is
> non-obvious unless you go looking for it, so it might be good to at
> least add this test result in the change log. It's hard to write this
> in LTP or kernel selftest unfortunately.
I think so too : -(
One test that I wanted to do while developing this feature was to see if
I could figure out how many pages are really allocated from each node. The
difficulty in doing this (as you pointed out above) is that because there are
other ways that move the round robin forward (without necessarily calling the
bulk alloc function), it's hard to directly attribute the page allocations.
If this was the only place that we were modifying these values, then a
correctness check would be equivalent to just adding a printk of each node
and how many pages were allocated on it, then adding all the numbers up to
see if it matches the weight ratios in sysfs.
So I think I will do what you did as well -- I think that performing some
tests, at least on the edge cases in a separate program will help give
some confidence that the code works as intended. I'll also continue to think
about if there are better ways to be testing this instead.
Thanks again for reviewing this, have a great day!
Joshua
Sent using hkml (https://github.com/sjp38/hackermail)
next prev parent reply other threads:[~2025-06-27 16:13 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-26 20:09 [PATCH 0/2] mm/mempolicy: Cleanup and optimization for " Joshua Hahn
2025-06-26 20:09 ` [PATCH 1/2] mm/mempolicy: Simplify weighted interleave bulk alloc calculations Joshua Hahn
2025-06-26 21:51 ` David Hildenbrand
2025-06-27 4:31 ` Gregory Price
2025-06-27 7:38 ` Rakie Kim
2025-06-27 7:45 ` Oscar Salvador
2025-06-26 20:09 ` [PATCH 2/2] mm/mempolicy: Skip extra call to __alloc_pages_bulk in weighted interleave Joshua Hahn
2025-06-27 4:28 ` Gregory Price
2025-06-27 16:13 ` Joshua Hahn [this message]
2025-06-30 15:39 ` Joshua Hahn
2025-06-30 20:05 ` Kees Bakker
2025-06-30 20:21 ` Joshua Hahn
2025-06-30 22:35 ` Andrew Morton
2025-06-30 23:01 ` 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=20250627161318.1898633-1-joshua.hahnjy@gmail.com \
--to=joshua.hahnjy@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=byungchul@sk.com \
--cc=david@redhat.com \
--cc=gourry@gourry.net \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=matthew.brost@intel.com \
--cc=rakie.kim@sk.com \
--cc=ying.huang@linux.alibaba.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