From patchwork Tue Dec 2 09:27:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Yalin" X-Patchwork-Id: 5418841 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B9E8FBEEA8 for ; Tue, 2 Dec 2014 09:30:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 23AFC200E7 for ; Tue, 2 Dec 2014 09:30:29 +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 696B52024F for ; Tue, 2 Dec 2014 09:30:25 +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 1Xvjkl-0000au-HW; Tue, 02 Dec 2014 09:28:15 +0000 Received: from cnbjrel01.sonyericsson.com ([219.141.167.165]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xvjki-0000Tq-2X for linux-arm-kernel@lists.infradead.org; Tue, 02 Dec 2014 09:28:12 +0000 From: "Wang, Yalin" To: "'linux-kernel@vger.kernel.org'" , "'linux-mm@kvack.org'" , "'linux-arm-kernel@lists.infradead.org'" Date: Tue, 2 Dec 2014 17:27:36 +0800 Subject: [RFC V2] mm:add zero_page _mapcount when mapped into user space Thread-Topic: [RFC V2] mm:add zero_page _mapcount when mapped into user space Thread-Index: AdAOEjVZ7CVTZrZqRRuSy8tkAu1Gbw== Message-ID: <35FD53F367049845BC99AC72306C23D103E688B313E0@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-20141202_012812_349592_89301320 X-CRM114-Status: UNSURE ( 6.19 ) 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/dec zero_page's _mapcount to make sure the mapcount is correct for zero_page, so that when read from /proc/kpagecount, zero_page's mapcount is also correct, userspace process like procrank can calculate PSS correctly. Signed-off-by: Yalin Wang --- mm/memory.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/memory.c b/mm/memory.c index 3e50383..7215423 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2198,6 +2198,7 @@ gotten: new_page = alloc_zeroed_user_highpage_movable(vma, address); if (!new_page) goto oom; + atomic_dec(&pfn_to_page(pte_pfn(orig_pte))->_mapcount); } else { new_page = alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, address); if (!new_page) @@ -2647,6 +2648,7 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma, page_table = pte_offset_map_lock(mm, pmd, address, &ptl); if (!pte_none(*page_table)) goto unlock; + atomic_inc(&pfn_to_page(my_zero_pfn(address))->_mapcount); goto setpte; }