Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: convert free_page_and_swap_cache() to free_folio_and_swap_cache()

free_page_and_swap_cache() takes a struct page pointer as input parameter,
but it will immediately convert it to folio and all operations following
within use folio instead of page. It makes more sense to pass in folio
directly.

Convert free_page_and_swap_cache() to free_folio_and_swap_cache() to
consume folio directly.

Link: https://lkml.kernel.org/r/20250416201720.41678-1-nifan.cxl@gmail.com
Signed-off-by: Fan Ni <fan.ni@samsung.com>
Acked-by: Davidlohr Bueso <dave@stgolabs.net>
Acked-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Adam Manzanares <a.manzanares@samsung.com>
Cc: "Aneesh Kumar K.V" <aneesh.kumar@kernel.org>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Luis Chamberalin <mcgrof@kernel.org>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Fan Ni and committed by
Andrew Morton
06340b92 4f219913

+10 -14
+2 -2
arch/s390/include/asm/tlb.h
··· 40 40 /* 41 41 * Release the page cache reference for a pte removed by 42 42 * tlb_ptep_clear_flush. In both flush modes the tlb for a page cache page 43 - * has already been freed, so just do free_page_and_swap_cache. 43 + * has already been freed, so just do free_folio_and_swap_cache. 44 44 * 45 45 * s390 doesn't delay rmap removal. 46 46 */ ··· 49 49 { 50 50 VM_WARN_ON_ONCE(delay_rmap); 51 51 52 - free_page_and_swap_cache(page); 52 + free_folio_and_swap_cache(page_folio(page)); 53 53 return false; 54 54 } 55 55
+3 -5
include/linux/swap.h
··· 450 450 } 451 451 452 452 void free_swap_cache(struct folio *folio); 453 - void free_page_and_swap_cache(struct page *); 453 + void free_folio_and_swap_cache(struct folio *folio); 454 454 void free_pages_and_swap_cache(struct encoded_page **, int); 455 455 /* linux/mm/swapfile.c */ 456 456 extern atomic_long_t nr_swap_pages; ··· 520 520 521 521 #define si_swapinfo(val) \ 522 522 do { (val)->freeswap = (val)->totalswap = 0; } while (0) 523 - /* only sparc can not include linux/pagemap.h in this file 524 - * so leave put_page and release_pages undeclared... */ 525 - #define free_page_and_swap_cache(page) \ 526 - put_page(page) 523 + #define free_folio_and_swap_cache(folio) \ 524 + folio_put(folio) 527 525 #define free_pages_and_swap_cache(pages, nr) \ 528 526 release_pages((pages), (nr)); 529 527
+1 -1
mm/huge_memory.c
··· 3653 3653 * requires taking the lru_lock so we do the put_page 3654 3654 * of the tail pages after the split is complete. 3655 3655 */ 3656 - free_page_and_swap_cache(&new_folio->page); 3656 + free_folio_and_swap_cache(new_folio); 3657 3657 } 3658 3658 return ret; 3659 3659 }
+1 -1
mm/khugepaged.c
··· 746 746 ptep_clear(vma->vm_mm, address, _pte); 747 747 folio_remove_rmap_pte(src, src_page, vma); 748 748 spin_unlock(ptl); 749 - free_page_and_swap_cache(src_page); 749 + free_folio_and_swap_cache(src); 750 750 } 751 751 } 752 752
+3 -5
mm/swap_state.c
··· 232 232 } 233 233 234 234 /* 235 - * Perform a free_page(), also freeing any swap cache associated with 236 - * this page if it is the last user of the page. 235 + * Freeing a folio and also freeing any swap cache associated with 236 + * this folio if it is the last user. 237 237 */ 238 - void free_page_and_swap_cache(struct page *page) 238 + void free_folio_and_swap_cache(struct folio *folio) 239 239 { 240 - struct folio *folio = page_folio(page); 241 - 242 240 free_swap_cache(folio); 243 241 if (!is_huge_zero_folio(folio)) 244 242 folio_put(folio);