mm: Add folio_raw_mapping()

Convert __page_rmapping to folio_raw_mapping and move it to mm/internal.h.
It's only a couple of instructions (load and mask), so it's definitely
going to be cheaper to inline it than call it.  Leave page_rmapping
out of line.  Change page_anon_vma() to not call folio_raw_mapping() --
it's more efficient to do the subtraction than the mask.
Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: default avatarDavid Howells <dhowells@redhat.com>
Acked-by: default avatarVlastimil Babka <vbabka@suse.cz>
parent bf6bd276
...@@ -34,6 +34,13 @@ ...@@ -34,6 +34,13 @@
void page_writeback_init(void); void page_writeback_init(void);
static inline void *folio_raw_mapping(struct folio *folio)
{
unsigned long mapping = (unsigned long)folio->mapping;
return (void *)(mapping & ~PAGE_MAPPING_FLAGS);
}
vm_fault_t do_swap_page(struct vm_fault *vmf); vm_fault_t do_swap_page(struct vm_fault *vmf);
void folio_rotate_reclaimable(struct folio *folio); void folio_rotate_reclaimable(struct folio *folio);
......
...@@ -654,21 +654,10 @@ void *kvrealloc(const void *p, size_t oldsize, size_t newsize, gfp_t flags) ...@@ -654,21 +654,10 @@ void *kvrealloc(const void *p, size_t oldsize, size_t newsize, gfp_t flags)
} }
EXPORT_SYMBOL(kvrealloc); EXPORT_SYMBOL(kvrealloc);
static inline void *__page_rmapping(struct page *page)
{
unsigned long mapping;
mapping = (unsigned long)page->mapping;
mapping &= ~PAGE_MAPPING_FLAGS;
return (void *)mapping;
}
/* Neutral page->mapping pointer to address_space or anon_vma or other */ /* Neutral page->mapping pointer to address_space or anon_vma or other */
void *page_rmapping(struct page *page) void *page_rmapping(struct page *page)
{ {
page = compound_head(page); return folio_raw_mapping(page_folio(page));
return __page_rmapping(page);
} }
/** /**
...@@ -699,13 +688,12 @@ EXPORT_SYMBOL(folio_mapped); ...@@ -699,13 +688,12 @@ EXPORT_SYMBOL(folio_mapped);
struct anon_vma *page_anon_vma(struct page *page) struct anon_vma *page_anon_vma(struct page *page)
{ {
unsigned long mapping; struct folio *folio = page_folio(page);
unsigned long mapping = (unsigned long)folio->mapping;
page = compound_head(page);
mapping = (unsigned long)page->mapping;
if ((mapping & PAGE_MAPPING_FLAGS) != PAGE_MAPPING_ANON) if ((mapping & PAGE_MAPPING_FLAGS) != PAGE_MAPPING_ANON)
return NULL; return NULL;
return __page_rmapping(page); return (void *)(mapping - PAGE_MAPPING_ANON);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment