Re: [RFC PATCH v3 2/4] mm: distinguish large folio swap allocation failures

Youngjun Park <[email protected]>
Newsgroups org.kernel.vger.cgroups,org.kernel.vger.linux-kernel,org.kvack.linux-mm
Message-ID <al+alXxG/8XRCM3y@yjaykim-PowerEdge-T330>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.