Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp157626pxb; Tue, 12 Jan 2021 23:38:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJyhxjLLBSqkt9Ge3RsybQXh4i8WpU6cI1tEeMC1GlZ1lqnOcbedfMUbHpv+/rWVK+CGPUSS X-Received: by 2002:a17:906:c00c:: with SMTP id e12mr609321ejz.103.1610523492935; Tue, 12 Jan 2021 23:38:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610523492; cv=none; d=google.com; s=arc-20160816; b=xcxl5wqldYwwhUnMPnnDIOK74PSF/qLAgP+sPTWi6VTE1lGRLqDZl9Q9WhAmOZotKk pjeBRtwnN2EYC4BSJJOqRfOcb4fqIGuRc4cOstqasix5CefeW4pLJnV/6DjTSvFGX25f U2u3OjJgdXdENwIBF63gWgoYZbvf8TYr8J/+HyBcmPoGz1i5ItT0nzdpY/9TH4OhrvNU mE9lFfAubtUJi3DHhDBdMhHCGQFgJNkc94ToKVmzrU97Eqb8cIEw4icUCz22fcrjigqz vGx3EsF+AJdPT4QqA/g3xrGeLGIzeZ/M7MDCZJJWmnzem9CXGdy7kSbp8mMgez9dkuW7 E+vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:message-id:date:cc:to:from:subject:ironport-sdr :ironport-sdr; bh=UmoM/MxSzqsRIiYpOCa6o/5rUh/d4Hz0TpBCBEHjj+E=; b=p9pO9YcoCtLFTnmTsk738OzA1elQPKJJAmeg55OsHxQv9RQSsYRj1LxZpCdykh2ysD 4x9osxg3wGaz+bsiSVJ7+8P+U69Y35fnwasSyHsYyk2o7DDCNXD2tRi0gc+gqGnZEbfA ZIblSlJPQdCUqTjqGtUsBoFJPrjF9eFViXTc86bhkr3dM2q0SfBm+iOViTPCwh3YfDHx mTcnExat5Jnr7bdLnfxUjtOyFYxbJrHUo9y+2NYGa1V09YBF/bvygIEyZfffHyNYRz2x WkxlW1rKnwzO6MbHC5/0sqnDZUSHtHlgDWLBLHWxAw2ofue9yiUwzKxc6TDXsfp3K3pd ppSw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dg4si586115edb.104.2021.01.12.23.37.49; Tue, 12 Jan 2021 23:38:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725873AbhAMHgB (ORCPT + 99 others); Wed, 13 Jan 2021 02:36:01 -0500 Received: from mga07.intel.com ([134.134.136.100]:20971 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725773AbhAMHgB (ORCPT ); Wed, 13 Jan 2021 02:36:01 -0500 IronPort-SDR: TNdWSHV2JbGEdHO1NabWomeULgWmrj243HsvUzor6nAxO2q7Ek/0gq0TKfWQQAeEZq9xFvUJR7 nwW+26exSAJw== X-IronPort-AV: E=McAfee;i="6000,8403,9862"; a="242238101" X-IronPort-AV: E=Sophos;i="5.79,343,1602572400"; d="scan'208";a="242238101" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2021 23:35:19 -0800 IronPort-SDR: R7U7SOlxIAask0dFOPSZ+iv/4TSvK3885rmAPXftCa0I6o/KodFyfMs5MpYz6914ji5DT++mEY igedmqs3aGCA== X-IronPort-AV: E=Sophos;i="5.79,343,1602572400"; d="scan'208";a="400456436" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.25]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2021 23:35:15 -0800 Subject: [PATCH v3 0/6] mm: Fix pfn_to_online_page() with respect to ZONE_DEVICE From: Dan Williams To: linux-mm@kvack.org Cc: David Hildenbrand , Dave Jiang , Ira Weiny , stable@vger.kernel.org, Naoya Horiguchi , Qian Cai , Michal Hocko , Oscar Salvador , Michal Hocko , Naoya Horiguchi , Vishal Verma , Andrew Morton , linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org Date: Tue, 12 Jan 2021 23:35:15 -0800 Message-ID: <161052331545.1805594.2356512831689786960.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Changes since v2 [1]: - Collect some reviewed-by's from David and Oscar - Rework subsection validity to include pfn_valid() gated by CONFIG_HAVE_ARCH_PFN_VALID (David, Oscar) - Introduce pgmap_pfn_valid() to validate metadata vs data in a pgmap (David) ! Kill put_ref_page(): the extra "if (ref_page) put_page(ref_page)" still feels more cluttered than adding a tiny helper. (Oscar) [1]: http://lore.kernel.org/r/161044407603.1482714.16630477578392768273.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/ The libnvdimm sysfs attribute visibility code was failing to publish the resource base for memmap=ss!nn defined namespaces. This is needed for the regression test for soft_offline_page(). 3/ 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 (6): 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 libnvdimm/namespace: Fix visibility of namespace resource attribute drivers/nvdimm/namespace_devs.c | 10 +++--- 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 | 70 +++++++++++++++++++++++++++++++++++++++ mm/memremap.c | 15 ++++++++ 7 files changed, 134 insertions(+), 32 deletions(-)