Skip to content

Commit

Permalink
mm: Move page_mapping_file to pagemap.h
Browse files Browse the repository at this point in the history
page_mapping_file() is only used by some architectures, and then it
is usually only used in one place.  Make it a static inline function
so other architectures don't have to carry this dead code.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
  • Loading branch information
Matthew Wilcox (Oracle) authored and intel-lab-lkp committed Mar 16, 2021
1 parent 2932a9e commit 5f7b112
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
1 change: 0 additions & 1 deletion include/linux/mm.h
Expand Up @@ -1549,7 +1549,6 @@ static inline pgoff_t page_index(struct page *page)

bool page_mapped(struct page *page);
struct address_space *page_mapping(struct page *page);
struct address_space *page_mapping_file(struct page *page);

/*
* Return true only if the page has been allocated with
Expand Down
10 changes: 10 additions & 0 deletions include/linux/pagemap.h
Expand Up @@ -121,6 +121,16 @@ static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask)

void release_pages(struct page **pages, int nr);

/*
* For file cache pages, return the address_space, otherwise return NULL
*/
static inline struct address_space *page_mapping_file(struct page *page)
{
if (unlikely(PageSwapCache(page)))
return NULL;
return page_mapping(page);
}

/*
* speculatively take a reference to a page.
* If the page is free (_refcount == 0), then _refcount is untouched, and 0
Expand Down
10 changes: 0 additions & 10 deletions mm/util.c
Expand Up @@ -689,16 +689,6 @@ struct address_space *page_mapping(struct page *page)
}
EXPORT_SYMBOL(page_mapping);

/*
* For file cache pages, return the address_space, otherwise return NULL
*/
struct address_space *page_mapping_file(struct page *page)
{
if (unlikely(PageSwapCache(page)))
return NULL;
return page_mapping(page);
}

/* Slow path of page_mapcount() for compound pages */
int __page_mapcount(struct page *page)
{
Expand Down

0 comments on commit 5f7b112

Please sign in to comment.