Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3921232ybi; Mon, 27 May 2019 08:04:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7x8iQ4bwpBln+LYcrRcL0StzsxsNaBoc5mfcL+PZWfLvAlcgPfNRVdQU1kvRNbr/rCSdy X-Received: by 2002:a17:90a:17c7:: with SMTP id q65mr31280372pja.92.1558969458221; Mon, 27 May 2019 08:04:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558969458; cv=none; d=google.com; s=arc-20160816; b=pquKTBQ2OdbY1L1ad1H5zDIPE3mCL+pmmugTjMtlrALD3zhngqFAfEjPcLyux9EnDI p4Q17yVypcaLIYEwDxvSgTV3ohJRyvsHVnifEW2lUOeDL/SYWLNE2JJeqdkFXGLl5fba 4JBjLBN1/AVS13ebIuRKR1RWYtXyxm9Cz5KKk9ubGWIdjh+v2Pea2HP3r54ux0HkPBZV AuXgZt6o030/iiS43Glwr3sebAcUBpNkkAi0nBlNYnGpqFID/CT4H2aSkyt7iJ5tGMkq Jj6E826pwKd1CrpWgnFNFqrCalHutBVgka3RPFqBTAq1/YHXN22Zf4fHJxxNYnOt6C1d 8gdA== 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=1GNZVkr57fgdF1rUp1cbQT5WCv4nVhkLxgTXkpSsqfk=; b=ECPh1VlA9D7yOjOmdPl9jLUpIRlPvWv2SKOH6rcib/X8NN91fcrSp0REepkJ1fZu55 o5uuOITjR6qt4xPsQgd3DtLGYDJU/3JavzwAmAimwxeIL24jKl0+DCf51zDZsZtH9wT9 SAqGBYcnhnLahAp+Dy9AxDhkICPOsYBTzTuuX2gB2+52IrQuysH0MDOEYUiBWA+xhUKf 5stVHVYLnOHvwKdtldL+o5kIi/0Mfstfdt5kYLM0LpUSJLYsH1/HuffwmBbDqrDGi3Ms 07o9/KgBMtwdo3OR5wTUNknliqnetXhTnBXANC8avcYr7dzE4MZUZt1EWupYwl1oF+sF uScA== 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 s30si4921959pgk.204.2019.05.27.08.04.00; Mon, 27 May 2019 08:04:18 -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 S1726772AbfE0PBK (ORCPT + 99 others); Mon, 27 May 2019 11:01:10 -0400 Received: from mx2.suse.de ([195.135.220.15]:48034 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726094AbfE0PBK (ORCPT ); Mon, 27 May 2019 11:01:10 -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 065A5AE74; Mon, 27 May 2019 15:01:08 +0000 (UTC) Date: Mon, 27 May 2019 17:01:07 +0200 From: Michal Hocko To: ira.weiny@intel.com Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, John Hubbard , =?iso-8859-1?B?Suly9G1l?= Glisse , Dan Williams Subject: Re: [PATCH v2] mm/swap: Fix release_pages() when releasing devmap pages Message-ID: <20190527150107.GG1658@dhcp22.suse.cz> References: <20190524173656.8339-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: <20190524173656.8339-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 On Fri 24-05-19 10:36:56, ira.weiny@intel.com wrote: > From: Ira Weiny > > Device pages can be more than type MEMORY_DEVICE_PUBLIC. > > Handle all device pages within release_pages() > > This was found via code inspection while determining if release_pages() > and the new put_user_pages() could be interchangeable. Please expand more about who is such a user and why does it use release_pages rather than put_*page API. The above changelog doesn't really help understanding what is the actual problem. I also do not understand the fix and a failure mode from release_pages is just scary. It is basically impossible to handle the error case. So what is going on here? > Cc: J?r?me Glisse > Cc: Michal Hocko > Reviewed-by: Dan Williams > Reviewed-by: John Hubbard > Signed-off-by: Ira Weiny > > --- > Changes from V1: > Add comment clarifying that put_devmap_managed_page() can still > fail. > Add Reviewed-by tags. > > mm/swap.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/mm/swap.c b/mm/swap.c > index 9d0432baddb0..f03b7b4bfb4f 100644 > --- a/mm/swap.c > +++ b/mm/swap.c > @@ -740,15 +740,18 @@ 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 can still fail here and will > + * therefore need put_page_testzero() > + */ > + if (put_devmap_managed_page(page)) > + continue; > } > > page = compound_head(page); > -- > 2.20.1 > -- Michal Hocko SUSE Labs