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.

gup: use folios for gup_devmap

Use try_grab_folio() instead of try_grab_page() so we get the folio back
that we calculated, and then use folio_set_referenced() instead of
SetPageReferenced(). Correspondingly, use gup_put_folio() to put any
unneeded references.

Link: https://lkml.kernel.org/r/20240424191914.361554-6-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Matthew Wilcox (Oracle) and committed by
Andrew Morton
9cbe4954 498aefbc

+8 -9
+8 -9
mm/gup.c
··· 2877 2877 unsigned int flags, struct page **pages) 2878 2878 { 2879 2879 while ((*nr) - nr_start) { 2880 - struct page *page = pages[--(*nr)]; 2880 + struct folio *folio = page_folio(pages[--(*nr)]); 2881 2881 2882 - ClearPageReferenced(page); 2883 - if (flags & FOLL_PIN) 2884 - unpin_user_page(page); 2885 - else 2886 - put_page(page); 2882 + folio_clear_referenced(folio); 2883 + gup_put_folio(folio, 1, flags); 2887 2884 } 2888 2885 } 2889 2886 ··· 3021 3024 struct dev_pagemap *pgmap = NULL; 3022 3025 3023 3026 do { 3027 + struct folio *folio; 3024 3028 struct page *page = pfn_to_page(pfn); 3025 3029 3026 3030 pgmap = get_dev_pagemap(pfn, pgmap); ··· 3035 3037 break; 3036 3038 } 3037 3039 3038 - SetPageReferenced(page); 3039 - pages[*nr] = page; 3040 - if (unlikely(try_grab_page(page, flags))) { 3040 + folio = try_grab_folio(page, 1, flags); 3041 + if (!folio) { 3041 3042 gup_fast_undo_dev_pagemap(nr, nr_start, flags, pages); 3042 3043 break; 3043 3044 } 3045 + folio_set_referenced(folio); 3046 + pages[*nr] = page; 3044 3047 (*nr)++; 3045 3048 pfn++; 3046 3049 } while (addr += PAGE_SIZE, addr != end);