From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935985AbdEVVRb (ORCPT ); Mon, 22 May 2017 17:17:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47036 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933776AbdEVVR2 (ORCPT ); Mon, 22 May 2017 17:17:28 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 91B1D80C10 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jglisse@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 91B1D80C10 Date: Mon, 22 May 2017 17:17:24 -0400 From: Jerome Glisse To: Hugh Dickins Cc: Dan Williams , Andrew Morton , "linux-kernel@vger.kernel.org" , Linux MM , John Hubbard , David Nellans , "Kirill A . Shutemov" , Ross Zwisler Subject: Re: [HMM 08/15] mm/ZONE_DEVICE: special case put_page() for device private pages Message-ID: <20170522211724.GC8168@redhat.com> References: <20170522165206.6284-1-jglisse@redhat.com> <20170522165206.6284-9-jglisse@redhat.com> <20170522201416.GA8168@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.7.1 (2016-10-04) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 22 May 2017 21:17:27 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 22, 2017 at 01:22:22PM -0700, Hugh Dickins wrote: > On Mon, 22 May 2017, Jerome Glisse wrote: > > On Mon, May 22, 2017 at 12:29:53PM -0700, Dan Williams wrote: > > > On Mon, May 22, 2017 at 9:51 AM, Jerome Glisse wrote: > > > > A ZONE_DEVICE page that reach a refcount of 1 is free ie no longer > > > > have any user. For device private pages this is important to catch > > > > and thus we need to special case put_page() for this. > > > > > > > > Signed-off-by: Jerome Glisse > > > > Cc: Kirill A. Shutemov > > > > Cc: Dan Williams > > > > Cc: Ross Zwisler > > > > --- > > > > include/linux/mm.h | 30 ++++++++++++++++++++++++++++++ > > > > kernel/memremap.c | 1 - > > > > 2 files changed, 30 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/include/linux/mm.h b/include/linux/mm.h > > > > index a825dab..11f7bac 100644 > > > > --- a/include/linux/mm.h > > > > +++ b/include/linux/mm.h > > > > @@ -23,6 +23,7 @@ > > > > #include > > > > #include > > > > #include > > > > +#include > > > > > > > > struct mempolicy; > > > > struct anon_vma; > > > > @@ -795,6 +796,20 @@ static inline bool is_device_private_page(const struct page *page) > > > > return ((page_zonenum(page) == ZONE_DEVICE) && > > > > (page->pgmap->type == MEMORY_DEVICE_PRIVATE)); > > > > } > > > > + > > > > +static inline void put_zone_device_private_page(struct page *page) > > > > +{ > > > > + int count = page_ref_dec_return(page); > > > > + > > > > + /* > > > > + * If refcount is 1 then page is freed and refcount is stable as nobody > > > > + * holds a reference on the page. > > > > + */ > > > > + if (count == 1) > > > > + page->pgmap->page_free(page, page->pgmap->data); > > > > + else if (!count) > > > > + __put_page(page); > > > > +} > > Is there something else in this patchset that guarantees > that get_page_unless_zero() is never used on thse pages? > We have plenty of code that knows that refcount 0 is special: > having to know that refcount 1 may be special is worrying. > > Hugh ZONE_DEVICE pages always had this extra refcount since their inception. All the place that use get_page_unless_zero() should be unreachable by a ZONE_DEVICE pages (hwpoison, lru, isolate, ksm, ...). So if that happens it is a bug. Jérôme From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt0-f199.google.com (mail-qt0-f199.google.com [209.85.216.199]) by kanga.kvack.org (Postfix) with ESMTP id 83C376B02B4 for ; Mon, 22 May 2017 17:17:29 -0400 (EDT) Received: by mail-qt0-f199.google.com with SMTP id 25so54223621qtx.11 for ; Mon, 22 May 2017 14:17:29 -0700 (PDT) Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id g46si19318022qtb.268.2017.05.22.14.17.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 May 2017 14:17:28 -0700 (PDT) Date: Mon, 22 May 2017 17:17:24 -0400 From: Jerome Glisse Subject: Re: [HMM 08/15] mm/ZONE_DEVICE: special case put_page() for device private pages Message-ID: <20170522211724.GC8168@redhat.com> References: <20170522165206.6284-1-jglisse@redhat.com> <20170522165206.6284-9-jglisse@redhat.com> <20170522201416.GA8168@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Sender: owner-linux-mm@kvack.org List-ID: To: Hugh Dickins Cc: Dan Williams , Andrew Morton , "linux-kernel@vger.kernel.org" , Linux MM , John Hubbard , David Nellans , "Kirill A . Shutemov" , Ross Zwisler On Mon, May 22, 2017 at 01:22:22PM -0700, Hugh Dickins wrote: > On Mon, 22 May 2017, Jerome Glisse wrote: > > On Mon, May 22, 2017 at 12:29:53PM -0700, Dan Williams wrote: > > > On Mon, May 22, 2017 at 9:51 AM, Jerome Glisse wrote: > > > > A ZONE_DEVICE page that reach a refcount of 1 is free ie no longer > > > > have any user. For device private pages this is important to catch > > > > and thus we need to special case put_page() for this. > > > > > > > > Signed-off-by: Jerome Glisse > > > > Cc: Kirill A. Shutemov > > > > Cc: Dan Williams > > > > Cc: Ross Zwisler > > > > --- > > > > include/linux/mm.h | 30 ++++++++++++++++++++++++++++++ > > > > kernel/memremap.c | 1 - > > > > 2 files changed, 30 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/include/linux/mm.h b/include/linux/mm.h > > > > index a825dab..11f7bac 100644 > > > > --- a/include/linux/mm.h > > > > +++ b/include/linux/mm.h > > > > @@ -23,6 +23,7 @@ > > > > #include > > > > #include > > > > #include > > > > +#include > > > > > > > > struct mempolicy; > > > > struct anon_vma; > > > > @@ -795,6 +796,20 @@ static inline bool is_device_private_page(const struct page *page) > > > > return ((page_zonenum(page) == ZONE_DEVICE) && > > > > (page->pgmap->type == MEMORY_DEVICE_PRIVATE)); > > > > } > > > > + > > > > +static inline void put_zone_device_private_page(struct page *page) > > > > +{ > > > > + int count = page_ref_dec_return(page); > > > > + > > > > + /* > > > > + * If refcount is 1 then page is freed and refcount is stable as nobody > > > > + * holds a reference on the page. > > > > + */ > > > > + if (count == 1) > > > > + page->pgmap->page_free(page, page->pgmap->data); > > > > + else if (!count) > > > > + __put_page(page); > > > > +} > > Is there something else in this patchset that guarantees > that get_page_unless_zero() is never used on thse pages? > We have plenty of code that knows that refcount 0 is special: > having to know that refcount 1 may be special is worrying. > > Hugh ZONE_DEVICE pages always had this extra refcount since their inception. All the place that use get_page_unless_zero() should be unreachable by a ZONE_DEVICE pages (hwpoison, lru, isolate, ksm, ...). So if that happens it is a bug. Jerome -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org