From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754471AbcKUMue (ORCPT ); Mon, 21 Nov 2016 07:50:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37852 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753952AbcKUMud (ORCPT ); Mon, 21 Nov 2016 07:50:33 -0500 Date: Mon, 21 Nov 2016 07:50:29 -0500 From: Jerome Glisse To: Anshuman Khandual Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, John Hubbard , Dan Williams , Ross Zwisler Subject: Re: [HMM v13 03/18] mm/ZONE_DEVICE/free_hot_cold_page: catch ZONE_DEVICE pages Message-ID: <20161121125029.GG2392@redhat.com> References: <1479493107-982-1-git-send-email-jglisse@redhat.com> <1479493107-982-4-git-send-email-jglisse@redhat.com> <5832ADD2.5000507@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5832ADD2.5000507@linux.vnet.ibm.com> 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.38]); Mon, 21 Nov 2016 12:50:32 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 21, 2016 at 01:48:26PM +0530, Anshuman Khandual wrote: > On 11/18/2016 11:48 PM, Jérôme Glisse wrote: > > Catch page from ZONE_DEVICE in free_hot_cold_page(). This should never > > happen as ZONE_DEVICE page must always have an elevated refcount. > > > > This is to catch refcounting issues in a sane way for ZONE_DEVICE pages. > > > > Signed-off-by: Jérôme Glisse > > Cc: Dan Williams > > Cc: Ross Zwisler > > --- > > mm/page_alloc.c | 10 ++++++++++ > > 1 file changed, 10 insertions(+) > > > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > index 0fbfead..09b2630 100644 > > --- a/mm/page_alloc.c > > +++ b/mm/page_alloc.c > > @@ -2435,6 +2435,16 @@ void free_hot_cold_page(struct page *page, bool cold) > > unsigned long pfn = page_to_pfn(page); > > int migratetype; > > > > + /* > > + * This should never happen ! Page from ZONE_DEVICE always must have an > > + * active refcount. Complain about it and try to restore the refcount. > > + */ > > + if (is_zone_device_page(page)) { > > + VM_BUG_ON_PAGE(is_zone_device_page(page), page); > > + page_ref_inc(page); > > + return; > > + } > > This fixes an issue in the existing ZONE_DEVICE code, should not this > patch be sent separately not in this series ? > Well this is more like a safetynet feature, i can send it separately from the series. It is not an issue per say as a trap to catch bugs. I had refcounting bugs while working on this patchset and having this safetynet was helpful to quickly pin-point issues. Cheers, Jérôme