From nobody Wed Dec 17 11:02:15 2025 Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5739114B075 for ; Mon, 27 Jan 2025 15:34:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737992060; cv=none; b=ZGNFJB/0DhEWxT+D4i4Bngqpo+YgHKue/3IUgcdqxmjW8tA16CDLUnSBxSGxqerPciBoEcboa4+PGNmrhBSbLSYC2oYl7kGHAKPky9vNr+Q6CinezfM+WMMbVZofPc9LJR4JW88zOt48K7odVH5SgytTkRxRcIUYp7Ke6PTnUao= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737992060; c=relaxed/simple; bh=JlIRardHN3T/rAzbVZsKRhQoD9nvYKKMQjOClOHhgOw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dh9ClcOwZ1rVZyByFJCXaZmZMK3R+1gyjoRgDg68HiZlN+UjQo1BJKZJl3+ma+mE5J3ggxGLqhxZLtMN3a+ajtdB9qZZnNwvV3Wk+hpXkC4AC1CGWl5lj9uld4sqF/hCKa/ikvp7W12pyNRTQKPUVP+3UhU2kJJxwqtJPdQR2vA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net; spf=pass smtp.mailfrom=gourry.net; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b=dj2HA8rn; arc=none smtp.client-ip=209.85.222.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gourry.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b="dj2HA8rn" Received: by mail-qk1-f180.google.com with SMTP id af79cd13be357-7b6e9db19c8so444085085a.3 for ; Mon, 27 Jan 2025 07:34:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1737992054; x=1738596854; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WEKgJJf51nUXgtjwZFRtEbK89HKdrqyuzjYJ58simEs=; b=dj2HA8rnoFiTxa2S//p5IKk2K5BIQjRfAn3abJ2mMWWy6TnQtD9xorztaejAujGUWU zBL2Kl4tUIZhWpPiX+RQz378HZ8Qv6rYKStTbmptjz/70QrEQ9PchLOqUJFTyzn1+Ldw 4Ej7sxIqBhCNYYDSLn4IARkaepc8eCLxA66Np4KXPiCC9HFGePp6B43njBxjb2D7VZwh 6KmR/iIY0/n31hVt4WtH5BK/RCZRrKtNF/WweJeOcp7lhTXazamDfS4icCDgwHJRBobT HBRydsXIFvgYE8InEmsFB2IaeUJjicUYV7VDlpu7us7cBeoyCiuFk8uDTsADIt3R6TE0 aMjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737992054; x=1738596854; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WEKgJJf51nUXgtjwZFRtEbK89HKdrqyuzjYJ58simEs=; b=Yd9vdPEiJzhOLVbLOZi1pWVcF6Q9YF2MMU7xNdU9SgCU08SDnvYA0SWR1OD7XVsgPE CPPeSjVAMLPeGuIx9di1Gl1vnslTGvKZ3n1UHUUbstgPo5ovtLk5bo9dOMCStEeq603b ce9nlW1qy5+L/6wDAxX6LVas1GgWWTshQc6gxgY3WtGfy2iPy1RocvxQowKyQVC7Es/J 4lakYQIDsjxUpvS/FNLN3R2+GsUVv/Zqg8A6hMjo9A3DdnS/4PmistqfrA6MICarOh4x Ov+/YI6PNRYOPODlZkLwIw6RHi4PAGl6SBPqjhVBiUt45m9EwYdhgLnySFSc22aXG79K prbA== X-Forwarded-Encrypted: i=1; AJvYcCUKWxCNYe9PfFwn0+dUfA6vkRwh/rQ+a+oYREvbbxpmOK+KyzmMLvmuQf0VDg4k59yLyZsVUcT+cGGGeX4=@vger.kernel.org X-Gm-Message-State: AOJu0YxlTfSY3qbFImnYawCLpERkBXVpqTgw/Y4ZoCAroxIXyPzMEWXm Qcf0tcj5YJ6/6Uolgp6gICOek2ohTrOCQVVKCz0/ZFyn0XEoQxbfka7rTKEiGPbmsi+5MhQosic d X-Gm-Gg: ASbGnctNmgigui6S8Y/pem1cEerDKEdS8ut33jWF76mEnWIH3cUhLEaj3YA/DpV1+RR AWro4e7afLqXJ9sxGbb7BG4EZ93U4o4YY1pgTxxnOQrduDtbfSbObOAqYLD0pynqdhFWZ585fo1 M4TA/PKFTvZ44XuFuc49pkSCkk7u7kP/NWIOyM7aixoh2BmBcE+jPMbhx/UyGqA6VFDG3m5mzyb +uM2AwPX+NW6tsIlC4SoAenvJWP8p7cNWbA514Zoli9WJGSDYexhpMiNSvBsRDy7HLGSFizZJvI rMW/tAxdqhtP53kbPZPyYTKoFI0hxjXe2qPKu/7TxR3NNacGBZSi7Ly1JH0VJVQDGvEE X-Google-Smtp-Source: AGHT+IGoKs+d0lqDKVI9i+teoRAx9CQCD+e8LPsJoU6HHbn9z9w7GdlOVjcgcKDj1hULyXcfAypH2A== X-Received: by 2002:a05:6214:4b0f:b0:6e1:a36b:3445 with SMTP id 6a1803df08f44-6e1b21857c6mr708814736d6.19.1737992054132; Mon, 27 Jan 2025 07:34:14 -0800 (PST) Received: from gourry-fedora-PF4VCD3F.lan (pool-173-79-56-208.washdc.fios.verizon.net. [173.79.56.208]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6e2058c2a51sm35380476d6.109.2025.01.27.07.34.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2025 07:34:13 -0800 (PST) From: Gregory Price To: linux-mm@kvack.org, linux-acpi@vger.kernel.org Cc: kernel-team@meta.com, x86@kernel.org, linux-kernel@vger.kernel.org, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, rafael@kernel.org, lenb@kernel.org, david@redhat.com, osalvador@suse.de, gregkh@linuxfoundation.org, akpm@linux-foundation.org, dan.j.williams@intel.com, Jonathan.Cameron@huawei.com, alison.schofield@intel.com, rrichter@amd.com, rppt@kernel.org, gourry@gourry.net, bfaccini@nvidia.com, haibo1.xu@intel.com, dave.jiang@intel.com, Ira Weiny , Fan Ni Subject: [PATCH v8 1/3] memory: implement memory_block_advise/probe_max_size Date: Mon, 27 Jan 2025 10:34:03 -0500 Message-ID: <20250127153405.3379117-2-gourry@gourry.net> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250127153405.3379117-1-gourry@gourry.net> References: <20250127153405.3379117-1-gourry@gourry.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Hotplug memory sources may have opinions on what the memblock size should be - usually for alignment purposes. For example, CXL memory extents can be 256MB with a matching alignment. If this size/alignment is smaller than the block size, it can result in stranded capacity. Implement memory_block_advise_max_size for use prior to allocator init, for software to advise the system on the max block size. Implement memory_block_probe_max_size for use by arch init code to calculate the best block size. Use of advice is architecture defined. The probe value can never change after first probe. Calls to advise after probe will return -EBUSY to aid debugging. On systems without hotplug, always return -ENODEV and 0 respectively. Suggested-by: Ira Weiny Acked-by: David Hildenbrand Acked-by: Mike Rapoport (Microsoft) Acked-by: Dan Williams Tested-by: Fan Ni Reviewed-by: Ira Weiny Signed-off-by: Gregory Price Acked-by: Dave Hansen Acked-by: Oscar Salvador Suggested-by: Dan Williams Suggested-by: David Hildenbrand --- drivers/base/memory.c | 51 ++++++++++++++++++++++++++++++++++++++++++ include/linux/memory.h | 10 +++++++++ 2 files changed, 61 insertions(+) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 348c5dbbfa68..69feacbac3da 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -110,6 +110,57 @@ static void memory_block_release(struct device *dev) kfree(mem); } =20 + +/* Max block size to be set by memory_block_advise_max_size */ +static unsigned long memory_block_advised_size; +static bool memory_block_advised_size_queried; + +/** + * memory_block_advise_max_size() - advise memory hotplug on the max sugge= sted + * block size, usually for alignment. + * @size: suggestion for maximum block size. must be aligned on power of 2. + * + * Early boot software (pre-allocator init) may advise archs on the max bl= ock + * size. This value can only decrease after initialization, as the intent = is + * to identify the largest supported alignment for all sources. + * + * Use of this value is arch-defined, as is min/max block size. + * + * Return: 0 on success + * -EINVAL if size is 0 or not pow2 aligned + * -EBUSY if value has already been probed + */ +int __init memory_block_advise_max_size(unsigned long size) +{ + if (!size || !is_power_of_2(size)) + return -EINVAL; + + if (memory_block_advised_size_queried) + return -EBUSY; + + if (memory_block_advised_size) + memory_block_advised_size =3D min(memory_block_advised_size, size); + else + memory_block_advised_size =3D size; + + return 0; +} + +/** + * memory_block_advised_max_size() - query advised max hotplug block size. + * + * After the first call, the value can never change. Callers looking for t= he + * actual block size should use memory_block_size_bytes. This interface is + * intended for use by arch-init when initializing the hotplug block size. + * + * Return: advised size in bytes, or 0 if never set. + */ +unsigned long memory_block_advised_max_size(void) +{ + memory_block_advised_size_queried =3D true; + return memory_block_advised_size; +} + unsigned long __weak memory_block_size_bytes(void) { return MIN_MEMORY_BLOCK_SIZE; diff --git a/include/linux/memory.h b/include/linux/memory.h index c0afee5d126e..8202d0efbf46 100644 --- a/include/linux/memory.h +++ b/include/linux/memory.h @@ -149,6 +149,14 @@ static inline int hotplug_memory_notifier(notifier_fn_= t fn, int pri) { return 0; } +static inline int memory_block_advise_max_size(unsigned long size) +{ + return -ENODEV; +} +static inline unsigned long memory_block_advised_max_size(void) +{ + return 0; +} #else /* CONFIG_MEMORY_HOTPLUG */ extern int register_memory_notifier(struct notifier_block *nb); extern void unregister_memory_notifier(struct notifier_block *nb); @@ -181,6 +189,8 @@ int walk_dynamic_memory_groups(int nid, walk_memory_gro= ups_func_t func, void memory_block_add_nid(struct memory_block *mem, int nid, enum meminit_context context); #endif /* CONFIG_NUMA */ +int memory_block_advise_max_size(unsigned long size); +unsigned long memory_block_advised_max_size(void); #endif /* CONFIG_MEMORY_HOTPLUG */ =20 /* --=20 2.48.1 From nobody Wed Dec 17 11:02:15 2025 Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7BEAC149C7D for ; Mon, 27 Jan 2025 15:34:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737992059; cv=none; b=LFSSrtpxRQmTDdt8MLJ2bPQ3P0CF2/qcD2eQ9Ts21gKMpDQcweocbJ2P1LcoSXpelyk67fAz/Ef6tZpsDrb0zXKuSMbGxGrF/Gd8Djgzc7OAt9a95RY4Zx19+o3O7H9qVTOScNVj060L5Qv60Jdp5ZhlPQAnDK0mE1ABYk+O5Zo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737992059; c=relaxed/simple; bh=9Bnw9+CkdHqaCLM0YEFQRfjPOnve6pPOiFVrRE8u43Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sXy0zu08JpNggFJ/gC/gBET9f4073NTit7OsQ7wIqLdJzuBCmAoEL8STlzN7j+NXcjpa3ShLyJJSYIb/YL/IkB656/iuOVkjEQy1i452mMhUxDoBRLfQEi2Y5obHJa6thoHgDxCNgzhF61hUfzek7FIpmo6i3BTapOdFyo0SD6U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net; spf=pass smtp.mailfrom=gourry.net; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b=lQIjy5KV; arc=none smtp.client-ip=209.85.219.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gourry.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b="lQIjy5KV" Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-6dcdd9a3e54so46012156d6.3 for ; Mon, 27 Jan 2025 07:34:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1737992056; x=1738596856; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cuGLm5QAWvME/iYTUeN4C38ZerEmS6SWYSvNtkJw+ks=; b=lQIjy5KVxE7WdL4ONGFzbxw4loh5PvryKwkMZJVwnKzMzHjpVIrznT7yXaX2Rus86I rRBbSR5SAvDfJOkX0Sj8eYL0+hpsqXbFoRvEYdc+5W52BWbTmeaAx9GnLWoDVD99mNDk OAQKoN/EHBKIwEg9B7AXfgwgAHO2WuGcURW1ZGMTutNyq7R9vq9DfKfQrNJnbrFCuP/3 z0JhYNARN0ixszY+/J2sXLIpm7BM2c4yGFuc+guvVLfe4MvGEHQ5jeLT6YRb0kexxZev 06iF2WBi8u46Il4Yk83+2i0WX6SsJ4ZN4oNatwRatbj4uAbK5AefpfOtwb1bYx1YR/xm URAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737992056; x=1738596856; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cuGLm5QAWvME/iYTUeN4C38ZerEmS6SWYSvNtkJw+ks=; b=AHLwJesWkh5MLcu54grcYc4Dejp1VuPoGE11PfHfdjDllj5L6QEAlYs70sTShMbv3G jzHs//BIkQzv+Zg8kK98WFjAbERQqqj1vBveSr5SHyeCPTy4Wt4KN/7go/X7oil3sk5+ 5D66njOF4MtX22b1Fi/Pwv4MjCYOOQgelYQuWbYwFSc41/qXX9LH268C0Pmtn1Chr5t0 uOEo4aCkApyIy34QdijxDGmi0Td8aMeEDcMF1yIVQpRUrg4W4y8Hnm1N+Ir6XEjBwbAr AFCgWP1icJYX/zaRpcAsVL6gTC0KJ/OyvnC37CSt/+vhVyJRnr1fsLD2Xeh807otRGv6 ijZw== X-Forwarded-Encrypted: i=1; AJvYcCUrSfAZ6ENTiJJg/2N3ZnfWS0llESMLZu99t7IGRegZuXhCljhqbiMrQxHxP2iWTRzgDs/s+BhWJd1Jk4A=@vger.kernel.org X-Gm-Message-State: AOJu0Yyc28yUiQY6oNJLFieDn5GsjQL91sdQYCcQ3Hbo0/Bkoc2BE6nc IK+EfWqsz/RvliJqaTtbsmHt7D2FlWqj72cD8QID7BAUslpBu+UgOqSc7nr8Tcw= X-Gm-Gg: ASbGncsmiT0EmFReIwT6my6LVMwib719BvBUr8fCWaiuiC7vXNEEwR+gp8AkSliQXMg B1npGKfEOmxxozksVrPFkAlF+egrgyp81Sp4eBP7eYPSMUlIBBjgD7Pt7YYJKfsALqOpSjrAnO2 afk32o0iW8IRpzMqmkGG8jYxG+fIlnudX5TLaL3yha6Zt9ZX3fvWcZDKz5qqsj2al+/IrVZsQqf ZK3CEdEHCsWS5NvGN80VV3vrjnMC45fWe6EYktKc81WBlCf+tiliGDKBv7TCCRLeQ6nwSi0TFg0 dX5wyVkeOZteoT39Yhut0vdMau5Yxvizk+/kVVjWEeT0BBHpZFek9Exi+MkBxpwOczqk X-Google-Smtp-Source: AGHT+IH3YD2uq0s2UOyUMAffGvHi1zghb5NCWsDgLZca9QQje9OVBrkdwmDEWT3QH9fizy2t68UjHA== X-Received: by 2002:a05:6214:1248:b0:6d8:b3ee:8b72 with SMTP id 6a1803df08f44-6e1b2229d49mr616446186d6.32.1737992056362; Mon, 27 Jan 2025 07:34:16 -0800 (PST) Received: from gourry-fedora-PF4VCD3F.lan (pool-173-79-56-208.washdc.fios.verizon.net. [173.79.56.208]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6e2058c2a51sm35380476d6.109.2025.01.27.07.34.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2025 07:34:15 -0800 (PST) From: Gregory Price To: linux-mm@kvack.org, linux-acpi@vger.kernel.org Cc: kernel-team@meta.com, x86@kernel.org, linux-kernel@vger.kernel.org, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, rafael@kernel.org, lenb@kernel.org, david@redhat.com, osalvador@suse.de, gregkh@linuxfoundation.org, akpm@linux-foundation.org, dan.j.williams@intel.com, Jonathan.Cameron@huawei.com, alison.schofield@intel.com, rrichter@amd.com, rppt@kernel.org, gourry@gourry.net, bfaccini@nvidia.com, haibo1.xu@intel.com, dave.jiang@intel.com, Fan Ni , Ira Weiny Subject: [PATCH v8 2/3] x86: probe memory block size advisement value during mm init Date: Mon, 27 Jan 2025 10:34:04 -0500 Message-ID: <20250127153405.3379117-3-gourry@gourry.net> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250127153405.3379117-1-gourry@gourry.net> References: <20250127153405.3379117-1-gourry@gourry.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Systems with hotplug may provide an advisement value on what the memblock size should be. Probe this value when the rest of the configuration values are considered. The new heuristic is as follows 1) set_memory_block_size_order value if already set (cmdline param) 2) minimum block size if memory is less than large block limit 3) if no hotplug advice: Max block size if system is bare-metal, otherwise use end of memory alignment. 4) if hotplug advice: lesser of advice and end of memory alignment. Convert to cpu_feature_enabled() while at it.[1] [1] https://lore.kernel.org/all/20241031103401.GBZyNdGQ-ZyXKyzC_z@fat_crate= .local/ Suggested-by: Borislav Petkov Suggested-by: David Hildenbrand Acked-by: David Hildenbrand Acked-by: Dave Hansen Acked-by: Mike Rapoport (Microsoft) Acked-by: Dan Williams Tested-by: Fan Ni Reviewed-by: Ira Weiny Signed-off-by: Gregory Price Acked-by: Oscar Salvador Suggested-by: Dan Williams Suggested-by: Ira Weiny --- arch/x86/mm/init_64.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index 01ea7c6df303..58ace82874eb 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -1462,16 +1462,21 @@ static unsigned long probe_memory_block_size(void) } =20 /* - * Use max block size to minimize overhead on bare metal, where - * alignment for memory hotplug isn't a concern. + * When hotplug alignment is not a concern, maximize blocksize + * to minimize overhead. Otherwise, align to the lesser of advice + * alignment and end of memory alignment. */ - if (!boot_cpu_has(X86_FEATURE_HYPERVISOR)) { + bz =3D memory_block_advised_max_size(); + if (!bz) { bz =3D MAX_BLOCK_SIZE; - goto done; + if (!cpu_feature_enabled(X86_FEATURE_HYPERVISOR)) + goto done; + } else { + bz =3D max(min(bz, MAX_BLOCK_SIZE), MIN_MEMORY_BLOCK_SIZE); } =20 /* Find the largest allowed block size that aligns to memory end */ - for (bz =3D MAX_BLOCK_SIZE; bz > MIN_MEMORY_BLOCK_SIZE; bz >>=3D 1) { + for (; bz > MIN_MEMORY_BLOCK_SIZE; bz >>=3D 1) { if (IS_ALIGNED(boot_mem_end, bz)) break; } --=20 2.48.1 From nobody Wed Dec 17 11:02:15 2025 Received: from mail-qv1-f52.google.com (mail-qv1-f52.google.com [209.85.219.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 771747083D for ; Mon, 27 Jan 2025 15:34:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737992061; cv=none; b=r4B6dHc//UuEwiguYxPpLZCnhxC69iU4leMdbzNMnB+Z3cMXTqsfdqvaFKg8IhRgz1SoZFALGqobYwc66MQi4B3rhrPnpheGOVLUANKuDTycCMEIRKqZ+Dr+gPYgJZjt5kWnLxtFG9notWoxl/bSjGRKYt7Xl/ZlwM7FDQMqrb8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737992061; c=relaxed/simple; bh=V5XzW7xlrKvXPXLFvpi5tASensizwqikatEr538IoTI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MMB74Mtr9WzaRk1EFkVesf1xNwdh202c5GeanxXDSRk25ms+24SQ5xcfcNWsr1r8kcGVkIRZHRItqoS8Zq/cKWvFSpsidmJGEorLyYGDr+cMf5gucYGeSdW2d0AKYMGHNifh8pOtsXlwcyvzkLC9H7cT5xVXh5c7fNLLqdWL3HM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net; spf=pass smtp.mailfrom=gourry.net; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b=I6Qihem8; arc=none smtp.client-ip=209.85.219.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gourry.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b="I6Qihem8" Received: by mail-qv1-f52.google.com with SMTP id 6a1803df08f44-6dd5c544813so48019176d6.1 for ; Mon, 27 Jan 2025 07:34:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1737992058; x=1738596858; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=K2QKacaR1w2J0DOe/2A1iWnNo84Ql16Satbz8d4J348=; b=I6Qihem8NkNlByKXTVIOrHtSfvD6cEaI2153UUHcAIOPJyPivhUovH3TYW4lrlVd5t Jeh14cZc2ckY1pcYgKN3sEFW6Z4tTwrievFQtAkVy4DHkf+vT7DyaDxxwhjPXru2kUyp AsD/OjyUWvx0udby4wvvV0sKXv+DKMLFtfRaixIK2WE0fYugqI5tL7tfLXqSJHOe6PXq ZzilYMrnFWPU3gc965sG1J5Ty30mlwf0dX6LJtSwWPTw+hA5JO4qR+a3l9VVs3PP3rZ+ W8NKnyj6Y38xutKIv7muyZAIXAj1qJ7P0M/sRPUrBuIp5z+SaoBDXmeTuRMb6gwpomWf QRrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737992058; x=1738596858; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=K2QKacaR1w2J0DOe/2A1iWnNo84Ql16Satbz8d4J348=; b=Dwb4ZhjTTWXR0azedIDaLVe31CyGw5/5y67kU4OHHFjc07dlUhZIBC9A1iR7iH32WZ ygHqVMRn2a4v7oXNe9nNr2t9k6gN43r2VS9RGYl+AbzVWgzO6xsLODpyJ1tbCk0xOPpq ZJaLZOXok4VQLP6p9n75kwUCnYpFiuFw5gZYqVH091mgzbCqACSPKBuMtoymS5DlblX/ Weu3+Q0utP2NQgir3HSVY66HCHrQB1T7XPm6A4sc1UmQzQcv/2mxutOn2aT/rw1zgSr+ m+QH+4lMqrKh0atB52lgpBwT7r7numRX4thPNrilDjoLUGh3J/ka9QM9y2tH/hFf35kr 3PmQ== X-Forwarded-Encrypted: i=1; AJvYcCXbBcn999ffHqWYOSqBQYDGgO2iVY/dKNBHAz9k/lbaT0xkBHRqZo6z6FdFh3nNby1JpIIdrSQpfQt0LPI=@vger.kernel.org X-Gm-Message-State: AOJu0YxiP6fBOaCpJnSEsTtSkTPTmf78u1otNcU+W4UKUP0QEoKvyRbm Dk3BBI1v7UqHixEp9UVWFCyAwTBgp00P1955/Hrtc92Jv6jQR/fTS8nFMLcFQ+U= X-Gm-Gg: ASbGncvHeDhm7dvahDPEIZ8/NvELVtjIiXvvN5YnDnkKlEbyjgSzI8MurRi57Q0ghGO bFwpiexSUwEoLc8gAhSPKSjQ5kvxAf6/CDPm0Xe6/SdLGZTKCMB3+qG2AwgxHeY5783SbuWGGBd vfg1xDWKoc9hpW4F0LCs8f4lYh6ShUmVFzP1GhrCfsgYb9EaRPutJ1O2Bevgj9b34PljjJLP6cV bRbV7ohAS52xKKRlvkHEdR/jEQxtfETLDkyivZjRMBKVBkefPH8A1pIWED9PV3aH4b1d6teQpQG SyF83qhUbbVfy9ee66eODHEsJ5qw/hDtuhe2yqmgknyVpXdpLCXESq4t+MPZfG33V6qU X-Google-Smtp-Source: AGHT+IEloh1Kwttg6pCvanJlLHnirCN2YmmH2PFhQey08HdVHFNPfJ5MgRHGu5KGGQRd7g7bqkubRw== X-Received: by 2002:a05:6214:2584:b0:6cb:ee08:c1e8 with SMTP id 6a1803df08f44-6e1b21b7b81mr667790436d6.23.1737992058363; Mon, 27 Jan 2025 07:34:18 -0800 (PST) Received: from gourry-fedora-PF4VCD3F.lan (pool-173-79-56-208.washdc.fios.verizon.net. [173.79.56.208]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6e2058c2a51sm35380476d6.109.2025.01.27.07.34.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2025 07:34:18 -0800 (PST) From: Gregory Price To: linux-mm@kvack.org, linux-acpi@vger.kernel.org Cc: kernel-team@meta.com, x86@kernel.org, linux-kernel@vger.kernel.org, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, rafael@kernel.org, lenb@kernel.org, david@redhat.com, osalvador@suse.de, gregkh@linuxfoundation.org, akpm@linux-foundation.org, dan.j.williams@intel.com, Jonathan.Cameron@huawei.com, alison.schofield@intel.com, rrichter@amd.com, rppt@kernel.org, gourry@gourry.net, bfaccini@nvidia.com, haibo1.xu@intel.com, dave.jiang@intel.com, Fan Ni , "Rafael J. Wysocki" , Ira Weiny Subject: [PATCH v8 3/3] acpi,srat: give memory block size advice based on CFMWS alignment Date: Mon, 27 Jan 2025 10:34:05 -0500 Message-ID: <20250127153405.3379117-4-gourry@gourry.net> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250127153405.3379117-1-gourry@gourry.net> References: <20250127153405.3379117-1-gourry@gourry.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Capacity is stranded when CFMWS regions are not aligned to block size. On x86, block size increases with capacity (2G blocks @ 64G capacity). Use CFMWS base/size to report memory block size alignment advice. Suggested-by: Dan Williams Acked-by: Mike Rapoport (Microsoft) Acked-by: David Hildenbrand Acked-by: Dan Williams Tested-by: Fan Ni Acked-by: Rafael J. Wysocki Reviewed-by: Ira Weiny Signed-off-by: Gregory Price Acked-by: Dave Hansen Acked-by: Oscar Salvador Suggested-by: David Hildenbrand Suggested-by: Ira Weiny --- drivers/acpi/numa/srat.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c index 59fffe34c9d0..1501a9bb3936 100644 --- a/drivers/acpi/numa/srat.c +++ b/drivers/acpi/numa/srat.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -425,13 +426,23 @@ static int __init acpi_parse_cfmws(union acpi_subtabl= e_headers *header, { struct acpi_cedt_cfmws *cfmws; int *fake_pxm =3D arg; - u64 start, end; + u64 start, end, align; int node; + int err; =20 cfmws =3D (struct acpi_cedt_cfmws *)header; start =3D cfmws->base_hpa; end =3D cfmws->base_hpa + cfmws->window_size; =20 + /* Align memblock size to CFMW regions if possible */ + align =3D 1UL << __ffs(start | end); + if (align >=3D SZ_256M) { + err =3D memory_block_advise_max_size(align); + if (err) + pr_warn("CFMWS: memblock size advise failed (%d)\n", err); + } else + pr_err("CFMWS: [BIOS BUG] base/size alignment violates spec\n"); + /* * The SRAT may have already described NUMA details for all, * or a portion of, this CFMWS HPA range. Extend the memblks --=20 2.48.1