Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp387807ybi; Fri, 21 Jun 2019 01:12:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqwg9fi8obyIiCBKdNJkNsSQ5u+qS4FEnN3fX9mQPaqAZ5LWpe7oQwcpgKApjRGQ/N+b7SVZ X-Received: by 2002:a17:902:a607:: with SMTP id u7mr125068092plq.43.1561104740727; Fri, 21 Jun 2019 01:12:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561104740; cv=none; d=google.com; s=arc-20160816; b=Y+tyn+LsC7G1bezaqxedAbcygXIVn59x/pZnRookqZtcBdmmYaojHr+u8mOg++tpVa riL1Hpu5F7soFVq5mTbkw/6pX7qaDU1uhcSoJH3p0fsoE3vVfXRRXJj1EptzSNyYGZ7l 3vqveE0TcPb9hQz642qLLTAoyKaob2q4EOIly1uBfhaSrzsXXCvczH8h3XLpaxdii6Qb z78B/C0GO++ygp7Oj/gC+jF0/4+FvE40RGT3VsrpTIuMGQPuiymZJBFHVTEMk3Pwdq+P g6UalH3Xig8pjPF9F+qNvPg2q/I/Ir4buqJuy8YYagVEezqOyRNUPoeCx+sX+jK5vuVU HdgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=7i6dJlpycYYkF3HawzKcEbdgni5ZrmtRBp3Gy0v9tRc=; b=GiafG07P6HUOp9/cUNdinVLZ8JeZSfvPT5eiQ2tGaR8hB19BQe/jH11YxAC7yXI9ZK 7ivLntmzIB+w0HJ8QKRh+0KJ1e6mDCn6UR7EYkuaPNUFZSKaCnBUW9/UOPZHN8y5K6tz DHOHaqT35FpHmnhTB/0t0U3XgnBytFOWHK4WPeZOVyBgZUKm7BdXrfWF7RJPuMRFNuNH IVvOuVUMI1KbpOcz06koqqz6WeH44AaOrl8YkBD60rR0nl0zd0YQfYXvmcCOi8ZNETot zm1enqli7F2b2IyRxJPOyrnVG2AZTgh9Aq/1iKpReOhlUwlAV5mDO3qw5lkH9fkhGcWi x1ag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w5si1892370pgh.430.2019.06.21.01.12.05; Fri, 21 Jun 2019 01:12:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726331AbfFUILu (ORCPT + 99 others); Fri, 21 Jun 2019 04:11:50 -0400 Received: from mx2.suse.de ([195.135.220.15]:51606 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726058AbfFUILu (ORCPT ); Fri, 21 Jun 2019 04:11:50 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 5292CAF50; Fri, 21 Jun 2019 08:11:49 +0000 (UTC) Date: Fri, 21 Jun 2019 10:11:47 +0200 From: Michal Hocko To: ira.weiny@intel.com Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, =?iso-8859-1?B?Suly9G1l?= Glisse , Dan Williams , John Hubbard Subject: Re: [PATCH v4] mm/swap: Fix release_pages() when releasing devmap pages Message-ID: <20190621081147.GC3429@dhcp22.suse.cz> References: <20190605214922.17684-1-ira.weiny@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190605214922.17684-1-ira.weiny@intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sorry for a late reply. On Wed 05-06-19 14:49:22, ira.weiny@intel.com wrote: > From: Ira Weiny > > release_pages() is an optimized version of a loop around put_page(). > Unfortunately for devmap pages the logic is not entirely correct in > release_pages(). This is because device pages can be more than type > MEMORY_DEVICE_PUBLIC. There are in fact 4 types, private, public, FS > DAX, and PCI P2PDMA. Some of these have specific needs to "put" the > page while others do not. > > This logic to handle any special needs is contained in > put_devmap_managed_page(). Therefore all devmap pages should be > processed by this function where we can contain the correct logic for a > page put. > > Handle all device type pages within release_pages() by calling > put_devmap_managed_page() on all devmap pages. If > put_devmap_managed_page() returns true the page has been put and we > continue with the next page. A false return of > put_devmap_managed_page() means the page did not require special > processing and should fall to "normal" processing. > > This was found via code inspection while determining if release_pages() > and the new put_user_pages() could be interchangeable.[1] This is much more clear than the previous version I've looked at. Thanks a lot! > > [1] https://lore.kernel.org/lkml/20190523172852.GA27175@iweiny-DESK2.sc.intel.com/ > > Cc: J?r?me Glisse > Cc: Michal Hocko > Reviewed-by: Dan Williams > Reviewed-by: John Hubbard > Signed-off-by: Ira Weiny Acked-by: Michal Hocko > > --- > Changes from V3: > Update comment to the one provided by John > > Changes from V2: > Update changelog for more clarity as requested by Michal > Update comment WRT "failing" of put_devmap_managed_page() > > Changes from V1: > Add comment clarifying that put_devmap_managed_page() can still > fail. > Add Reviewed-by tags. > > mm/swap.c | 13 +++++++++---- > 1 file changed, 9 insertions(+), 4 deletions(-) > > diff --git a/mm/swap.c b/mm/swap.c > index 7ede3eddc12a..607c48229a1d 100644 > --- a/mm/swap.c > +++ b/mm/swap.c > @@ -740,15 +740,20 @@ void release_pages(struct page **pages, int nr) > if (is_huge_zero_page(page)) > continue; > > - /* Device public page can not be huge page */ > - if (is_device_public_page(page)) { > + if (is_zone_device_page(page)) { > if (locked_pgdat) { > spin_unlock_irqrestore(&locked_pgdat->lru_lock, > flags); > locked_pgdat = NULL; > } > - put_devmap_managed_page(page); > - continue; > + /* > + * ZONE_DEVICE pages that return 'false' from > + * put_devmap_managed_page() do not require special > + * processing, and instead, expect a call to > + * put_page_testzero(). > + */ > + if (put_devmap_managed_page(page)) > + continue; > } > > page = compound_head(page); > -- > 2.20.1 > -- Michal Hocko SUSE Labs