mm: do not inc NR_PAGETABLE if ptlock_init failed
authorVladimir Davydov <vdavydov@virtuozzo.com>
Fri, 6 Nov 2015 02:49:27 +0000 (18:49 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 6 Nov 2015 03:34:48 +0000 (19:34 -0800)
If ALLOC_SPLIT_PTLOCKS is defined, ptlock_init may fail, in which case we
shouldn't increment NR_PAGETABLE.

Since small allocations, such as ptlock, normally do not fail (currently
they can fail if kmemcg is used though), this patch does not really fix
anything and should be considered as a code cleanup.

Signed-off-by: Vladimir Davydov <vdavydov@virtuozzo.com>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/mm.h

index fa08f3cf0f22ebab5995b3c04fca719cb0442fb7..3c258f8eb9ae76017124af4892cb1305634006c2 100644 (file)
@@ -1606,8 +1606,10 @@ static inline void pgtable_init(void)
 
 static inline bool pgtable_page_ctor(struct page *page)
 {
+       if (!ptlock_init(page))
+               return false;
        inc_zone_page_state(page, NR_PAGETABLE);
-       return ptlock_init(page);
+       return true;
 }
 
 static inline void pgtable_page_dtor(struct page *page)