Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp809280pxb; Wed, 13 Jan 2021 17:06:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJzcFqiaa/dYgN1D+xwgDpsD9gLcKk4WYnuiyMAPHS2BCuPXnltxpZUAyXfnRWYipxkLxxeN X-Received: by 2002:a17:906:ce2b:: with SMTP id sd11mr3548171ejb.334.1610586388653; Wed, 13 Jan 2021 17:06:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610586388; cv=none; d=google.com; s=arc-20160816; b=lbvrrurujWwbNEqQ+jD1zoVTLEeflSXzLjY3PDZmWWYmzpIWDysljHzS0zFKq5p2eW MmO39+IvtmZKR5nBdNIhhxKLf28Foz98jcVJv96qFqiZ7VdZ0wx0m2hZ5VYwNJoMC0LO Lw9SGEAutd/MCF+KO4ECZryl76IMiOkYNxGDGssFI7JqDgi7JGT5Lu7qrzbfThGcrMQ9 ipaGltJ3sxn1se5/L/HWJ/xQKCkzVfSeRg9sQZPqnbRFtl/3zaS9zMNehCU3ZL2oyW+E WPV5FNkmhkApJeFZFD7kzyWzQafEFDOJLIoQOzQdPbaRhSW8k8oPeIe70dheXanO7po6 Pjpw== 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=oatXatewU3t38saqzyL0aBcBrH/atSCCLqTv5ex4/GA=; b=hZSusQam/CGlKdCz6HFQ+G3Ga7a0hI+ih1fDM/+y8n+ra6z0/E56nGHRe22YMY+S6M atDt2PMsmH6FTixoQNUP1uMr70yGMWzP5MZuU9DCrZAdts7aSLt4JWYJ8N6tHduZo662 obSSfqkJfttqCA0tSEZabYi9PcAhobk+782qnF3iQsIo/atXHTyBrl2M7NCWmtLT/Us0 3G8bLUBM3qZhDkINj/12ah7WbXB+1SOxPvZodqjV2bNLWpqctp/FPfjuj+kBsS9poi34 LUwzqE+SkUsAXiDmGGDBOpdJUQC6gdkKBwq6pMpIRIxJu0BVlTyGsaqh2LZez+u3Z+PR JmAQ== 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 o27si1943979edi.277.2021.01.13.17.05.41; Wed, 13 Jan 2021 17:06:28 -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 S1727265AbhANBAj (ORCPT + 99 others); Wed, 13 Jan 2021 20:00:39 -0500 Received: from mga17.intel.com ([192.55.52.151]:6925 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727024AbhANApm (ORCPT ); Wed, 13 Jan 2021 19:45:42 -0500 IronPort-SDR: yuqzCodrUONpkeA0J2IogJHSfr3RIlzyqCsak7G6INk/dufrLXfyubBtpjaGEfGbqsw3gYLBFM WZCB9SYHafhA== X-IronPort-AV: E=McAfee;i="6000,8403,9863"; a="158064366" X-IronPort-AV: E=Sophos;i="5.79,345,1602572400"; d="scan'208";a="158064366" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.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 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 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(-)