Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm: thp: microoptimize compound_mapcount()

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>

authored by

Andrea Arcangeli and committed by
Linus Torvalds
5f527c2b 7b8da4c7

+1 -2
+1 -2
include/linux/mm.h
··· 475 475 476 476 static inline int compound_mapcount(struct page *page) 477 477 { 478 - if (!PageCompound(page)) 479 - return 0; 478 + VM_BUG_ON_PAGE(!PageCompound(page), page); 480 479 page = compound_head(page); 481 480 return atomic_read(compound_mapcount_ptr(page)) + 1; 482 481 }