From patchwork Mon Jan 27 15:34:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Price X-Patchwork-Id: 860465 Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) (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 585C0149C53 for ; Mon, 27 Jan 2025 15:34:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737992059; cv=none; b=bZJ7L4TDadBULonpaJN+bUO6IDD7xBz+7MSWUHTVoJklMv87pmGhKpbi/nIhU89oHNdwNmky23hUQC8adID/SUbV50wqF1A6kQBx13S1VunThNKbH4iTOdVdNk0On49JHAbkyVNs4hehGXIHsMEd492+q/iC+D4HB43Z7HpPzY8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737992059; c=relaxed/simple; bh=JlIRardHN3T/rAzbVZsKRhQoD9nvYKKMQjOClOHhgOw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l4TUW8QUBtCRckPw5cQMAGOTpxsipQM+XthEQWzDXg3cF4ZYSgVdn+p5/kJKfyUDekBQ3FHiL7bYP74XhUBdX09+prKSjqsi+f86q2Ujvt4Bq40+o7nJeanaByh48wuClV5CEBioPkCTK4ib5VuDX+PHdDWnm3M+P7a6c/Gw+6c= 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.179 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-f179.google.com with SMTP id af79cd13be357-7b6e5ee6ac7so387317685a.0 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=v0cVkSJeo+K3kzUlGxL4tk85yFZaexiPhoSaofHnctZCDN7VrL3MxdieDySekLV0EF TuDs4P7cEuaHWZsR/ROO9FKmB6mFprO9Uy0jHLE119WTkdCkleFczxcWdNTj3BMs498l FUA3A/nKxjAvcabwZ7c96BdwOkoVdDDMtFf5psNTRbDo9r7VB/zub5vEZO6/gMwz0r9m i1rSHcK3jf7R05U0Tkh6wKJBPbJ/3xD5uEwiXl6HOw4Y1sjYFWY6USJoLwbcrK+mrTu9 GCOL8/9sx/SxRb031jLdnrMhwvsOTEkBIAdFyZWtq4dW/Qksi+jaPObB13VYvm4KJVaF zHHQ== X-Forwarded-Encrypted: i=1; AJvYcCUe0X0sR5EXjbWvX3hvxNHEEoNY6DEKMXX3WXzx8wOFXEUOm/E1wWhyRFQDGkBpXcad72DD2BoV4Tja@vger.kernel.org X-Gm-Message-State: AOJu0YyEC9cPON8e5S8R018aQcSciT25rLTWG4fZtjuwwh0TsFPRcPIy riXMPOXqkeISgkj38dAbDXTzY+BR8n+BeKrHSzFKMH59fXKSRcjtJvspqxwoYco= X-Gm-Gg: ASbGncsayfrngp5V0l0O0+RY5XCsywRrRTEPOZXNbpgc6S9TisRhc3UCezPv6+agbjt JTvkCp9TrvKVYV352qLVg6q33XFuA03EnNp5rHaAqf0FMvt/ijO+1s53vtRx7StcAUHIkkYtvJa 6JRZEDOtjvyyA9pJ4DhmS1EX0G7pTac1BvHWOhnth3Sc99TcsywE2BeD8NZ7CPvqLnBGpmb4v+G VhYMVRmZd7zUPIO2PnpLbkHqOgBBNCTRTQL47c/q1UmYOQ8BweBlxOeozXbPLsBwlDaR5V6iKq8 dAcFXuqNldpoDkIYINIx1Ahfho1DBYFqii9ODACqMkPDwwbzx7YbXSo6qlEzQFh1O9gK 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-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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); } + +/* 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 suggested + * 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 block + * 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 = min(memory_block_advised_size, size); + else + memory_block_advised_size = 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 the + * 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 = 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_groups_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 */ /* From patchwork Mon Jan 27 15:34:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Price X-Patchwork-Id: 860291 Received: from mail-qv1-f50.google.com (mail-qv1-f50.google.com [209.85.219.50]) (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 D640E14A4FF for ; Mon, 27 Jan 2025 15:34:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737992059; cv=none; b=NEcCzq+87NIUNwVnM6ZbXyr4m7ddC4xwWI6tKSBWknZaIgfO4xBd84EbpJg13EL0eXVfED7u/AoCrB3PYSur1AO4DHrXDoAuc6JFmDkdeI3kxeZCVZZ8rWKPKBm/lnfjOGF7TneMlXYHRaClFmhJDBaLglmrJOH1BfKh+XoDszk= 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.50 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-f50.google.com with SMTP id 6a1803df08f44-6dd01781b56so55509096d6.0 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=bMs9V09BX9/A16OYxpMJ+ceuBK47u80xvtA0UpzLMZXwFSa9zuOoDN0Pz67/hlMp/6 zX8uMRTUS9QdMoogWvrxx58+YGUNNndZDK29eIUqq61doPppDgklUpyRm1F4X00ybv9W p8mMEgRKPhsh6FTIaS9w3gEPOhjTb7Bux9yRin+AJxmzGXDcjr39Ag9Ut2Kn20d39s11 Ylg4UU5is/hDRPLrPELnnbBReYwem82FbRrNvrpRntL2To/uiAvZOIBFJdIK8kIyEKn3 mmM7QiTmhaFt/Xgug9D1dMLCII86C37M9+2nmf056LXpP8f3dCQFo3q3kLD4T7lzrT2i +x4Q== X-Forwarded-Encrypted: i=1; AJvYcCVt3BtydlWy5gbpDmbVbYW2EZSVOVipUsnGzCcW5E5SRTv+bg74cBYJ67IvWZTfKkDW64ughSF6n3E5@vger.kernel.org X-Gm-Message-State: AOJu0YzOKNTVAlVE0qIh6Mogusb3QpR7B5JnfojSd4xW0Av7GeKQaVji HHDFaGRSlc624yQuDCyOA4mbYEQ+qkCvMfWUpvX/K3/fvMDRYs98DtlrK9vvcvQ= X-Gm-Gg: ASbGncsr4EhZnERDdNTV2p7wdYDeynav7auR9kFHqmpsHCGBjWo/oUcwmvP4Xx2RCZG KVb6fb3LQIXPjqe32/rI8tK0XTsYbayVhh7hDpsLt7ILaoAhmQ7ksc56k+Oo8w+6JngW6ecxjqN PjKq0VIk+k9OoYXn8ZQNYV9op7pFKcnDdo1Lw9/6aMe65PdrQieoTeHBqtg2yvCe0O219VNMOIr J+xe+PZEqNRgMFpF51F6CoHL1bIbOyfLSjH+w2qxAeqeaInbaP3Nlw5Dr+ZHmspicekED7SZrEx KQdgHEGHTSquybGvlz7DBa9qX4bm2t9/CS2VXwCWhNC99Dz/hXgl2z6nBLNNUrVE2aQR 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-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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) } /* - * 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 = memory_block_advised_max_size(); + if (!bz) { bz = MAX_BLOCK_SIZE; - goto done; + if (!cpu_feature_enabled(X86_FEATURE_HYPERVISOR)) + goto done; + } else { + bz = max(min(bz, MAX_BLOCK_SIZE), MIN_MEMORY_BLOCK_SIZE); } /* Find the largest allowed block size that aligns to memory end */ - for (bz = MAX_BLOCK_SIZE; bz > MIN_MEMORY_BLOCK_SIZE; bz >>= 1) { + for (; bz > MIN_MEMORY_BLOCK_SIZE; bz >>= 1) { if (IS_ALIGNED(boot_mem_end, bz)) break; } From patchwork Mon Jan 27 15:34:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Price X-Patchwork-Id: 860464 Received: from mail-qv1-f50.google.com (mail-qv1-f50.google.com [209.85.219.50]) (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 8D0A8150997 for ; Mon, 27 Jan 2025 15:34:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737992061; cv=none; b=jP9Mf2QDTn1KN0zgKtWcUnrOj5fc+h5O5qo4mc2rP0DZJf9H0tJinkKNuxbnNAETakiwXcr2nazmZZzwqvf1XyjKHdeOTR9EINhLTUuUFnKKoxmDPnm7KoN/gpk7/a0iJSWuwhA8jcVEw4G2J/TS81kcPsVcuvaLraeJrF/P9XE= 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.50 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-f50.google.com with SMTP id 6a1803df08f44-6d8f75b31bfso46791276d6.3 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=LYoMecQuriBSWiC7XoLsbxNSQSQT7+Eq+hglHehCNCyB+BrpyySzyDdR9ZIeD/2tfn zheo1fVcipev2YRdXRq1VQ79v/5lO9pTbP+mMygDMAD7pFxf12Nm1DsgeDKdxNYL44sF gJ85sUnIEQiQ1H+taQRwJtK4Ej+ynBnUn/+621QROuK83W6BJN7y1TM37D7HA6Kqcmgt e6yRAqgqOWOCvHOWJLeeV/WYjLxpjfKHnCFE+UeN61swBCg40MaJ52rP3nayi98KXIad VxZb0hpkgxOylWWpii0hpgzuYftpImwyb7nfvU4hyF3WESrT9/SARtGFDUAFpfDeDhgY mNGA== X-Forwarded-Encrypted: i=1; AJvYcCVEWfbkJIWwlLigWBNaNgSEsIkXSY4lQfZSa2Z4iWcUqHzYahnNvkeKBb/6VsushyNWeoOSjdnZ00/l@vger.kernel.org X-Gm-Message-State: AOJu0Yy4WGtgEywVN+QzRWwtV8ARtDjJBR0dBjeDQDof7D6d+swG9jMK 91lZt+9FjS38dXFacQO7QFrpr6bs4kARKdTlFbQIg6F8eVYcunyIwmcUKkOsY/I= X-Gm-Gg: ASbGncsqnX9ibxOgNu2McTLQ8VNWpI4+BA+2U0UbWkCLqfnUXQHeyED/uuvjwN+KYf9 kMuH2+r5p7nPmbn+FPf3wtzjxvAHn3lB2rFE1GEpzOm76pdAUfrpQ4CgKAN9hjMt+a7Sc+6+T6V M2/vBpq7GL/aHK8jPQ/e7yTxdxW4/93qu1v7R5ka3gz2NsVqq/rPYu/5cM05mDVInq3z5zB4YFZ bVMZruPpjvgEoZKRBEE0U3bYUzb/7L1wwfEIoWChHMLNF5Sa0CpS/kUIM3Qvqu0TfD7JfvAryLI ZqacAavt0dsK/iexR9sgCXlgbUnnkIiGW25+xMX3289nu2h9YZ05g+wEsBxpki/zjsBb 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-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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_subtable_headers *header, { struct acpi_cedt_cfmws *cfmws; int *fake_pxm = arg; - u64 start, end; + u64 start, end, align; int node; + int err; cfmws = (struct acpi_cedt_cfmws *)header; start = cfmws->base_hpa; end = cfmws->base_hpa + cfmws->window_size; + /* Align memblock size to CFMW regions if possible */ + align = 1UL << __ffs(start | end); + if (align >= SZ_256M) { + err = 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