Skip to contentSkip to conversation

mm: thp: microoptimize compound_mapcount()

PATCH New [email protected] 1 participant 1 message May 20, 2016 MM core

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 41/162 mm: thp: microoptimize compound_mapcount()

From: Andrea Arcangeli <[email protected]>
Subject: 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.

---

 include/linux/mm.h |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
include/linux/mm.h renamed from include/linux/mm.h~mm-thp-microoptimize-compound_mapcount +1 -2
diff -puN include/linux/mm.h~mm-thp-microoptimize-compound_mapcount include/linux/mm.h
@@ -475,8 +475,7 @@ static inline atomic_t *compound_mapcoun
 
 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;
 }

_