From patchwork Tue Dec 10 22:05:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Price X-Patchwork-Id: 13902354 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 35B74E7717F for ; Tue, 10 Dec 2024 22:05:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B7AAC8D001D; Tue, 10 Dec 2024 17:05:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B27448D0017; Tue, 10 Dec 2024 17:05:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9A2A28D001D; Tue, 10 Dec 2024 17:05:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 6E13D8D0017 for ; Tue, 10 Dec 2024 17:05:47 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 367F580B9C for ; Tue, 10 Dec 2024 22:05:47 +0000 (UTC) X-FDA: 82880431872.11.A352A43 Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) by imf05.hostedemail.com (Postfix) with ESMTP id A6025100003 for ; Tue, 10 Dec 2024 22:05:02 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=gourry.net header.s=google header.b=pwIKHZSo; spf=pass (imf05.hostedemail.com: domain of gourry@gourry.net designates 209.85.160.176 as permitted sender) smtp.mailfrom=gourry@gourry.net; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733868330; 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=UvgUsC8+OSYl1zj6uOGNQd8LMwZ5SWRB4r93/t1srT0=; b=cKJxCstjPqj9R//itF73u0NeQeMEI/p9SnuIfsKqxeP2AGwCDbnyCe7dU8kcz8uvac/9jF 1B3JD3mMW6qZKAVmYKnaphmOLkZX9rrObSsHPkG6d/s3fKqvIS9Z2WIb6p0ZY1Zgga0o48 6Mi3FhNahNFM194QWGc66sLW7jObmgk= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=gourry.net header.s=google header.b=pwIKHZSo; spf=pass (imf05.hostedemail.com: domain of gourry@gourry.net designates 209.85.160.176 as permitted sender) smtp.mailfrom=gourry@gourry.net; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733868330; a=rsa-sha256; cv=none; b=RRvXFtrHUGbU+cRNr7jQNUZyaPYZMSrwuCedI0JLfwxtbj/yFa038xoGxQP6jXE11axmom woun3BJQy979oUNi7im/rt46ZVZqKBvNOYhc45wX/SnJ6S78epRuMeWlVJ1sd4PMnhtug9 19/JeXHPiWwDXG2Rq4up1TQa1VAZHWc= Received: by mail-qt1-f176.google.com with SMTP id d75a77b69052e-46741855f9bso31245291cf.2 for ; Tue, 10 Dec 2024 14:05:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1733868344; x=1734473144; 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=UvgUsC8+OSYl1zj6uOGNQd8LMwZ5SWRB4r93/t1srT0=; b=pwIKHZSoyeaHcu1lpCsErJZqvt4qclxbiz4si2UC8Tq2OTVudWndJIB6USfGvBzTaZ eC8mjBSjA8sAOYL9T4TFBQ+cpsMdRVYEGCyQfU/CzwcZkVpEos8GB/vQ1ZvsamX7QScT 3SxWCnNS8Cv64MR0pXmF1e4nKXcTqQf5F+Wj+wUDUgQDIDPBVd3LwKwC42In3c081erm gP9nR0aqhbsb5vQ2yW0ukIBJqquTMtfTwwVs1fnYRiCOFIzal66fAsF9jHSpGot+Zfte 6mLPvmYBw15GSaxrW2LL+RdV/vkeI6bNP31zqqorMf0/FVvx36A5VNsq7EzKTCiL56O4 atlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733868344; x=1734473144; 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=UvgUsC8+OSYl1zj6uOGNQd8LMwZ5SWRB4r93/t1srT0=; b=TzPazYU6PuIQEgWm5N8i0nzHk7vSQAGLt/6bDHQjErzB60ys1NLgKio1UMfSg6TF1A s7QEmsMwpDYX9RUoEatFdc+3hq3w+oLTLwICPITEjswlsfXK26pBIvtwjpL2aY48GGZx y12bYdj6Gw8nafH4U/H7AFhdpuSlNnREu1ARY3idHBtvOWEHcYuKs5y4dEL6fR8diTiB kdszpxTyKY4Ic7r3mycb8K2nwGAafVYTHu8ohp0ax5P9bPOHc7MoKSby5hA1kuGUx1zD Y32dw7jtfzpcWCErfy+jOrinySR/R/wOk0PiIsgJJT8WkvxAYr+z8sTnMA5PM9KOOaSt Mifw== X-Forwarded-Encrypted: i=1; AJvYcCWLckwyiBkAY7NAvyFWCCYi13/aWIGD6pLYPTYVJ5I7CzvvoTROQW8etb34dSfiWQBQgA0z49iLoQ==@kvack.org X-Gm-Message-State: AOJu0Yx4HHqygkH/31HTM27RXCPy5OBntN44AKgMOnmoRtNY90wfLOw2 FlX7NaolZBpq3EtBfXFw+xIlz6FWu/IUBp2jv8Ox70scF6PKA3HcIWToomFA6Oc= X-Gm-Gg: ASbGncuLTVIZH8fHPiP1whTNoVzQwoqim7aInQ8NFq8l2GAKVpEMSDJ2Vq4XpBRz2av chWlVkCsJ8QSVDTKmnvdA9xsr5Sl9SctQnWM0wDFhRpxHtNygJutIBRqi9vkr1yABSde/cC0Dbe WmFMLwNh5M97rNezFBgTJe8WI5AQSaI3BQ3h54/t/8IUv7tyoflgSOdouRoo78M3v3QFFG/cesn QyQmzR7IgB4GZu8CZ3XBTtkypqxZ67isaQHmKFn9DkUW5jmNWneUIB/I0nDdwwGBWYszQhLcVWO OK/lFmRf8MmT585Jz0FIsBNO+JPbggLXxl2uZV4= X-Google-Smtp-Source: AGHT+IE5ydpoL70LSKM9Nla3l7Xx3LL3OIA9p7ihHnld0+zQW3qbNmeKX9aX6FlxL/xgIC54FK+x8g== X-Received: by 2002:a05:6214:20a3:b0:6d8:b3a7:75a0 with SMTP id 6a1803df08f44-6d934c161d4mr12732836d6.47.1733868344301; Tue, 10 Dec 2024 14:05:44 -0800 (PST) Received: from PC2K9PVX.TheFacebook.com (pool-173-79-56-208.washdc.fios.verizon.net. [173.79.56.208]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6d8eeb132e1sm49707756d6.35.2024.12.10.14.05.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2024 14:05:43 -0800 (PST) From: Gregory Price To: x86@kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-mm@kvack.org Cc: linux-cxl@vger.kernel.org, kernel-team@meta.com, dan.j.williams@intel.com, ira.weiny@intel.com, gourry@gourry.net, dave.hansen@linux.intel.com, david@redhat.com, rppt@kernel.org, akpm@linux-foundation.org, luto@kernel.org, peterz@infradead.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, rafael@kernel.org, lenb@kernel.org, osalvador@suse.de, Fan Ni Subject: [PATCH v7 0/3] memory,x86,acpi: hotplug memory alignment advisement Date: Tue, 10 Dec 2024 17:05:14 -0500 Message-ID: <20241210220517.3744-1-gourry@gourry.net> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Rspamd-Server: rspam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Actu0I 7PyeSnepSmPizFVJV2p8WMRGmJKaklAZt7goWhGI6syeoRQFA9Ad0Tog92dUCQay/i/58CwGz1B8ocxltS4s1Os3BVGzTRgtyLSSoM+XA0EonlzssEUPSeEHgmbzd44LAhnH27Dv1Le1ATWWU/aGU6U9TCdSVM2eoBps40AIIVGzEbgz7CA0dQEMiTYUT0T5EcOCQKplk6wKR6n60J7I1HE3o4ZtPruJddjvFclkA/U6xRefxBaQ/8MgS00uRoIUUyOYIWlRdMshVZLaHTlrj2Iq28Sr7scg1TLG70Jo88MAgvMIYMPKdU5HL7Lk1JVyfJs7s8JbWNM9f8Nubzt21jSuUk9n3niX1x9hG1aq+B3abMHzyGc4X2MPx2JJsZAiUJ9DyaB4rDparHL9XjL73c3LPEA== 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: v7: collect tags and rebase on latest mm-unstable. ACKs: x86 MM, Memblock/MM Init, Memory Hotplug, and CXL Missing any critical acks? Best merge target seems -mm 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(-)