From patchwork Mon Jan 13 17:44:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Price X-Patchwork-Id: 13937844 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7413CC02180 for ; Mon, 13 Jan 2025 17:44:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E88396B007B; Mon, 13 Jan 2025 12:44:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E38046B0082; Mon, 13 Jan 2025 12:44:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD8866B0083; Mon, 13 Jan 2025 12:44:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A70EC6B007B for ; Mon, 13 Jan 2025 12:44:52 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 093A21A0209 for ; Mon, 13 Jan 2025 17:44:52 +0000 (UTC) X-FDA: 83003154024.21.C855527 Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) by imf22.hostedemail.com (Postfix) with ESMTP id 2A1F6C000C for ; Mon, 13 Jan 2025 17:44:49 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gourry.net header.s=google header.b=GNBUehNm; dmarc=none; spf=pass (imf22.hostedemail.com: domain of gourry@gourry.net designates 209.85.222.178 as permitted sender) smtp.mailfrom=gourry@gourry.net ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736790290; a=rsa-sha256; cv=none; b=f1ag9ABH98iRCKCikN8CBbo9cTq3O0Qg3ZSgbpy+aTfAZL7OvTEdyWEnA+DgRVjio8ifIW d9g2+vWL0z7H1PFIlnDe1FqnvDxieYPV2tErBHSqwhuWW9IfVn6/1MP5wmB8ohVnjJ98cM iNV5Ly/PWqKEk/gYo+RMQG6xhuA6eBA= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gourry.net header.s=google header.b=GNBUehNm; dmarc=none; spf=pass (imf22.hostedemail.com: domain of gourry@gourry.net designates 209.85.222.178 as permitted sender) smtp.mailfrom=gourry@gourry.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736790290; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=eZDY+roqlFWFlucPr2s+hwWgkw5ODZbVNYznP3NH7H8=; b=7oN5pYFKaRVdhTmGEh3qkbKP4E7rC/G3iJoQGKPH8fJqGO2fFaK06l1vPgVXybxi1pdldn 9KXqowrdw+bv9qSnT45RSJ2leXMuoXNjwk7obQRLI/TaHdL6uJ5Bv/PRydvoqe1pUE6fXY xpIM4hqFwwnUokAh0f0PRFTs27QYsH8= Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-7b6ff72ba5aso438189385a.1 for ; Mon, 13 Jan 2025 09:44:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1736790288; x=1737395088; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=eZDY+roqlFWFlucPr2s+hwWgkw5ODZbVNYznP3NH7H8=; b=GNBUehNm4Uow3R+xEVOwBHpOILowNsVSNz/U96RA4F7gvbCLvj6/qgaMYRlcZ+bjCM 1a0I8C6ywNMh/QT5FuF8y4U2eEmkWOmecH10NuTGM4bih/ow2KmYmjRMl3/GWd/TW2lT NiRn0F+GZkRWkU4UIVOIcJxMYDxOpNFF/+jsKZItZIw8JwWWpFQlfcHZxnrec7hWnGZP R/gmBObR20DMLpd9MeeUa02+T3D+ZhR986ewqzyJoSq4wMKRPaXf7GktDWiJvWc01jVn cUHLqsT6wRfTo9rZwmw9jOPJ7nzHOwibXLs3R64ZbNa51YGm1F3YQWWjhpYy0aclLpcb XuPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736790288; x=1737395088; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=eZDY+roqlFWFlucPr2s+hwWgkw5ODZbVNYznP3NH7H8=; b=wV7L3RxthwGbURUn+1oeQkwlSzRkQIxaKkoIzwmWSpk6z4hPdhpzV60+MlgPdxh6dt 2fvN1yPoRalNYRFUmY7B++nWvgqXoUcaXeMkXRoroIPMByZ8y4soxKeoHJP71r/ZshN3 j5SCyEafyecVyUEwFNClzK+Ja+D8JMv/1TCW5lYaSBz+qyeRh40o90/rppR9XmMJigi9 BelTEOd9Cdsk3YHLYEaTj0w2l9Gb+k0HHhq3//Tc3nKqrOSiHgbz+qsYEJ1K7ndE7seK gLfUAbwg8JnvABNseZKGsa42ckbNy2d/jU0s4eTLGKpTsHeVaZbSe40M7p/CK3qCBHMa P6KA== X-Gm-Message-State: AOJu0YyRgDCpfCHDpAliQem/zWOGesd2i8NrkG+aPPsK/PQ0KqhuEIwz 6HIbmLvL46HwrqBdAUFNO/hpXUfV4EYjg+3K14c/O5+SOkWvN2kHlP6IGOq28BuVv6GIVBrcYEn U X-Gm-Gg: ASbGncvO91P5KjrTnq1YOQjbslnQu6lRbAIEUBGAF325mXlqtSfJlgKpUpaG/9GR+Ua XH4Cu2+eUen/wc2qOrS4W2Su7rpZJFTV0CUq+kofmvxxn1eG+kORLZ/FNHh6z/TrJAElB6CJXzH eeauImW4JyPYzhNdj1rgR03uk4rXuLU+Bz9bEkmnrS/KUsCbawySl6Dc217NPZ+gtE8dUEJcEVF XZUT9LPuGsLXfayjiySuGiJwNfDJrGkrqO3HWw6ne/kQtw25315A/GXOCmUuJ6i/BObSTZrwq0E wCK5hcYhH/FCAWpXy1Afimnl0fk0gmO+dBFLgZqho3Nr X-Google-Smtp-Source: AGHT+IHX1aewgna2tPJ+Kpz+e7MVsUxTNCPKq11aXN8qXChUb+HG4maQWEFLCXjBLN1Qz50JhJ5yWg== X-Received: by 2002:a05:620a:248c:b0:7b7:106a:19a2 with SMTP id af79cd13be357-7bcd971c3f3mr3611917885a.31.1736790288625; Mon, 13 Jan 2025 09:44:48 -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 af79cd13be357-7bce3248c80sm511214185a.49.2025.01.13.09.44.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2025 09:44:47 -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: [RESEND v7 0/3] memory,x86,acpi: hotplug memory alignment advisement Date: Mon, 13 Jan 2025 12:44:36 -0500 Message-ID: <20250113174439.1965168-1-gourry@gourry.net> X-Mailer: git-send-email 2.47.1 MIME-Version: 1.0 X-Stat-Signature: adhhdrhxumrg1w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kZ5G 00a91ZLsxVR3nTwpJsTON/3auzj8QihORJ8Vrytni+ypz4/62Ni5EVN7l/8QZMk/Q+si2uQEsNkYh+OYznoXBVVTnShnUlNvk1kxU5coUWBPfHjXziNmsi9VESdUCl+grrNAOMPVxJYsj73pgmHUJdsjl14jjUwL3nr1KDlTPSfFCwCmsb95IoISvXGD5mNIyq/X8Gg2EuW5+N8BKeZ2J0J+/9zhVnTX8W/GQsw1OEfZSbwyMkLy0FNll2whx0j349NoY8eXOsTgfLuKtEE1JlDTbOOXZ9qhkDIIhR0W+3XNkeUiHFaucLCyvlfp7JX6dbC+mSYJeSpsd7efIFu6pCprXyfCxdkVw5OwuEdP1EwzeTKrLYFML/U+2EkZmXcEN6HfSDmZJJ+KSFsJRZ9ITi+Za+Q== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: resend: Not clear if this should go through -mm or -acpi clean rebase on mm-unstable as of Jan 13, no changes When physical address regions are not aligned to memory block size, the misaligned portion is lost (stranded capacity). Block size (min/max/selected) is architecture defined. Most architectures tend to use the minimum block size or some simplistic heurist. On x86, memory block size increases up to 2GB, and is otherwise fitted to the alignment of non-hotplug (i.e. not special purpose memory). CXL exposes its memory for management through the ACPI CEDT (CXL Early Detection Table) in a field called the CXL Fixed Memory Window. Per the CXL specification, this memory must be aligned to at least 256MB. When a CFMW aligns on a size less than the block size, this causes a loss of up to 2GB per CFMW on x86. It is not uncommon for CFMW to be allocated per-device - though this behavior is BIOS defined. This patch set provides 3 things: 1) implement advise/query functions in driverse/base/memory.c to report/query architecture agnostic hotplug block alignment advice. 2) update x86 memblock size logic to consider the hotplug advice 3) add code in acpi/numa/srat.c to report CFMW alignment advice The advisement interfaces are design to be called during arch_init code prior to allocator and smp_init. start_kernel will call these through setup_arch() (via acpi and mm/init_64.c on x86), which occurs prior to mm_core_init and smp_init - so no need for atomics. There's an attempt to signal callers to advise() that query has already occurred, but this is predicated on the notion that query actually occurs (which presently only happens on the x86 arch). This is to assist debugging future users. Otherwise, the advise() call has been marked __init to help static discovery of bad call times. Once query is called the first time, it will always return the same value. Interfaces return -EBUSY and 0 respectively on systems without hotplug. Suggested-by: Ira Weiny Suggested-by: David Hildenbrand Suggested-by: Dan Williams Acked-by: Mike Rapoport (Microsoft) Acked-by: David Hildenbrand Acked-by: Dan Williams Acked-by: Dave Hansen Signed-off-by: Gregory Price Tested-by: Fan Ni Gregory Price (3): memory: implement memory_block_advise/probe_max_size x86: probe memory block size advisement value during mm init acpi,srat: give memory block size advice based on CFMWS alignment arch/x86/mm/init_64.c | 15 ++++++++---- drivers/acpi/numa/srat.c | 12 ++++++++- drivers/base/memory.c | 53 ++++++++++++++++++++++++++++++++++++++++ include/linux/memory.h | 10 ++++++++ 4 files changed, 84 insertions(+), 6 deletions(-)