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

secretmem: convert page_is_secretmem() to folio_is_secretmem()

The only caller already has a folio, so use it to save calling
compound_head() in PageLRU() and remove a use of page->mapping.

Link: https://lkml.kernel.org/r/20230822202335.179081-1-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Mike Rapoport (IBM) <rppt@kernel.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Matthew Wilcox (Oracle) and committed by
Andrew Morton
8f9ff2de 7db15418

+8 -9
+7 -8
include/linux/secretmem.h
··· 6 6 7 7 extern const struct address_space_operations secretmem_aops; 8 8 9 - static inline bool page_is_secretmem(struct page *page) 9 + static inline bool folio_is_secretmem(struct folio *folio) 10 10 { 11 11 struct address_space *mapping; 12 12 13 13 /* 14 - * Using page_mapping() is quite slow because of the actual call 15 - * instruction and repeated compound_head(page) inside the 16 - * page_mapping() function. 14 + * Using folio_mapping() is quite slow because of the actual call 15 + * instruction. 17 16 * We know that secretmem pages are not compound and LRU so we can 18 17 * save a couple of cycles here. 19 18 */ 20 - if (PageCompound(page) || !PageLRU(page)) 19 + if (folio_test_large(folio) || !folio_test_lru(folio)) 21 20 return false; 22 21 23 22 mapping = (struct address_space *) 24 - ((unsigned long)page->mapping & ~PAGE_MAPPING_FLAGS); 23 + ((unsigned long)folio->mapping & ~PAGE_MAPPING_FLAGS); 25 24 26 - if (!mapping || mapping != page->mapping) 25 + if (!mapping || mapping != folio->mapping) 27 26 return false; 28 27 29 28 return mapping->a_ops == &secretmem_aops; ··· 38 39 return false; 39 40 } 40 41 41 - static inline bool page_is_secretmem(struct page *page) 42 + static inline bool folio_is_secretmem(struct folio *folio) 42 43 { 43 44 return false; 44 45 }
+1 -1
mm/gup.c
··· 2600 2600 if (!folio) 2601 2601 goto pte_unmap; 2602 2602 2603 - if (unlikely(page_is_secretmem(page))) { 2603 + if (unlikely(folio_is_secretmem(folio))) { 2604 2604 gup_put_folio(folio, 1, flags); 2605 2605 goto pte_unmap; 2606 2606 }