Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754492AbdCPPV7 (ORCPT ); Thu, 16 Mar 2017 11:21:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51654 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752727AbdCPPVz (ORCPT ); Thu, 16 Mar 2017 11:21:55 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A977781F03 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jglisse@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A977781F03 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= To: akpm@linux-foundation.org, , linux-mm@kvack.org Cc: John Hubbard , Naoya Horiguchi , David Nellans , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Dan Williams , Ross Zwisler Subject: [HMM 02/16] mm/put_page: move ref decrement to put_zone_device_page() Date: Thu, 16 Mar 2017 12:05:21 -0400 Message-Id: <1489680335-6594-3-git-send-email-jglisse@redhat.com> In-Reply-To: <1489680335-6594-1-git-send-email-jglisse@redhat.com> References: <1489680335-6594-1-git-send-email-jglisse@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 16 Mar 2017 15:03:51 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1489 Lines: 52 This does not affect non ZONE_DEVICE page. In order to allow ZONE_DEVICE page to be tracked we need to detect when refcount of a ZONE_DEVICE page reach 1 (not 0 as non ZONE_DEVICE page). This patch just move put_page_testzero() from put_page() to put_zone_device_page() and only for ZONE_DEVICE. It does not add any overhead compare to existing code. Signed-off-by: Jérôme Glisse Cc: Dan Williams Cc: Ross Zwisler --- include/linux/mm.h | 8 +++++--- kernel/memremap.c | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 5f01c88..28e8b28 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -793,11 +793,13 @@ static inline void put_page(struct page *page) { page = compound_head(page); + if (unlikely(is_zone_device_page(page))) { + put_zone_device_page(page); + return; + } + if (put_page_testzero(page)) __put_page(page); - - if (unlikely(is_zone_device_page(page))) - put_zone_device_page(page); } #if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP) diff --git a/kernel/memremap.c b/kernel/memremap.c index 40d4af8..c821946 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c @@ -190,6 +190,8 @@ EXPORT_SYMBOL(get_zone_device_page); void put_zone_device_page(struct page *page) { + page_ref_dec(page); + put_dev_pagemap(page->pgmap); } EXPORT_SYMBOL(put_zone_device_page); -- 2.4.11