linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Joshua Hahn <joshua.hahnjy@gmail.com>
To: Daniel Palmer <daniel@0x0f.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	mm-commits@vger.kernel.org
Subject: Re: [GIT PULL] MM updates for 6.19-rc1
Date: Thu, 11 Dec 2025 14:59:46 -0800	[thread overview]
Message-ID: <20251211225947.822866-1-joshua.hahnjy@gmail.com> (raw)
In-Reply-To: <CAFr9PX=_HaM3_xPtTiBn5Gw5-0xcRpawpJ02NStfdr0khF2k7g@mail.gmail.com>

On Thu, 11 Dec 2025 20:12:18 +0900 Daniel Palmer <daniel@0x0f.com> wrote:

> Hi Andrew,
> 
> On Thu, 4 Dec 2025 at 14:29, Andrew Morton <akpm@linux-foundation.org> wrote:
> >       mm/page_alloc: prevent reporting pcp->batch = 0
> 
> I think, maybe, the following part of this patch broke nommu.
> 
> -       new_batch = max(1, zone_batchsize(zone));
> +       new_batch = zone_batchsize(zone);
> 
> Before this change on nommu zone_batchsize() returns 0 but the max()
> changes it to 1. Now it'll stay as 0 and anywhere that depends on it
> not being 0 won't work?

Hi Daniel,

Thank you for taking a look at this and finding that this was the source of
the deadlock. I took a look, it's definitely an issue. The problem is that
the patch gets rid of the max(1, zone_batchsize()) and handles the MMU case
by ensuring zone_batchsize never returns a value less than 1, but the
NOMMU case always returns 0.

I think your solution below works. I've also come up with a simler workaround
which doesn't change drain_pages_zone:

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index d0f026ec10b6..9d638697cec8 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5919,7 +5919,7 @@ static int zone_batchsize(struct zone *zone)
         * recycled, this leads to the once large chunks of space being
         * fragmented and becoming unavailable for high-order allocations.
         */
-       return 0;
+       return 1;
 #endif
 }

Would this be enough? Then we don't have to worry about handling zero values
from the callsites for NOMMU machines as well. But this has the opposite problem
that I was initially trying to fix, which is that NOMMU machines will now
report a batchsize of 1 in zone_pcp_init and print it out to dmesg, which
may be confusing for NOMMU users who expect there to be no batchsize. So
it totally makes sense for me to drop my original patch completely as well.
I'm not a NOMMU user so I am hoping to receive some feedback from folks who do
who can chime in on which approach is better.

> I'm seeing a deadlock on nommu:
> 
> https://lore.kernel.org/lkml/20251211102607.2538595-1-daniel@thingy.jp/

I would also like to take this opportunity to ask any NOMMU experts out there
about the apparent disagreement between the comment in zone_batchsize under the
NOMMU case, which suggests that NOMMU is harmed by batched freeing:

	/* The deferral and batching of frees should be suppressed under NOMMU
	 * conditions.

And returns 0 here which makes sense, only to artificially set it to 1 via
the max() later on and still do batching anyways by
<< CONFIG_PCP_BATCH_SCALE_MAX.

Thank you Daniel again for helping root cause this. Hopefully this fix works
to fix the deadlock you mentioned! Have a great day : -)
Joshua


  reply	other threads:[~2025-12-11 22:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-04  5:29 Andrew Morton
2025-12-05 21:56 ` Linus Torvalds
2025-12-06  2:54   ` Jason Gunthorpe
2025-12-06  3:43     ` Linus Torvalds
2025-12-05 22:14 ` pr-tracker-bot
2025-12-11 11:12 ` Daniel Palmer
2025-12-11 22:59   ` Joshua Hahn [this message]
2025-12-12  1:53     ` 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=20251211225947.822866-1-joshua.hahnjy@gmail.com \
    --to=joshua.hahnjy@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=daniel@0x0f.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mm-commits@vger.kernel.org \
    --cc=torvalds@linux-foundation.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