From patchwork Thu Jan 14 00:43:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 12018035 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 047B5C433E0 for ; Thu, 14 Jan 2021 00:43:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7F0BD23382 for ; Thu, 14 Jan 2021 00:43:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7F0BD23382 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id ABF918D00A7; Wed, 13 Jan 2021 19:43:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A48B68D008E; Wed, 13 Jan 2021 19:43:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C2798D00A7; Wed, 13 Jan 2021 19:43:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0149.hostedemail.com [216.40.44.149]) by kanga.kvack.org (Postfix) with ESMTP id 717AB8D008E for ; Wed, 13 Jan 2021 19:43:15 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 39230181AC9CB for ; Thu, 14 Jan 2021 00:43:15 +0000 (UTC) X-FDA: 77702531550.28.ring84_480812c27522 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id 17B806D68 for ; Thu, 14 Jan 2021 00:43:15 +0000 (UTC) X-HE-Tag: ring84_480812c27522 X-Filterd-Recvd-Size: 4549 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Thu, 14 Jan 2021 00:43:13 +0000 (UTC) IronPort-SDR: V6pFu9aaHWAOfU/kSTKb9Q3TkpSH/uEWKapIqNSic38H61d0n81co8UlIzjUKnMDTX5HeNG7PN oA5IdpBMI2vA== X-IronPort-AV: E=McAfee;i="6000,8403,9863"; a="175709939" X-IronPort-AV: E=Sophos;i="5.79,345,1602572400"; d="scan'208";a="175709939" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jan 2021 16:43:11 -0800 IronPort-SDR: wzoTb6hc9d6sqSJukVWSRq9IMAjmL767ApWlY5EtFShw7qgNK9ZWF4BfFWxVMzbhr+x2kbIecu b0GJ+8ILSuOg== X-IronPort-AV: E=Sophos;i="5.79,345,1602572400"; d="scan'208";a="465080679" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.25]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jan 2021 16:43:10 -0800 Subject: [PATCH v4 0/5] mm: Fix pfn_to_online_page() with respect to ZONE_DEVICE From: Dan Williams To: akpm@linux-foundation.org Cc: David Hildenbrand , stable@vger.kernel.org, Naoya Horiguchi , Qian Cai , Michal Hocko , Oscar Salvador , Michal Hocko , Naoya Horiguchi , linux-mm@kvack.org, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org Date: Wed, 13 Jan 2021 16:43:10 -0800 Message-ID: <161058499000.1840162.702316708443239771.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Changes since v3 [1]: - Switch to "if (IS_ENABLED(CONFIG_HAVE_ARCH_PFN_VALID) && !pfn_valid(pfn))" (David) - Finish collecting reviewed-bys across all patches in the series - Drop the libnvdimm fixup, to be merged through nvdimm.git not -mm [1]: http://lore.kernel.org/r/161052331545.1805594.2356512831689786960.stgit@dwillia2-desk3.amr.corp.intel.com --- Andrew, All patches in this series have been reviewed and the kbuild-robot reports a build-success over 172 configs. They pass an updated version of the nvdimm unit tests to exercise corner cases of pfn_to_online_page() and get_dev_pagemap() [2], and apply cleanly to current -next. Please apply, thanks. [2]: http://lore.kernel.org/r/161052209289.1804207.11599120961607513911.stgit@dwillia2-desk3.amr.corp.intel.com --- Michal reminds that the discussion about how to ensure pfn-walkers do not get confused by ZONE_DEVICE pages never resolved. A pfn-walker that uses pfn_to_online_page() may inadvertently translate a pfn as online and in the page allocator, when it is offline managed by a ZONE_DEVICE mapping (details in Patch 3: ("mm: Teach pfn_to_online_page() about ZONE_DEVICE section collisions")). The 2 proposals under consideration are teach pfn_to_online_page() to be precise in the presence of mixed-zone sections, or teach the memory-add code to drop the System RAM associated with ZONE_DEVICE collisions. In order to not regress memory capacity by a few 10s to 100s of MiB the approach taken in this set is to add precision to pfn_to_online_page(). In the course of validating pfn_to_online_page() a couple other fixes fell out: 1/ soft_offline_page() fails to drop the reference taken in the madvise(..., MADV_SOFT_OFFLINE) case. 2/ memory_failure() uses get_dev_pagemap() to lookup ZONE_DEVICE pages, however that mapping may contain data pages and metadata raw pfns. Introduce pgmap_pfn_valid() to delineate the 2 types and fail the handling of raw metadata pfns. --- Dan Williams (5): mm: Move pfn_to_online_page() out of line mm: Teach pfn_to_online_page() to consider subsection validity mm: Teach pfn_to_online_page() about ZONE_DEVICE section collisions mm: Fix page reference leak in soft_offline_page() mm: Fix memory_failure() handling of dax-namespace metadata include/linux/memory_hotplug.h | 17 +--------- include/linux/memremap.h | 6 +++ include/linux/mmzone.h | 22 +++++++++---- mm/memory-failure.c | 26 +++++++++++++-- mm/memory_hotplug.c | 69 ++++++++++++++++++++++++++++++++++++++++ mm/memremap.c | 15 +++++++++ 6 files changed, 128 insertions(+), 27 deletions(-)