From patchwork Wed Nov 6 15:58:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Price X-Patchwork-Id: 13865121 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 2EB48D59F48 for ; Wed, 6 Nov 2024 15:59:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A83FD6B00A6; Wed, 6 Nov 2024 10:59:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A0E346B00AA; Wed, 6 Nov 2024 10:59:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 887296B00AC; Wed, 6 Nov 2024 10:59:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 6B79B6B00A6 for ; Wed, 6 Nov 2024 10:59:04 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C1518C0C16 for ; Wed, 6 Nov 2024 15:59:03 +0000 (UTC) X-FDA: 82756127916.10.EAF743E Received: from mail-ua1-f51.google.com (mail-ua1-f51.google.com [209.85.222.51]) by imf13.hostedemail.com (Postfix) with ESMTP id 209072000F for ; Wed, 6 Nov 2024 15:58:25 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gourry.net header.s=google header.b="e6ga7/PW"; dmarc=none; spf=pass (imf13.hostedemail.com: domain of gourry@gourry.net designates 209.85.222.51 as permitted sender) smtp.mailfrom=gourry@gourry.net ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730908572; a=rsa-sha256; cv=none; b=cXWQc//CmBc6Nrm2YVgGFeFJ0YMoVUJNvawP+R/hd9fGsziP+I4SC2UQsuyJhlytIX/7+v jaSLZTJ0Osy9UH5PKNvlZ99HDchmvEml7pt73omV/eJiwWVeW+N13nQron9LrxZXxdxv7f LtrnA2j30X6yQXy/+JB4CpUKxIJafA8= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=gourry.net header.s=google header.b="e6ga7/PW"; dmarc=none; spf=pass (imf13.hostedemail.com: domain of gourry@gourry.net designates 209.85.222.51 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=1730908572; 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=onjaUxq9jxQzB8yd13QCSLIfBZyPKRSn2LqnOpXSgfY=; b=nqAanfnpgy2H21Ub66PCfcTKs3J8CQDluNYxPoE7zhKXfzROCCbbpIfsAO76gc7IBm6dqx WtbIf2U2TSJe15icy95xOMAlpbkMj9E1yq6moMy6992/+O//GIkoqOfRC0sVs99Kfm2uN7 FEdWFo7+lS+FNNIoM9gUobQRutrD3no= Received: by mail-ua1-f51.google.com with SMTP id a1e0cc1a2514c-84fd2310413so2388992241.0 for ; Wed, 06 Nov 2024 07:59:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1730908740; x=1731513540; 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=onjaUxq9jxQzB8yd13QCSLIfBZyPKRSn2LqnOpXSgfY=; b=e6ga7/PWOO/s1QfjShCp/8ywzeI6n3O4RB5QX31OMtdvD4QB3vsT3BgD5OY3RLvFaF k/X2WfP7J3LiMIfcwj2im2QCBSt/B1cTgVbiH3l/7oqtcG5XPj9G7DggVif9YHipcJcg 8BlRGszMwU3iwwGK+odYgrK0Re4JLIdPvytRfordnyzdfRyJVTI7FTIUJiD7Cvk1p1NP N1pyI3RWk/mrSoQp3HLthiVZP6twkYN9dcH0IihDsGGXgncF7ROo25BufR7QJg+Fij/s oNlq7t4G96y9hrEwPRwNnVYHxJ4EEAsm4GbxpCQJMyKtDpw0Bn+vdwS7XzHFir/UAZP2 VNhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730908740; x=1731513540; 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=onjaUxq9jxQzB8yd13QCSLIfBZyPKRSn2LqnOpXSgfY=; b=UYCrj4Cta7ou8MnidZ9LGGdE3FoA3pPD3b28XD6lmcCjLcasPEXnrKeX+1oforAaik Mf4efaAVlZzhTBmU2lusNiac9dJbjP6p3mlIUVEzK5L1KX1raLiHTF0Sc3FxTkxeMV64 QxX8gfqOE3xOb3N7lDRRWtcwc8UvdS1auksWhfFKd77xMVdTODzkfD029/slGhp0ZSLA z+C4ckiY51EDb0e73MJhbnz6jBT4+B/5+2h2Wx6ZEX2dnntcnazgs9fX5IV8v6uoOu+l SjmYP4bqDP65qVRUrLAztxT9el3b3FeIXHOLnonttZAP8fotZ+dWfyQMvWkxQQB8hSk5 KKOQ== X-Forwarded-Encrypted: i=1; AJvYcCVTo3AF47ujr6SF7frNv34X/wtWGuFuqcm2k+PLLYvR95J2j0VipF05S7gDpnA55CqVeJdtdv31nQ==@kvack.org X-Gm-Message-State: AOJu0Yzq3olTi/W5k6YPJLZtZ2e8d1TTjQBqh/5tETBNgwLUkXdMPj4v WM/1U8DBp7izud2aeZQsNEcFAs4XFa7U9aYg6TISvB6H77AAjfkWgRdBxtPo0h0= X-Google-Smtp-Source: AGHT+IEjVTXnrrJWDoPU07CCpmZR8Q4L/phPwYQPM8ei+fLWgcGnZ72fL5YgaRfLrc0OC1cc+i5L0g== X-Received: by 2002:a05:6102:3a09:b0:4a3:c3cf:42b1 with SMTP id ada2fe7eead31-4a8cfd573a7mr37335611137.26.1730908739921; Wed, 06 Nov 2024 07:58:59 -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 af79cd13be357-7b2f39f7b85sm641377285a.31.2024.11.06.07.58.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Nov 2024 07:58:59 -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, Jonathan.Cameron@huawei.com, dan.j.williams@intel.com, rrichter@amd.com, Terry.Bowman@amd.com, dave.jiang@intel.com, ira.weiny@intel.com, alison.schofield@intel.com, gourry@gourry.net, 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, rppt@kernel.org Subject: [PATCH v6 0/3] memory,x86,acpi: hotplug memory alignment advisement Date: Wed, 6 Nov 2024 10:58:44 -0500 Message-ID: <20241106155847.7985-1-gourry@gourry.net> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Stat-Signature: p4rejwk65ptzcazox7jhe91io5g6fkh1 X-Rspamd-Queue-Id: 209072000F X-Rspamd-Server: rspam08 X-Rspam-User: X-HE-Tag: 1730908705-874124 X-HE-Meta: U2FsdGVkX18EozBML/mB/8N1kBs5Kk4EK3HLOBpmRS3TsDijLB1DcQmg7GmI5PP6WiCHcvLaEBJ9l8NEtxitDg1Jn3/OxmHb+1IPYkvPlkVbQa7e0Y6AcgPCh/RF8XQQ5Zph+/dI80dUUg1IZyc3XrklTXNsXa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A3Ca03/GkL4AotDwjhy785wEsGbypIeFhTMLSmjCVs3iphTHcPemJ6CxbylzUAZzChjicS7O6jIHYfCAOuXN6r616eEXuIL76rv1To5sjjjOYt/aL6VR2iuIVWEps7llB 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: 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. v6: - boot_cpu_has -> cpu_feature_enabled() in x86 code - ack tags Suggested-by: Ira Weiny Suggested-by: David Hildenbrand Suggested-by: Dan Williams Signed-off-by: Gregory Price 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(-)