From patchwork Wed Oct 16 19:24:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Price X-Patchwork-Id: 13838788 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 A3166D2A541 for ; Wed, 16 Oct 2024 19:25:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0CF026B008A; Wed, 16 Oct 2024 15:25:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 07F846B0092; Wed, 16 Oct 2024 15:25:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E885E6B0093; Wed, 16 Oct 2024 15:25:15 -0400 (EDT) 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 C5A936B008A for ; Wed, 16 Oct 2024 15:25:15 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 5A66CAC0F9 for ; Wed, 16 Oct 2024 19:24:55 +0000 (UTC) X-FDA: 82680443370.07.22382CD Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) by imf24.hostedemail.com (Postfix) with ESMTP id BD76E180020 for ; Wed, 16 Oct 2024 19:25:11 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gourry.net header.s=google header.b=HAjdDaR5; spf=pass (imf24.hostedemail.com: domain of gourry@gourry.net designates 209.85.160.178 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=1729106570; 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=PnTj8Lsaioq+rT9KMPtZOlgLCzamtAdxNe82cXp5oXQ=; b=nIvxBokGZRT/RbrYBUCgz0kGy9qYNI/zxafelnZXzzBxn83HaVNlnWPRA/uoSFJ8HJLpNT y8gRbt7AFNo3tH/eYsRLBErRHi/g1vsGzn8TobKIup6Phwchp4DsR4PTRV09d4lCL7OXDf 42E0qiLYn2Qe5+1b0Eq455pke/1W1xI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729106570; a=rsa-sha256; cv=none; b=OEAX5NmSHpXtlPNJ7OsXegodNbDOhgq9pa+2Oy4bXRAcI8m75qdkd6sHuJQo8RhMsEA1pu bZt2mgkSxGCEqQqaGlqYF5jOAfkijk5K8FM6qJnhIigkqG+vgGB1H2MTAuTQzA4zwXg/j4 47FwLVUdebUA/ZxiUkWvI4Iww6FTDbg= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=gourry.net header.s=google header.b=HAjdDaR5; spf=pass (imf24.hostedemail.com: domain of gourry@gourry.net designates 209.85.160.178 as permitted sender) smtp.mailfrom=gourry@gourry.net; dmarc=none Received: by mail-qt1-f178.google.com with SMTP id d75a77b69052e-45f07eb6f5fso1425161cf.1 for ; Wed, 16 Oct 2024 12:25:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1729106712; x=1729711512; 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=PnTj8Lsaioq+rT9KMPtZOlgLCzamtAdxNe82cXp5oXQ=; b=HAjdDaR5MYbw4kcTqgZ+Aym8HcRtSn71o049o3P2GfalIWX43wb3yzy/XvBE1ECe1l XXig48I71q6j07iT07QiaMaDOyJow0mPnV9hsRY2zmm7DhyP9h6c2WGM+kCRo5dcikW/ da4lNclzx4U8j1mW8uBQAjJj7imOWiPklsxJV5mK6uD4FOusFTNOp2nKkdBcczSrUAUg XKLHYYKkgZHxcRHL6hX9XhGk2K6WTVgrXr89hzRz/tQbzFyRQpiaqnGfA0UaJiQ5IMZn jfGYbwDwrsGkzsQ+kOu74bU6i8yDrHp7/+88zxlRo34jxCYN+9If1JgFoQenyaINVsl6 x77w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729106712; x=1729711512; 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=PnTj8Lsaioq+rT9KMPtZOlgLCzamtAdxNe82cXp5oXQ=; b=jP89A0y7Nl1Q/XbVyhICQicrnzJzwvBXatPLTybdm4IXiSDA++o7bq9ZHxEFeTcuE6 S40c+vPDWR9lkaEDpmvXlS1+/cSQjd39DrouXTb4VpQNS24V4/OcReDxb6Jg0SKPi0Xo 3MJIyafHr28yIO5MK1fioOqUDbGlPYLa2UXr+NbGP3zFCGNOXANxKKiCIQBFwC3kb4TE NEYzpnHkNhXiAPiZdHjAcQpe/mrUdJY1o3S/0L/lgD6N4JoC5v7zXIY5Lnl7US/+G7IF HmO0lysLSIzDKFXpHG3scrfaCqbC1t9XEFpJAMtSSARABp7n13mgxOxAH19dQorJy94M F4mQ== X-Forwarded-Encrypted: i=1; AJvYcCUV1VC8eGjDf2PTrmHnQBKOphJxfk5VQYhOTG6zkaglJKX5K4mgXp23FGTiB2RJSmtmecI9cmorZQ==@kvack.org X-Gm-Message-State: AOJu0YwpHA3LtFTq3Huu1Pr69MXrttUwQJZfZxAuimMC7qCml/kcmho2 wAFzjbNTuoJVLhdPFu9be3fp3wrOVlLJNUkGMbJZkYuiiIHLBC87FYDjYELj1/0= X-Google-Smtp-Source: AGHT+IFLVilbKzRtR60hRVdAb2iSSymL1i+DXwV1S5+mgYdi39fcAJXLybQT7kl4t9CDE81sORKOAQ== X-Received: by 2002:a05:622a:551a:b0:45f:890c:5f49 with SMTP id d75a77b69052e-4609b4e7150mr13277981cf.24.1729106712569; Wed, 16 Oct 2024 12:25:12 -0700 (PDT) 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 d75a77b69052e-4607b38ce69sm20271651cf.90.2024.10.16.12.25.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2024 12:25:11 -0700 (PDT) From: Gregory Price To: x86@kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-mm@kvack.org Cc: dan.j.williams@intel.com, ira.weiny@intel.com, david@redhat.com, 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, rppt@kernel.org, akpm@linux-foundation.org, alison.schofield@intel.com, Jonathan.Cameron@huawei.com, rrichter@amd.com, ytcoode@gmail.com, haibo1.xu@intel.com, dave.jiang@intel.com Subject: [PATCH v2 0/3] mm/memblock,x86,acpi: hotplug memory alignment advisement Date: Wed, 16 Oct 2024 15:24:42 -0400 Message-ID: <20241016192445.3118-1-gourry@gourry.net> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Rspamd-Queue-Id: BD76E180020 X-Stat-Signature: os87uzcr1a5kebfpmsu8tbcrmwjo4y9g X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1729106711-173038 X-HE-Meta: U2FsdGVkX185oVw8kvrXcew0xmnQELFmihggaJXByfPHGS7ggHZbW0EETXEKX9U/Py9isRWsm5FXwfJO4r8NQldlHH8Sxn3lx9e8/+2RIlzc6KFgLvAIYSV6AYt+pvXejFd4q49oidmlF/r1m8fajy5Fa7TBMj0FvMOFB1gFZ7oC/Ok2LG+T/rp7a483X4fVBID3fuE3PTnZRRgLW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H9LtaA7gsMKR6VLJkrbzvr1cEw2gF1Jj5QorIIpQDKm 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 (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/probe functions in mm/memblock.c to report/probe architecture agnostic hotplug memory 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 probe has already occurred, but this is predicated on the notion that probe() actually occurs (which presently only happens on x86). This is to assist debugging future users who may mistakenly call this after allocator or smp init. Likewise, if probe() occurs more than once, we return -EBUSY to prevent inconsistent values from being reported - i.e. this interaction should happen exactly once, and all other behavior is an error / the probed value should be acquired via memory_block_size_bytes() instead. Suggested-by: Ira Weiny Suggested-by: David Hildenbrand Suggested-by: Dan Williams Signed-off-by: Gregory Price Gregory Price (3): mm/memblock: implement memblock_advise_size_order and probe functions x86: probe memblock size advisement value during mm init acpi,srat: reduce memory block size if CFMWS has a smaller alignment arch/x86/mm/init_64.c | 16 +++++++++++++ drivers/acpi/numa/srat.c | 42 ++++++++++++++++++++++++++++++++++ include/linux/memblock.h | 2 ++ mm/memblock.c | 49 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+)