Re: [RFC PATCH v3 2/4] mm: distinguish large folio swap allocation failures
From: Youngjun Park
Date: Tue Jul 21 2026 - 12:22:40 EST
On Fri, Jul 17, 2026 at 08:25:12PM +0800, Xueyuan Chen wrote:
...
> local_lock(&percpu_swap_cluster.lock);
> if (!swap_alloc_fast(folio))
> @@ -1730,11 +1734,16 @@ int folio_alloc_swap(struct folio *folio)
> }
> /* Need to call this even if allocation failed, for MEMCG_SWAP_FAIL. */
> - if (unlikely(mem_cgroup_try_charge_swap(folio, folio->swap)))
> + if (unlikely(mem_cgroup_try_charge_swap(folio, folio->swap,
> + &nr_swap_pages))) {
> swap_cache_del_folio(folio);
IMHO,
If we get here the allocation succeeded and only the charge failed, so
we already know global swap space exists.
(And also swap_cache_del_folio right above even puts the slots back,
so nr_swap_pages goes up again)
Could we just take the margin and decide -E2BIG or -ENOMEM from that?
Youngjun