From nobody Mon Feb 9 03:58:31 2026 Received: from out162-62-57-49.mail.qq.com (out162-62-57-49.mail.qq.com [162.62.57.49]) (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 1A5862777FD for ; Sun, 4 Jan 2026 12:27:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=162.62.57.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767529654; cv=none; b=fWGxTICsbI2ux3C716P0zNzHyzZguu0umSQd6wFlDpJNH6t4f2/EhdeYLmeVmg0jvhkx5qSgDWhbiHiWwE3yqsAq5BiEC4bUYSEzDrEP1MwW9OOzuXDDD+xP//x1qhDrYUWPdwMOY/+rytFBbyTK1FfChKjcgKKSMBvqQ/MJ5pY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767529654; c=relaxed/simple; bh=/7zOl8ZC0mkzrUqeMd2vvc8tYIKx2aH9P+kcektMlig=; h=Message-ID:From:To:Cc:Subject:Date:In-Reply-To:References: MIME-Version; b=Vw1HRcpnWQRvU/+a5f9HiaNPuvvfp5H5Nm7gEMOyiHAfCxVSFcsoMEU8qwgfmw+ZS8SqXUEFxyZSss8YxQWJbD0p5n5mOvvPNyI53AW2gYUHReZk5tUo15wqwWdccd/cMvXkIJmgBmHY/F+KKcg16Y7XiiDETmZshxMwq5WxrHs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=qq.com; spf=pass smtp.mailfrom=qq.com; dkim=pass (1024-bit key) header.d=qq.com header.i=@qq.com header.b=EBLWEzFk; arc=none smtp.client-ip=162.62.57.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=qq.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=qq.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=qq.com header.i=@qq.com header.b="EBLWEzFk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1767529640; bh=XnoiPqIKCGT3TvWDVfAyWO7UyS6E9qFjisMWZRge56g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=EBLWEzFkZ3MD/vPXF5AORxa6ouNSaRm4meai4K86YoybaimhIPjK6xcDddz4Sg10V ArJv5C4RcVO89Z7/sfxjX9XiRR1Dig1arrlzMbzkBNCpwQOvZTTtwPJVvU4dYukCRh EsoDXppFIX6TClmeLXBp6C0vVE+x3Z29AzN+WAfQ= Received: from localhost.localdomain ([61.144.109.141]) by newxmesmtplogicsvrszc41-0.qq.com (NewEsmtp) with SMTP id 6D11CCC8; Sun, 04 Jan 2026 20:27:17 +0800 X-QQ-mid: xmsmtpt1767529637tjn4o49cv Message-ID: X-QQ-XMAILINFO: MMwjR1C73eIsZ8C984l31Xid8Z8Nty5k0BEMSfL2KaCwIFJ8BTPvIw92TXjjTn fr7HQPhyVMl3q6H6SAPCg62ck3uEH753h6B/Vu+rWlbg9zul2GjQan6mpmBKApOUMZC/1Px673Wp MGlGxzjRreaOOx60wDJEph76rptxRqBiwX6uJi9mmXsZhEJm4Iap8XF1ve5M46dFj004eu0Z6x96 9D/4Xre878I80YDtdf386OWO20vmqUdEMrRts4imm3qqdG8E+qFYf3/XHZonL74Cbrwbq7GWlLFU +4uVQladPMfzpHXhfXrRx/KG+Mzu0kPIKfkmxN1Zj2KjuiJF4tKqkMOdARQfJ8DBBBUzIp1gsp5B i+45bdKZcmuhABC+30Z507FkSpgWMmCH+dalPRqySI6CoCRDFcVcGkJXhTBKLN5YTjh/FoGTDODU WAxF7aOqL+xE78J1ybKtqVQ64O9MRHmiXzBI4Jbn2Kl5vh/c4mjOONZtWe4XbdlqkoNsvlaFfQuL SrVnx9kkJGPfW2IfLzqyCWFzwyfPjpT4kNwqqhqQJYKAiXic0Mz0TJZXSqxQOuN7FDTprVjsoTN7 VOX36hltNu5cApwQ/qQqkt+RITuwc/eJxzxD4tRY0Zbl2i9J/CKNqHMAPAQS/qyf4YFfgb6wes/x ESGzg0dJ2DzZnn1b2a/qMGH5W8rxpaKjJqcf3GhSexmlIsAPR0wJz45MSgkSjblxx83LC0EplIKA vgmNOSArsn9d2OTV62im55N2gM4F0yhCGdVNjxD5TtNbfIB0l2E3ghZ3rnC+dsojMtGfQ15nyi75 AtLZIg29vIDaQL4V/LJrkyxO+14zIGwVNQVeu0DX4XCayFvtfqpNo69dZgBZz9Sl+KTpI6WblfIZ eY0g+xCYyoqBQ50K1iaSeTnZ24S4hESOBfrEtJQ9rpopdvzAFyt/dLdcXuoTm2A3IVH3YVELpMT9 1YrGS2tTfd5ovOPjx6tk6EVip5tjOvHTklSNz8g+h6SqpEm1ujzaNBcjdFJbF/v/10TzkK4tk4+T mkUr9xrGH2F6FHzPhD5GS0pp5/OYd/dHku4FHJqPHhEM1l6d6c X-QQ-XMRINFO: OD9hHCdaPRBwH5bRRRw8tsiH4UAatJqXfg== From: wujing To: Andrew Morton , Vlastimil Babka Cc: Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Qiliang Yuan , wujing Subject: [PATCH 1/1] mm/page_alloc: auto-tune min_free_kbytes on atomic allocation failure Date: Sun, 4 Jan 2026 20:26:52 +0800 X-OQ-MSGID: <20260104122652.1219035-1-realwujing@qq.com> X-Mailer: git-send-email 2.39.5 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: quoted-printable Content-Type: text/plain; charset="utf-8" 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. The adjustment doubles min_free_kbytes upon upon failure (exponential backo= ff), 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=3D0x48002= 0(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=3D0x48002= 0(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=3D0x48002= 0(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=3D0x48002= 0(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=3D0x48002= 0(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=3D0x48002= 0(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:0x480= 020(GFP_ATOMIC), nodemask=3D(null) [38535649.671692] swapper/100 cpuset=3D/ mems_allowed=3D0-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, nodem= ask_t *nodemask) mem_cgroup_show_protected_memory(NULL); } =20 +static void boost_min_free_kbytes_workfn(struct work_struct *work); +static DECLARE_WORK(boost_min_free_kbytes_work, boost_min_free_kbytes_work= fn); + 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 =3D=3D 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_fla= gs, 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 =3D totalram_pages() << (PAGE_SHIFT - 10); + int max_limit =3D total_kbytes / 100; + + /* Exponential increase: double the current value */ + new_min =3D min_free_kbytes * 2; + + if (new_min > max_limit) + new_min =3D max_limit; + + if (new_min > min_free_kbytes) { + min_free_kbytes =3D new_min; + /* Update user_min_free_kbytes so it persists through recalculations */ + if (new_min > user_min_free_kbytes) + user_min_free_kbytes =3D new_min; + =09 + setup_per_zone_wmarks(); + pr_info("Auto-tuning: unexpected atomic failure detected, increasing min= _free_kbytes to %d\n", min_free_kbytes); + } +} --=20 2.39.5