From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yx1-f52.google.com (mail-yx1-f52.google.com [74.125.224.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9EC251C695 for ; Wed, 17 Dec 2025 05:16:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765948619; cv=none; b=A+NlszuKEYBvds3P2i36KPomAd7YtoClhhZGgABJAuKR51sqaT6pPPe6Fzd7EnVwfDdl/neXPO7Tk1NcjucRLoNJmjsOLXznWhFRI22UyigEKH/eRP0kRiI4vWo71rI6PKMq9pjdL6dn4HIdPohcirkq71j0xVLLWu4P5WFr45Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765948619; c=relaxed/simple; bh=/jlPoiqgi6X9ie2iedDP5clCEEtvTwbUswfK2n0ew3Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kG9CFwq7iEHiqowuU/YcKJHRgrGAUwtRzL+W9u9MGBXI1yrjfx1BSzyTQZYq6Yd5ItoNI3HEFnriFwVrQQYwz209ieczmocEgqC7dhc37+XwSmzE09N8mm/Pf/Rq3lETobEN1edBdPnoFBTDufVZN/uEl0pMl6tqFPEXoQFwLkU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=H2JTgASe; arc=none smtp.client-ip=74.125.224.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="H2JTgASe" Received: by mail-yx1-f52.google.com with SMTP id 956f58d0204a3-644795bf5feso5040527d50.2 for ; Tue, 16 Dec 2025 21:16:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765948616; x=1766553416; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=e3U4fucPIwa5C3A7mTN8iePIKa9pv0/tHUusJYkp2+Y=; b=H2JTgASeV/dDUfJv9DoNvW3l8mjD6gm0pyrMKJKkJsZpvIWp+8biQVJlnzQq5HfBCc CFmtK5NNWMM/4uLQrX0EEXUiVSZIleUQSD1yIrb592ivHLUPXF7sEJ1+TFWplN30vgWG jO1xU/VQwf+db1euT3UKOks7rvT1GJrLhhICXlfWMR4keIQx+FyVZNBCs7HDow4B2K0i 4r+wVtvyO8xNH7The4b0cYM0/UlvT9rsqZ8iHRYltOX2CcaI4yXJPT64jLaoOBHDQMwF GGywWpi1iO49MrT4eDLx/JJyzn2o1Va1CaT9fvYbJsqry1FwKgYdjPAABiKkphumoEWl wtug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765948616; x=1766553416; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=e3U4fucPIwa5C3A7mTN8iePIKa9pv0/tHUusJYkp2+Y=; b=hwsj9rZrq/oN7p9BeBVbPzIfHw341vyzlyDTnLP8iZgAeqQYUM55N5i6NWopn7Z+Nf I5fFpHoAV/royh1O4Kq950UDSIyq1Luy11o6aHLXqGGRUwqORWmavniDowOAr9ZmPc9U TffSuObeLW1g7qRd+OV89HFk1spMf44mVSh0OPcytopLDPVpzETPZC6hyOMg7LBD+aYr pNAf5O71hLJvMD4hk/5p5jrGKGpH/6FjUxazgLsTqAjtogYl3tI/4whbsQ9K+oNDXM/l qGknLhjbLw+M+epV+lVf3z/npF3Iq5q11zGHINUUmmRHQFIeEVwX8Xb0DfBhmTHU+kkc HI1Q== X-Forwarded-Encrypted: i=1; AJvYcCVkR8SYXmH41O65dApP2HAtE1nO92Oz7X8wwB+l9YcPe6VDtHPKEf+nL1YgLktgJ1Kk5cBkMomSsIeXV4I=@vger.kernel.org X-Gm-Message-State: AOJu0Yw71qWJEVFSiXYVaUzGdnbmC7TVf9uoaGWkFKE+E92oDRn8ctf8 g2CFG2mlJHE+LJ6I+sr9wV9peU8uktzRyfnHAdQajSf7soo/fqMPyDDLBeAM0/43CZQ= X-Gm-Gg: AY/fxX4QmJfMzaKk4viYLadzX0YBltskPKwx2lIbWvYZx7i2OPXQdSiEqBnkxCZFyyF KfbGNU72zG8HyBPFgoGXYL+RD3I5vhpoJ8PdnwRLUJdTY30FZtm1eAMGQNXUHCNuyGOjUHEpiOi YaP9hcllMT8Qh4OnjRMkEcrSNGMoz8zLpDXMPES6kNcnTAAtMGb5QTd2fupyYCNQDOd32Lh4YWa yC5GnPMddbBaOoOW+4QV98Iavs1OeHpfZpqgG6Xo8C8PJEx+pk6wbk/1GFAzzm0nWfPWP4eok/5 UGwtBIFS7M5MWLlWFatGOLkVPGffUPbqqPbs9Ct07lCvOqHZi6wykU2/9iSd3bEd2NcGkhqIWwf KOmHiPZyrC6eH4NAieH/dPZCHN3iYF1hpiIg71+mXvtcV9Yi2tgzpRmYll44w/OdMefejQMStO5 dItpn/957LoYvoxNpjgWFjdw== X-Google-Smtp-Source: AGHT+IHl6JmRY4pmU+6aPgmZru5eursIsfwMpCPv4j6lmgmMPRhAD6OhtZZX534fHOXjHyU3LGVXxw== X-Received: by 2002:a05:690e:16a0:b0:644:7b59:4216 with SMTP id 956f58d0204a3-645555cda86mr12968997d50.3.1765948616522; Tue, 16 Dec 2025 21:16:56 -0800 (PST) Received: from localhost ([2a03:2880:25ff:52::]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-64477dab686sm8555903d50.16.2025.12.16.21.16.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Dec 2025 21:16:56 -0800 (PST) From: Joshua Hahn To: Guenter Roeck Cc: Andrew Morton , Dave Hansen , Brendan Jackman , Johannes Weiner , Michal Hocko , Suren Baghdasaryan , Vlastimil Babka , Zi Yan , linux-kernel@vger.kernel.org, linux-mm@kvack.org, kernel-team@meta.com, Geert Uytterhoeven , linux-m68k@lists.linux-m68k.org Subject: Re: [PATCH v2 2/2] mm/page_alloc: Prevent reporting pcp->batch = 0 [mcf5208evb boot failure] Date: Tue, 16 Dec 2025 21:16:54 -0800 Message-ID: <20251217051654.80355-1-joshua.hahnjy@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <42143500-c380-41fe-815c-696c17241506@roeck-us.net> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Tue, 16 Dec 2025 13:47:03 -0800 Guenter Roeck wrote: > Hi, > > On Thu, Oct 09, 2025 at 12:29:31PM -0700, Joshua Hahn wrote: > > zone_batchsize returns the appropriate value that should be used for > > pcp->batch. If it finds a zone with less than 4096 pages or PAGE_SIZE > > > 1M, however, it leads to some incorrect math. > > > > In the above case, we will get an intermediary value of 1, which is then > > rounded down to the nearest power of two, and 1 is subtracted from it. > > Since 1 is already a power of two, we will get batch = 1-1 = 0: > > > > batch = rounddown_pow_of_two(batch + batch/2) - 1; > > > > A pcp->batch value of 0 is nonsensical. If this were actually set, then > > functions like drain_zone_pages would become no-ops, since they could > > only free 0 pages at a time. > > > > Of the two callers of zone_batchsize, the one that is actually used to > > set pcp->batch works around this by setting pcp->batch to the maximum > > of 1 and zone_batchsize. However, the other caller, zone_pcp_init, > > incorrectly prints out the batch size of the zone to be 0. > > > > This is probably rare in a typical zone, but the DMA zone can often have > > less than 4096 pages, which means it will print out "LIFO batch:0". > > > > Before: [ 0.001216] DMA zone: 3998 pages, LIFO batch:0 > > After: [ 0.001210] DMA zone: 3998 pages, LIFO batch:1 > > > > Instead of dealing with the error handling and the mismatch between the > > reported and actual zone batchsize, just return 1 if the zone_batchsize > > is 1 page or less before the rounding. > > > > Signed-off-by: Joshua Hahn > > With this patch in the tree, the qemu 'mcf5208evb' machine fails to boot > with memory errors such as > > S01syslogd: page allocation failure: order:7, mode:0xcc0(GFP_KERNEL), nodemask=(null) > CPU: 0 UID: 0 PID: 34 Comm: S01syslogd Not tainted 6.19.0-rc1 #1 NONE > Stack from 407d7ce0: > 407d7ce0 403df960 403df960 00000000 00000001 00000007 40027c60 403df960 > 400c06be 00000cc0 00000001 407d7d7e 400bf614 407d7d34 403df3ba 407d7d14 > 407d7db8 400c0e5c 00000cc0 00000000 403df3ba 00000007 00000007 00000cc0 > 000d8000 00000018 0000006c 00000001 00000000 40fe6640 00000000 40fe81e4 > 403ffa40 4085eff4 00000000 00000400 00000000 001008c0 00000000 40854041 > f4fe0000 00004041 f4fe0000 00000000 00010000 403ffa40 4085ed00 4085e800 > Call Trace: [<40027c60>] dump_stack+0xc/0x10 > [<400c06be>] warn_alloc+0xdc/0x1bc > [<400bf614>] get_page_from_freelist+0x0/0xfa6 > [<400c0e5c>] __alloc_frozen_pages_noprof+0x6be/0x8be > [<400c1358>] get_free_pages_noprof+0x16/0x3e > > Reverting this patch fixes the problem. Hi Guenter, Thank you for the report. Daniel Palmer has identified an issue on NOMMU systems, and I think this is caused by the same issue. It seems like mcf5208evb is also NOMMU (arch/m68k/Kconfig.cpu shows config M520x depends on !MMU), so I imagine this is the same issue that was reported. Andrew let me know that the commit has already been committed to mainline so I'll be sending up a fix shortly. Sorry about the problem, and thank you again for reporting it. I hope you have a great day! Joshua