From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA82F4EBAE7; Wed, 16 Sep 2026 11:39:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789558783; cv=none; b=PyJCtjJNuU+gCI6uHOSvUqUpiwX2vsy5PqYENL0ueAmQXIr2Y7b6QGA6PIpLN+EAQ7sOLjfAdBDp80UhNlyn/afMxBi5w5z/kfvZhH6aanzSSJw6xsuGtFF6YK1qI/0QRibZFE/Sg3zDyNfAxnyZ9BagFqjdi5S+/35GU3GrjiY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789558783; c=relaxed/simple; bh=v5sttW6YkzqfhQkXivVTyjg8xZHwuXgutc5IID/fnfU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=SNeXv6NHnbyhry0C6fSVfNes5XSUOe/3L4ZSBrBKITH6YI/LdqYDUjHKlcNccvpgCoL3oIuoOSEtJERs4gbYg3sMWgwDwptDZN6JkBSavmD9m1KMkFtNymi8vsUOPsz5J8t7owD3BiuDaF1cxdAFvmcuCmKlTEyyC9MdGuBCkMc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KJyruiO5; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KJyruiO5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A404A1F000FF; Wed, 16 Sep 2026 11:39:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789558771; bh=PwPvpxGrzEMSl2UNY8taOVvejOczhuAnj7LbVVW1ppU=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=KJyruiO5wrKXPzdDFVqClE0Ty9ULE/hZ5397ZAAciwaIzSVYco6qRvg6/MDxgtKC0 5Orh+cdNNSyRg9VM6hQ/zX41j+heGbSMRTvdr4Bf6A683yZM+Uct4pWu7p8C/TZAod oecbogdsDV6kKQO+FXHf05kUU+o/mbKfsVJUibf5nEU/8bF6feZlVbDOPQhBrdkCNq 4CJaECSLIEwat0TrrDvjO5jSd0KNNyHgMQm3amCX92l6XCO0ns5Hn/UVCMAoEtXizc 1+68a2ZkufZRdTVOGMQFm/423/2+A9Yl8H7Yx+w2fcLCxww5d6OnBDIserveBUvhlz 4/duiZamVsrQA== Message-ID: <6cfc9b2b-f27d-4f06-ac76-bba64b5c1668@kernel.org> Date: Wed, 16 Sep 2026 13:39:27 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] mm/page_alloc: do not boost watermarks in kdump capture kernels Content-Language: en-US To: Yuanhe Shu , akpm@linux-foundation.org, mgorman@techsingularity.net, linux-mm@kvack.org Cc: surenb@google.com, mhocko@suse.com, brendan.jackman@linux.dev, hannes@cmpxchg.org, ziy@nvidia.com, linux-kernel@vger.kernel.org, stable@vger.kernel.org, henry.willard@oracle.com, david@kernel.org References: <20260916112545.3707893-1-xiangzao@linux.alibaba.com> From: "Vlastimil Babka (SUSE)" Autocrypt: addr=vbabka@kernel.org; keydata= xsFNBFZdmxYBEADsw/SiUSjB0dM+vSh95UkgcHjzEVBlby/Fg+g42O7LAEkCYXi/vvq31JTB KxRWDHX0R2tgpFDXHnzZcQywawu8eSq0LxzxFNYMvtB7sV1pxYwej2qx9B75qW2plBs+7+YB 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WvX8qrvqYapVbZ+9KqT74FsuB0Ya9uXwgBF2Q6cRuETZk5vqaqKxzqoQZCO8AOz/58j6O 2RHNy/mZEN+7tJ5Tsq42zVJ4jxsT8b9YplavCMsnBgDeRWhcbYhCyttoL7nYISyWg4kQYZ/P wIV3OuNv2f8iKYsxNsRuClOAF82+gvqOy1/1pprFjy8uo2pkoOrb63aOP3vO5VHnRKgra6dq NcaZ+c6J4H+nEJGi2SkHAUJz5oBzuThvPudLvPA/SK8sKoM01IRxSihev/S/5WLazXB1PGem OCbvzC1IjWJJraxiDJ5IygokapUa2RP7+WBR22skQ3SSl6G107QgWKSyTOGWEaRmV53vxQLV jXuCmzSSasTL60zq5yGrT4/DYQVSNEUiUbG4pYekxJujNeEDkUlky0Y= In-Reply-To: <20260916112545.3707893-1-xiangzao@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 9/16/26 13:25, Yuanhe Shu wrote: > A watermark boost is not confined to one watermark: wmark_pages() adds > it to min, low and high alike, so every watermark check sees it, > including should_reclaim_retry() and the last ditch ALLOC_WMARK_HIGH > attempt in __alloc_pages_may_oom(). Once the boost exceeds the memory > still free the allocator gives up and invokes the OOM killer, and a > capture kernel that is still booting has nothing to kill: the boot > panics and the vmcore is lost. > > Seen on an arm64 machine with 64K pages, CONFIG_PAGE_BLOCK_MAX_ORDER=10 > (pageblock = 64M) and crashkernel=512M, running a distribution kernel > based on 7.0.14. A high order UNMOVABLE allocation fell back to a > MOVABLE pageblock while the capture kernel was still in do_initcalls(): > > Node 0 DMA free:68096kB boost:65536kB min:68160kB > low:68800kB high:69440kB managed:479168kB > Out of memory and no killable processes... > Kernel panic - not syncing: System is deadlocked on memory > > The zone was not short of memory. Subtracting the boost gives > min:2624kB low:3264kB high:3904kB, so the 68096kB still free sat 17 > times above the high watermark and the allocator would not even have > entered its slow path. The boost supplied 65536kB of the 68160kB min > and by itself put the zone 64kB under water. It is that large because > boost_watermark() clamps it with max(pageblock_nr_pages, max_boost); > watermark_boost_factor alone would have allowed 5824kB. > > Commit 14f69140ff9c ("mm: limit boost_watermark on small zones") already > tried to protect capture kernels, but it infers them from the zone size > and skips the boost only below four pageblocks. arm64 64K pageblocks > were 512M then, so the guard reached zones up to 2G; > CONFIG_PAGE_BLOCK_MAX_ORDER can cap them at 64M, which shrinks the guard > to zones under 256M and lets this 468M zone through. > > kdump is a property of the kernel, not of the zone, so test for it > directly. A capture kernel exits within seconds and never uses the > fragmentation avoidance the boost buys. Normal kernels are unaffected: > the size based check still covers their genuinely tiny zones. > > Passing sysctl.vm.watermark_boost_factor=0 to the capture kernel does > not cover this window: sysctl.* parameters are written through procfs > by do_sysctl_args(), which runs after do_initcalls() where the panic > above happened, and watermark_boost_factor has no early_param of its > own. > > Fixes: 1c30844d2dfe ("mm: reclaim small amounts of memory when an external fragmentation event occurs") > Cc: stable@vger.kernel.org # v5.0 > Cc: Henry Willard > Cc: David Hildenbrand > Signed-off-by: Yuanhe Shu Reviewed-by: Vlastimil Babka (SUSE) > --- > Changes in v2: > - Drop the stale kdump capture kernel mention from the small-zone > comment in boost_watermark(): capture kernels now return earlier. > (Vlastimil Babka) > > v1: https://lore.kernel.org/r/20260914131142.2984623-1-xiangzao@linux.alibaba.com > > Build tested with CONFIG_CRASH_DUMP=y and =n. > > Tested on the affected machine with the original crashkernel=512M and > capture kernel command line. Without this patch both capture boots > panicked at 7.9s inside do_initcalls() with a 64M boost in place. With > it, and with boost_watermark() instrumented, every call was suppressed - > including those inside do_initcalls(), where the panics happened - free > memory came down to within 64kB of the min watermark, where a single > boost would have put it 65472kB under, and the dump completed. > --- > mm/page_alloc.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 12fac9084c48..f52ed7d2cd34 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -37,6 +37,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -2178,10 +2179,17 @@ static inline bool boost_watermark(struct zone *zone) > > if (!watermark_boost_factor) > return false; > + > + /* > + * A kdump capture kernel exits before a boost can pay off, while > + * the raised watermark can exceed the memory left for the dump. > + */ > + if (is_kdump_kernel()) > + return false; > + > /* > * Don't bother in zones that are unlikely to produce results. > - * On small machines, including kdump capture kernels running > - * in a small area, boosting the watermark can cause an out of > + * On small machines, boosting the watermark can cause an out of > * memory situation immediately. > */ > if ((pageblock_nr_pages * 4) > zone_managed_pages(zone))