From patchwork Mon Dec 8 09:59:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Yalin" X-Patchwork-Id: 5455351 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B9E299F1C5 for ; Mon, 8 Dec 2014 10:02:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EFB0620120 for ; Mon, 8 Dec 2014 10:02:08 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2699F20115 for ; Mon, 8 Dec 2014 10:02:08 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xxv77-0000jC-MA; Mon, 08 Dec 2014 10:00:21 +0000 Received: from cnbjrel02.sonyericsson.com ([219.141.167.166]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xxv71-0007uf-Q3 for linux-arm-kernel@lists.infradead.org; Mon, 08 Dec 2014 10:00:16 +0000 From: "Wang, Yalin" To: 'Hillf Danton' , 'linux-kernel' , "'linux-mm@kvack.org'" , "'linux-arm-kernel@lists.infradead.org'" , 'Andrew Morton' Date: Mon, 8 Dec 2014 17:59:46 +0800 Subject: [PATCH V3] mm:add VM_BUG_ON_PAGE() for page_mapcount() Thread-Topic: [PATCH V3] mm:add VM_BUG_ON_PAGE() for page_mapcount() Thread-Index: AdASyaRYNK5Lt1HlQ1KFwSk6V3BFwAAA8BmwAAAOZuA= Message-ID: <35FD53F367049845BC99AC72306C23D103E688B313FA@CNBJMBX05.corpusers.net> References: <010b01d012ca$05244060$0f6cc120$@alibaba-inc.com> <35FD53F367049845BC99AC72306C23D103E688B313F9@CNBJMBX05.corpusers.net> In-Reply-To: <35FD53F367049845BC99AC72306C23D103E688B313F9@CNBJMBX05.corpusers.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141208_020016_066244_E8F533BF X-CRM114-Status: UNSURE ( 8.94 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.3 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch add VM_BUG_ON_PAGE() for slab page, because _mapcount is an union with slab struct in struct page, avoid access _mapcount if this page is a slab page. Also remove the unneeded bracket. Signed-off-by: Yalin Wang Acked-by: Kirill A. Shutemov Acked-by: Hillf Danton --- include/linux/mm.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index b464611..a117527 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -449,7 +449,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)