Re: [PATCH 1/1] mm/page_alloc: auto-tune min_free_kbytes on atomic allocation failure

From: Andrew Morton
Date: Sun Jan 04 2026 - 13:14:51 EST


On Sun, 4 Jan 2026 20:26:52 +0800 wujing <realwujing@xxxxxx> 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.

Seems like a good idea, however it's very likely that the networking
people have looked into this rather a lot. Can I suggest that you
engage with them? netdev@xxxxxxxxxxxxxxx.

> The adjustment doubles min_free_kbytes upon upon failure (exponential backoff),
> capped at 1% of total RAM.

But no attempt to reduce it again after the load spike has gone away.

> 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
>
> ...
>
> +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);
> +

Probably this should be selectable and tunable via a kernel boot
parameter or a procfs tunable. But I suggest you not do that work
until having discussed the approach with the networking developers.

> warn_alloc(gfp_mask, ac->nodemask,
> "page allocation failure: order:%u", order);
> got_pg: