Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3799099ybi; Mon, 29 Jul 2019 12:51:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5I3WedFqCBHNh4ldaWMwN570Di3gyj236B3v6hsDvYCxVcoWhAtZuQmqkpxyjAzs2mPps X-Received: by 2002:a62:e710:: with SMTP id s16mr39426623pfh.183.1564429893895; Mon, 29 Jul 2019 12:51:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564429893; cv=none; d=google.com; s=arc-20160816; b=dAS+JJ0IkGcF8OHjNOK92JOxNpFOPJ9OwPiCY2xpMgZSjTELa99MVT3qTLk/cnSIki BaeiPydR8Gxuh8lm15tNTbx1WFMQ2nlDmiQlceH95W5eKNtMNI5CPZKvKrGQZNJkuZFn mhMbH8EUFX5N0Uq/fmGokT5tnQ4IjSOFznA0NG5HoD9UUrpqm3PyDvoso8iBDCXiG8i4 WYh7Yu2lQ714ff4FdDCiOMfkv/aUDwqal2VtvpO+n4Ji7k9MkUVjz6YbgTbNoTBawM39 JBWxo4KISsx5gWPrdFgsg1QAEhdpCabTrx+uU8HvUkWjhyR2rwnTfiZUt03oNxBKbE8E ZKhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/sIwuw9TViiEINWXQNYQEuD/eHuucj61ykvxarifmu4=; b=hx7vR2C1QFmGEP63xcAGoevfpmAt3N506c/37vHx+ZEAcYoLbd/sdOs+fYaWVxNW5D LKeTcOxih9Q/IiaeKXA10CJoXkIg2KIzs9eH6VAZVXOih1C9elwACNQ71l+QkgD4cCbG 1USG6U0fSHBwUs/Hp+CFyej6L9eDcUV/tA1xEQjHGutBmDX6dv+Ef9LkHjQWhhVb3lOV aQN04ntuLR0jQSLBqeVelYCrc/qTXA/Xxh98HYLFmB5+TxA23wh0iPi0qdYaPOV1wr/2 BQ1j1C0h1UbJZEjdWOwjghlgmKDGfJuxtmnNoeXi9e7ytv+RArrMi2nDr8nWldOchA8T GZ4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zFJvbW7A; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t185si18054337pgb.329.2019.07.29.12.51.18; Mon, 29 Jul 2019 12:51:33 -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; dkim=pass header.i=@kernel.org header.s=default header.b=zFJvbW7A; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390633AbfG2TuE (ORCPT + 99 others); Mon, 29 Jul 2019 15:50:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:40834 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389663AbfG2TuD (ORCPT ); Mon, 29 Jul 2019 15:50:03 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5D0E32171F; Mon, 29 Jul 2019 19:50:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429801; bh=Iy8qZVQ3LH2D9XH8iObm2cxeJ+sPEDDHwG2eVfTr+sk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zFJvbW7AhPD2J6UkFYxEGmXeb4gO4+Cz77H95R3tdKp1Hc5ZwgWU+YrwHIOxDXwPK bY/7kgk5J2fAApMUDmhqDmkDjC25kMWX1X2EwBh7MwRWEu7BUMqv5BBc2cHbvsAimU BLXAPS4kYKX8r5SvB2Lib/Y9vkAkNFxrVCSN3S0I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Michal Hocko , Dan Williams , John Hubbard , Ira Weiny , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.2 100/215] mm/swap: fix release_pages() when releasing devmap pages Date: Mon, 29 Jul 2019 21:21:36 +0200 Message-Id: <20190729190756.417958947@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit c5d6c45e90c49150670346967971e14576afd7f1 ] 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] [1] https://lkml.kernel.org/r/20190523172852.GA27175@iweiny-DESK2.sc.intel.com Link: https://lkml.kernel.org/r/20190605214922.17684-1-ira.weiny@intel.com Cc: Jérôme Glisse Cc: Michal Hocko Reviewed-by: Dan Williams Reviewed-by: John Hubbard Signed-off-by: Ira Weiny Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- 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