Skip to content

Commit

Permalink
mm: uninline page_mapped()
Browse files Browse the repository at this point in the history
It's huge.  Uninlining it saves 206 bytes per callsite.  Shaves 4924 bytes
from the x86_64 allmodconfig vmlinux.

Cc: Steve Capper <steve.capper@arm.com>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  • Loading branch information
akpm00 authored and sfrothwell committed Apr 3, 2016
1 parent 29c706c commit 64c57d7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
21 changes: 1 addition & 20 deletions include/linux/mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -1019,26 +1019,7 @@ static inline pgoff_t page_file_index(struct page *page)
return page->index;
}

/*
* Return true if this page is mapped into pagetables.
* For compound page it returns true if any subpage of compound page is mapped.
*/
static inline bool page_mapped(struct page *page)
{
int i;
if (likely(!PageCompound(page)))
return atomic_read(&page->_mapcount) >= 0;
page = compound_head(page);
if (atomic_read(compound_mapcount_ptr(page)) >= 0)
return true;
if (PageHuge(page))
return false;
for (i = 0; i < hpage_nr_pages(page); i++) {
if (atomic_read(&page[i]._mapcount) >= 0)
return true;
}
return false;
}
bool page_mapped(struct page *page);

/*
* Return true only if the page has been allocated with
Expand Down
22 changes: 22 additions & 0 deletions mm/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,28 @@ void *page_rmapping(struct page *page)
return __page_rmapping(page);
}

/*
* Return true if this page is mapped into pagetables.
* For compound page it returns true if any subpage of compound page is mapped.
*/
bool page_mapped(struct page *page)
{
int i;
if (likely(!PageCompound(page)))
return atomic_read(&page->_mapcount) >= 0;
page = compound_head(page);
if (atomic_read(compound_mapcount_ptr(page)) >= 0)
return true;
if (PageHuge(page))
return false;
for (i = 0; i < hpage_nr_pages(page); i++) {
if (atomic_read(&page[i]._mapcount) >= 0)
return true;
}
return false;
}
EXPORT_SYMBOL(page_mapped);

struct anon_vma *page_anon_vma(struct page *page)
{
unsigned long mapping;
Expand Down

0 comments on commit 64c57d7

Please sign in to comment.