Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1804822pxa; Sun, 2 Aug 2020 22:20:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0zoqxtGVsLCLx76B6+Mul2UKtVSlJ512VM3MK4zEUf+InmCKiO2U6iwibbAagNodPz1H4 X-Received: by 2002:a17:906:7798:: with SMTP id s24mr14759954ejm.45.1596432021030; Sun, 02 Aug 2020 22:20:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596432021; cv=none; d=google.com; s=arc-20160816; b=atbWB2q6s67qx5NuMDenEi3NX/aej8JrzbOZ4SBqrpPcW5A10HqgSwNLfxV4rXAZx7 3t4Onyc2LgHF22sEZLPvJVH0yQ4sx8TWxoGvwOOFBMp/+eCJaQJtfCzrEh6j+w7os90U 68dGrIsZQF6EO1vzDaLSfNY/+YgfjjGcMImvS6cVK4qtjCFLwNdI9oSpEJAIUW/oYDb/ vz++Phyt5Zw9uBJln8joh/i2u25NpRuENZ2V6zVhxlxjZ81koNmfWUGDP1s3r3fFBU3f 65HoZ4Pzzxq3iT4GeX+le/ZpmIfiI0DcW5JR+zi6q6Hv4usQXwCBv8xN0Gejyua6cvaa 0clg== 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:cc:to:from :subject:ironport-sdr:ironport-sdr; bh=C/qhbnytiKA9XK4cBlQe0rIYMwomzGmHgUkQ6rkjzGg=; b=uQVJqS3Lu/5+YPMZQLqS7CCiENdp4/ZoJ/MZKXCKfQi1AEMt1p+l2tP3Scwen3oTo3 5A3Wx0he907zrsUXTrBAihpe1+Pixt2M+dU6diBtQGSK1v/gBTLTKgBanER4A4kSV8aJ +XIlTlVJRUOvogM96tJmEGNFaqmq5dNNIDO1iHVly67dATG1/ozoCETKaW9Zo+qV9Vux BTQ9HRp93I6oAfROneeqcI2pn8aVG+Dzd1MneFMNDPDDa2vnUtVriyhyUrpPOTmH7cvm A2GBmITsL9fe8TTO4KOMMUqe2K7bN6Hm0U1uTAxZFbk3rr/JS7ypRRZGGoR1lR+06dgE j3vQ== 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 r5si8908388edx.458.2020.08.02.22.19.59; Sun, 02 Aug 2020 22:20:21 -0700 (PDT) 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 S1728094AbgHCFTS (ORCPT + 99 others); Mon, 3 Aug 2020 01:19:18 -0400 Received: from mga02.intel.com ([134.134.136.20]:6218 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728032AbgHCFTR (ORCPT ); Mon, 3 Aug 2020 01:19:17 -0400 IronPort-SDR: v7GwaP82xsq4LjCxo4xMHuK7SWH46hyeQFif4uEv0D2S1gzAVzmV3WzgMtvnbT8oG7Ov0/HSiY rLSJgR71aGXQ== X-IronPort-AV: E=McAfee;i="6000,8403,9701"; a="139998186" X-IronPort-AV: E=Sophos;i="5.75,429,1589266800"; d="scan'208";a="139998186" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2020 22:19:16 -0700 IronPort-SDR: tRc5FfBYtgkxrQasf2CoiKdYkaJgZ+TQxSo7NSUfVXubARTu0J1yE4qGSRKMMSvMAxCbfefDHy ylgtynKOm6zA== X-IronPort-AV: E=Sophos;i="5.75,429,1589266800"; d="scan'208";a="291927658" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2020 22:19:16 -0700 Subject: [PATCH v4 06/23] mm/memory_hotplug: Introduce default phys_to_target_node() implementation From: Dan Williams To: akpm@linux-foundation.org Cc: David Hildenbrand , Mike Rapoport , Jia He , peterz@infradead.org, vishal.l.verma@intel.com, dave.hansen@linux.intel.com, ard.biesheuvel@linaro.org, vishal.l.verma@intel.com, linux-mm@kvack.org, linux-nvdimm@lists.01.org, joao.m.martins@oracle.com, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, dri-devel@lists.freedesktop.org Date: Sun, 02 Aug 2020 22:02:57 -0700 Message-ID: <159643097768.4062302.3135192588966888630.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <159643094279.4062302.17779410714418721328.stgit@dwillia2-desk3.amr.corp.intel.com> References: <159643094279.4062302.17779410714418721328.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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation to set a fallback value for dev_dax->target_node, introduce generic fallback helpers for phys_to_target_node() A generic implementation based on node-data or memblock was proposed, but as noted by Mike: "Here again, I would prefer to add a weak default for phys_to_target_node() because the "generic" implementation is not really generic. The fallback to reserved ranges is x86 specfic because on x86 most of the reserved areas is not in memblock.memory. AFAIK, no other architecture does this." The info message in the generic memory_add_physaddr_to_nid() implementation is fixed up to properly reflect that memory_add_physaddr_to_nid() communicates "online" node info and phys_to_target_node() indicates "target / to-be-onlined" node info. Cc: David Hildenbrand Cc: Mike Rapoport Cc: Jia He Signed-off-by: Dan Williams --- arch/x86/mm/numa.c | 1 - include/linux/memory_hotplug.h | 5 +++++ include/linux/numa.h | 11 ----------- mm/memory_hotplug.c | 10 +++++++++- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index f3805bbaa784..c62e274d52d0 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -917,7 +917,6 @@ int phys_to_target_node(phys_addr_t start) return meminfo_to_nid(&numa_reserved_meminfo, start); } -EXPORT_SYMBOL_GPL(phys_to_target_node); int memory_add_physaddr_to_nid(u64 start) { diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index 375515803cd8..dcdc7d6206d5 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -151,11 +151,16 @@ int add_pages(int nid, unsigned long start_pfn, unsigned long nr_pages, #ifdef CONFIG_NUMA extern int memory_add_physaddr_to_nid(u64 start); +extern int phys_to_target_node(u64 start); #else static inline int memory_add_physaddr_to_nid(u64 start) { return 0; } +static inline int phys_to_target_node(u64 start) +{ + return 0; +} #endif #ifdef CONFIG_HAVE_ARCH_NODEDATA_EXTENSION diff --git a/include/linux/numa.h b/include/linux/numa.h index a42df804679e..8cb33ccfb671 100644 --- a/include/linux/numa.h +++ b/include/linux/numa.h @@ -23,22 +23,11 @@ #ifdef CONFIG_NUMA /* Generic implementation available */ int numa_map_to_online_node(int node); - -/* - * Optional architecture specific implementation, users need a "depends - * on $ARCH" - */ -int phys_to_target_node(phys_addr_t addr); #else static inline int numa_map_to_online_node(int node) { return NUMA_NO_NODE; } - -static inline int phys_to_target_node(phys_addr_t addr) -{ - return NUMA_NO_NODE; -} #endif #endif /* _LINUX_NUMA_H */ diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index dcdf3271f87e..426b79adf529 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -353,11 +353,19 @@ int __ref __add_pages(int nid, unsigned long pfn, unsigned long nr_pages, #ifdef CONFIG_NUMA int __weak memory_add_physaddr_to_nid(u64 start) { - pr_info_once("Unknown target node for memory at 0x%llx, assuming node 0\n", + pr_info_once("Unknown online node for memory at 0x%llx, assuming node 0\n", start); return 0; } EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid); + +int __weak phys_to_target_node(u64 start) +{ + pr_info_once("Unknown target node for memory at 0x%llx, assuming node 0\n", + start); + return 0; +} +EXPORT_SYMBOL_GPL(phys_to_target_node); #endif /* find the smallest valid pfn in the range [start_pfn, end_pfn) */