Skip to content

Commit 8f9ff2d

Browse files
Matthew Wilcox (Oracle)akpm00
authored andcommitted
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>
1 parent 7db1541 commit 8f9ff2d

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

include/linux/secretmem.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,23 @@
66

77
extern const struct address_space_operations secretmem_aops;
88

9-
static inline bool page_is_secretmem(struct page *page)
9+
static inline bool folio_is_secretmem(struct folio *folio)
1010
{
1111
struct address_space *mapping;
1212

1313
/*
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.
1716
* We know that secretmem pages are not compound and LRU so we can
1817
* save a couple of cycles here.
1918
*/
20-
if (PageCompound(page) || !PageLRU(page))
19+
if (folio_test_large(folio) || !folio_test_lru(folio))
2120
return false;
2221

2322
mapping = (struct address_space *)
24-
((unsigned long)page->mapping & ~PAGE_MAPPING_FLAGS);
23+
((unsigned long)folio->mapping & ~PAGE_MAPPING_FLAGS);
2524

26-
if (!mapping || mapping != page->mapping)
25+
if (!mapping || mapping != folio->mapping)
2726
return false;
2827

2928
return mapping->a_ops == &secretmem_aops;
@@ -39,7 +38,7 @@ static inline bool vma_is_secretmem(struct vm_area_struct *vma)
3938
return false;
4039
}
4140

42-
static inline bool page_is_secretmem(struct page *page)
41+
static inline bool folio_is_secretmem(struct folio *folio)
4342
{
4443
return false;
4544
}

mm/gup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2600,7 +2600,7 @@ static int gup_pte_range(pmd_t pmd, pmd_t *pmdp, unsigned long addr,
26002600
if (!folio)
26012601
goto pte_unmap;
26022602

2603-
if (unlikely(page_is_secretmem(page))) {
2603+
if (unlikely(folio_is_secretmem(folio))) {
26042604
gup_put_folio(folio, 1, flags);
26052605
goto pte_unmap;
26062606
}

0 commit comments

Comments
 (0)