From: Kirill A. Shutemov Date: Wed, 21 Oct 2015 22:03:31 +0000 (+1100) Subject: page-flags: do not corrupt caller 'page' in PF_NO_TAIL X-Git-Tag: KARO-TX6UL-2015-11-03~14^2~159 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=dc5f54eefc8e98ed185a91f6504626747f9b2b10;p=karo-tx-linux.git page-flags: do not corrupt caller 'page' in PF_NO_TAIL Andrew noticed that PF_NO_TAIL() modifies caller's 'page'. This doesn't trigger any bad results, because all users are inline functions which doesn't use the variable beyond the point. But still not good. The patch changes PF_NO_TAIL() to always return head page, regardless 'enforce'. This makes operations of page flags with PF_NO_TAIL more symmetrical: modifications and checks goes to head page. It gives better chance to recover in case of bug for non-DEBUG_VM kernel. DEBUG_VM kernel will still trigger VM_BUG_ON() on modifications to tail pages. Signed-off-by: Kirill A. Shutemov Cc: Andrea Arcangeli Cc: Hugh Dickins Cc: Christoph Lameter Signed-off-by: Andrew Morton --- diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 89feab774cbe..8fa6acd1b349 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -160,9 +160,7 @@ static inline int PageCompound(struct page *page) #define PF_NO_TAIL(page, enforce) ({ \ if (enforce) \ VM_BUG_ON_PAGE(PageTail(page), page); \ - else \ - page = compound_head(page); \ - page;}) + compound_head(page);}) #define PF_NO_COMPOUND(page, enforce) ({ \ if (enforce) \ VM_BUG_ON_PAGE(PageCompound(page), page); \