Re: [PATCH 7/7] mm, swap: simplify folio swap allocation
From: Matthew Wilcox
Date: Fri Feb 14 2025 - 15:14:20 EST
On Sat, Feb 15, 2025 at 01:57:09AM +0800, Kairui Song wrote:
> @@ -1648,20 +1639,20 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc)
> if (list_empty(&info->swaplist))
> list_add(&info->swaplist, &shmem_swaplist);
>
> - if (add_to_swap_cache(folio, swap,
> - __GFP_HIGH | __GFP_NOMEMALLOC | __GFP_NOWARN,
> - NULL) == 0) {
> + if (folio_alloc_swap(folio, __GFP_HIGH | __GFP_NOMEMALLOC | __GFP_NOWARN)) {
add_to_swap_cache() returns 0 on success or -errno.
folio_alloc_swap returns true on success.
That would seem to indicate you should change the polarity of this test?
Or should folio_alloc_swap() return an errno? Is there value in
distinguishing why we couldn't alloc swap (ENOMEM vs ENOSPC, perhaps?)