From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-188.mta0.migadu.com (out-188.mta0.migadu.com [91.218.175.188]) (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 7644B22068F for ; Mon, 5 Jan 2026 06:38:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767595131; cv=none; b=gnFJW4YncMQG4wnRoiCFK1Q86Mi4QiJ2JQtfpIHDNqwOAISUVVi4DJUABa7PDb/yvZZ+yrfunJJXmrONxVCAWkeRUEHDyIKCIEYdJQIwAbdpTETczdlQjqCYMrObOQE5z0gcAroEbz9jUq2470BVkrSZ3LZzNa/mSmGtN5QYLSI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767595131; c=relaxed/simple; bh=g8zc6KIcQ5qdDM1jqh2zIXuYcdp3vu9CREWG9Yyo1ZQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DzTHz2E4BcxVYzE0/vBH2ZcNAipTYeb6534C4MHRgMEJsXFbYf7hbUzi9AIQXNLj4iis5Dbxw085U2w9gipIYF0UgGrKiFaZjuueKWppXCSNXNleTJZY+E1EU77djnl8grZuDxYkjJPKb1AhKR6ov2DlXwQngYVc+g9D7JzXCww= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=og007XNo; arc=none smtp.client-ip=91.218.175.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="og007XNo" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1767595125; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6GSWauQ+JqQj2YxH5/FYfC8pu4G5J3rlHrbtcyoAwBI=; b=og007XNo1/mr8GtR9T1LkxWzw62ZWQ0jKZd6IaqP7454/WX0ocFgdaBJ4eREIDDcMYvaeA MKWAASCu+WCm1JLcYP8/aJ+aeZU7BGOWaLzSOqgSqZIt321u/JvN58bFNROLNOS4CDSvqG IcHU0ay+9teJol9aJJgkx7eocYV6NTw= From: Lance Yang To: realwujing@qq.com Cc: david@kernel.org, akpm@linux-foundation.org, hannes@cmpxchg.org, jackmanb@google.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, mhocko@suse.com, surenb@google.com, vbabka@suse.cz, yuanql9@chinatelecom.cn, ziy@nvidia.com, Lance Yang Subject: Re: [PATCH 1/1] mm/page_alloc: auto-tune min_free_kbytes on atomic allocation failure Date: Mon, 5 Jan 2026 14:38:30 +0800 Message-ID: <20260105063830.15140-1-lance.yang@linux.dev> In-Reply-To: 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 X-Migadu-Flow: FLOW_OUT On Sun, 4 Jan 2026 20:26:52 +0800, wujing wrote: > Introduce a mechanism to dynamically increase vm.min_free_kbytes when > critical atomic allocations (GFP_ATOMIC, order-0) fail. This prevents > recurring network packet drops or other atomic failures by proactively > reserving more memory. Just wondering, could we adjust watermark_scale_factor instead of min_free_kbytes? Increasing min_free_kbytes directly reduces available memory, while watermark_scale_factor just makes kswapd wake up earlier for reclaim ... Seems like less side effect than min_free_kbytes :) Cheers, Lance > > The adjustment doubles min_free_kbytes upon upon failure (exponential backoff), > capped at 1% of total RAM. > > Observed failure logs: > [38535641.026406] node 0: slabs: 941, objs: 54656, free: 0 > [38535641.037711] node 1: slabs: 349, objs: 22096, free: 272 > [38535641.049025] node 1: slabs: 349, objs: 22096, free: 272 > [38535642.795972] SLUB: Unable to allocate memory on node -1, gfp=0x480020(GFP_ATOMIC) > [38535642.805017] cache: skbuff_head_cache, object size: 232, buffer size: 256, default order: 2, min order: 0 > [38535642.816311] node 0: slabs: 854, objs: 42320, free: 0 > [38535642.823066] node 1: slabs: 400, objs: 25360, free: 294 > [38535643.070199] SLUB: Unable to allocate memory on node -1, gfp=0x480020(GFP_ATOMIC) > [38535643.078861] cache: skbuff_head_cache, object size: 232, buffer size: 256, default order: 2, min order: 0 > [38535643.089719] node 0: slabs: 841, objs: 41824, free: 0 > [38535643.096513] node 1: slabs: 393, objs: 24480, free: 272 > [38535643.484149] SLUB: Unable to allocate memory on node -1, gfp=0x480020(GFP_ATOMIC) > [38535643.492831] cache: skbuff_head_cache, object size: 232, buffer size: 256, default order: 2, min order: 0 > [38535643.503666] node 0: slabs: 898, objs: 43120, free: 159 > [38535643.510140] node 1: slabs: 404, objs: 25424, free: 319 > [38535644.699224] SLUB: Unable to allocate memory on node -1, gfp=0x480020(GFP_ATOMIC) > [38535644.707911] cache: skbuff_head_cache, object size: 232, buffer size: 256, default order: 2, min order: 0 > [38535644.718700] node 0: slabs: 1031, objs: 43328, free: 0 > [38535644.725059] node 1: slabs: 339, objs: 17616, free: 317 > [38535645.428345] SLUB: Unable to allocate memory on node -1, gfp=0x480020(GFP_ATOMIC) > [38535645.436888] cache: skbuff_head_cache, object size: 232, buffer size: 256, default order: 2, min order: 0 > [38535645.447664] node 0: slabs: 940, objs: 40864, free: 144 > [38535645.454026] node 1: slabs: 322, objs: 19168, free: 383 > [38535645.556122] SLUB: Unable to allocate memory on node -1, gfp=0x480020(GFP_ATOMIC) > [38535645.564576] cache: skbuff_head_cache, object size: 232, buffer size: 256, default order: 2, min order: 0 > [38535649.655523] warn_alloc: 59 callbacks suppressed > [38535649.655527] swapper/100: page allocation failure: order:0, mode:0x480020(GFP_ATOMIC), nodemask=(null) > [38535649.671692] swapper/100 cpuset=/ mems_allowed=0-1 > > Signed-off-by: wujing > Signed-off-by: Qiliang Yuan > --- > mm/page_alloc.c | 33 +++++++++++++++++++++++++++++++++ > 1 file changed, 33 insertions(+) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index c380f063e8b7..9a24e2b6cfbf 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -30,6 +30,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -3975,6 +3976,9 @@ static void warn_alloc_show_mem(gfp_t gfp_mask, nodemask_t *nodemask) > mem_cgroup_show_protected_memory(NULL); > } > > +static void boost_min_free_kbytes_workfn(struct work_struct *work); > +static DECLARE_WORK(boost_min_free_kbytes_work, boost_min_free_kbytes_workfn); > + > void warn_alloc(gfp_t gfp_mask, nodemask_t *nodemask, const char *fmt, ...) > { > struct va_format vaf; > @@ -4947,6 +4951,10 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, > goto retry; > } > fail: > + /* Auto-tuning: trigger boost if atomic allocation fails */ > + if ((gfp_mask & GFP_ATOMIC) && order == 0) > + schedule_work(&boost_min_free_kbytes_work); > + > warn_alloc(gfp_mask, ac->nodemask, > "page allocation failure: order:%u", order); > got_pg: > @@ -7682,3 +7690,28 @@ struct page *alloc_pages_nolock_noprof(gfp_t gfp_flags, int nid, unsigned int or > return page; > } > EXPORT_SYMBOL_GPL(alloc_pages_nolock_noprof); > + > +static void boost_min_free_kbytes_workfn(struct work_struct *work) > +{ > + int new_min; > + > + /* Cap at 1% of total RAM for safety */ > + unsigned long total_kbytes = totalram_pages() << (PAGE_SHIFT - 10); > + int max_limit = total_kbytes / 100; > + > + /* Exponential increase: double the current value */ > + new_min = min_free_kbytes * 2; > + > + if (new_min > max_limit) > + new_min = max_limit; > + > + if (new_min > min_free_kbytes) { > + min_free_kbytes = new_min; > + /* Update user_min_free_kbytes so it persists through recalculations */ > + if (new_min > user_min_free_kbytes) > + user_min_free_kbytes = new_min; > + > + setup_per_zone_wmarks(); > + pr_info("Auto-tuning: unexpected atomic failure detected, increasing min_free_kbytes to %d\n", min_free_kbytes); > + } > +}