mm: add VM_BUG_ON_PAGE() to page_mapcount()
authorWang, Yalin <Yalin.Wang@sonymobile.com>
Wed, 11 Feb 2015 23:24:48 +0000 (15:24 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 12 Feb 2015 01:06:00 +0000 (17:06 -0800)
Add VM_BUG_ON_PAGE() for slab pages.  _mapcount is an union with slab
struct in struct page, so we must avoid accessing _mapcount if this page
is a slab page.  Also remove the unneeded bracket.

Signed-off-by: Yalin Wang <yalin.wang@sonymobile.com>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/mm.h

index 8dd4fde9d2e5324c2c55e614d7b07f93848d2dd5..c6bf813a6b3d732e698d26dcedae4026c97940c8 100644 (file)
@@ -484,7 +484,8 @@ static inline void page_mapcount_reset(struct page *page)
 
 static inline int page_mapcount(struct page *page)
 {
-       return atomic_read(&(page)->_mapcount) + 1;
+       VM_BUG_ON_PAGE(PageSlab(page), page);
+       return atomic_read(&page->_mapcount) + 1;
 }
 
 static inline int page_count(struct page *page)