From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751472AbbJBFkX (ORCPT ); Fri, 2 Oct 2015 01:40:23 -0400 Received: from mga03.intel.com ([134.134.136.65]:20136 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750952AbbJBFkU (ORCPT ); Fri, 2 Oct 2015 01:40:20 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,621,1437462000"; d="scan'208";a="782511069" From: "Kirill A. Shutemov" To: Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, "Kirill A. Shutemov" Subject: [PATCH 1/3] page-flags: do not corrupt caller 'page' in PF_NO_TAIL Date: Fri, 2 Oct 2015 08:40:14 +0300 Message-Id: <1443764416-129688-2-git-send-email-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.5.1 In-Reply-To: <1443764416-129688-1-git-send-email-kirill.shutemov@linux.intel.com> References: <1443764416-129688-1-git-send-email-kirill.shutemov@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- include/linux/page-flags.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 2a2391c21558..465ca42af633 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -139,9 +139,7 @@ enum pageflags { #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); \ -- 2.5.1