Skip to content

Commit

Permalink
mm: thp: microoptimize compound_mapcount()
Browse files Browse the repository at this point in the history
compound_mapcount() is only called after PageCompound() has already been
checked by the caller, so there's no point to check it again.  Gcc may
optimize it away too because it's inline but this will remove the
runtime check for sure and add it'll add an assert instead.

Link: http://lkml.kernel.org/r/1462547040-1737-3-git-send-email-aarcange@redhat.com
Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Andrea Arcangeli authored and Linus Torvalds committed May 21, 2016
1 parent 7b8da4c commit 5f527c2
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions include/linux/mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,7 @@ static inline atomic_t *compound_mapcount_ptr(struct page *page)

static inline int compound_mapcount(struct page *page)
{
if (!PageCompound(page))
return 0;
VM_BUG_ON_PAGE(!PageCompound(page), page);
page = compound_head(page);
return atomic_read(compound_mapcount_ptr(page)) + 1;
}
Expand Down

0 comments on commit 5f527c2

Please sign in to comment.