From patchwork Tue Oct 8 04:43:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Price X-Patchwork-Id: 13826532 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 35942CEF177 for ; Tue, 8 Oct 2024 14:00:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 551F76B0095; Tue, 8 Oct 2024 10:00:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4DAF76B0096; Tue, 8 Oct 2024 10:00:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 354A06B0098; Tue, 8 Oct 2024 10:00:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 145506B0095 for ; Tue, 8 Oct 2024 10:00:51 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id BF07914014A for ; Tue, 8 Oct 2024 14:00:49 +0000 (UTC) X-FDA: 82650595860.08.8BA890A Received: from mail-qv1-f52.google.com (mail-qv1-f52.google.com [209.85.219.52]) by imf14.hostedemail.com (Postfix) with ESMTP id 8D2C4100008 for ; Tue, 8 Oct 2024 14:00:48 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=gourry.net header.s=google header.b=lznGZwtW; dmarc=none; spf=pass (imf14.hostedemail.com: domain of gourry@gourry.net designates 209.85.219.52 as permitted sender) smtp.mailfrom=gourry@gourry.net ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728395938; a=rsa-sha256; cv=none; b=sOQKGewpvlNdYS2lQL/1dJwnnd5V9W7lJSxxeN6quZWUF2i2kHlC8W2yEqikyRztTO7BL+ ciMLypG1/oUflHrNNPqdB3uh1tuuWLSqiq9GwI0NJEoMm7152lCULWA9mpsNnm+XBLl3li mpquLzz/1Qg0WQw2GeAJt1241/jpwlM= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=gourry.net header.s=google header.b=lznGZwtW; dmarc=none; spf=pass (imf14.hostedemail.com: domain of gourry@gourry.net designates 209.85.219.52 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=1728395938; 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=kWPfeq8jzkffwKXmR9I3LKRrKqlhfBH5YIi7C0BC88U=; b=sr09r3yfwfydW9/UsUPkcIQuTDtQXaWD3fenZB13sBWO5aFXoXRtcd64QFEj+XxAkLERew FTBjH74skCE0TH6xGaGbMU+0sP6Guffdsy1q3YZdWgrzzKAZizJok/ss72eW2rwPcT1SFj eT6ckBlgCFQ6OWUlLJ7IYTPQvPZA9C0= Received: by mail-qv1-f52.google.com with SMTP id 6a1803df08f44-6cbc14b3b08so4794366d6.3 for ; Tue, 08 Oct 2024 07:00:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1728396047; x=1729000847; 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=kWPfeq8jzkffwKXmR9I3LKRrKqlhfBH5YIi7C0BC88U=; b=lznGZwtWqeOYIYqZ5AEJ4NWjqD0GtddQEBs8T1RdQXjU84wUXZcdavGb56/yd9W2KW wYl6F0a1aZUVQ1QZ0AEtGBKXZzETpz56e4BF0pmVeFYVeryO4pZUGDIzIBVijXsZO/5e KgSswjIQbVQSrGwWnfHjtTlsFsARW+Q61EqonuQAJ8Ik/7FkhQXOM/5aLZA/mq73CVDS CqfTaUHNLGsggixfgX7wSuX3xgfmye1Zl4YDOrodHF/m8jbFXpqsso1wf1NQvBTZ7Z3f 7VTVtMe300QE3VoJFsk6ft6gdLf1/juRxqGK1QetLruP4TRIOFFAF1vwI/8DbfC2qr6x YsZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728396047; x=1729000847; 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=kWPfeq8jzkffwKXmR9I3LKRrKqlhfBH5YIi7C0BC88U=; b=SCfISWV+JNZdYF/BC/S3yRvC/DHtcR+4hl01xzn1fwlQ/Ux4b/5sbAt/UiBPNzxU4h QZu9Mb/KxkKdrqUwi1Ep7ZNVFt3wxBMRwhRC9AJOfRwfpqOyKE83qHB8MD8WS2lBaa1X A5UeJtqzCM7r3O3Pm0cx6dyHLut5fXY26Fhlp77vJazf4Tzg2FurM+sKq/dQdrsQ3mUe MFZa1zKwclZX2M896USkuWXnNFW7ZmcmFunS+vRyynrrRvoz+TPWIXV5kQIOAeowZyhp fTxdPTxhJawHtV0fjMT5bDrfLBefs0+HXG16b0bm1PmRFeu7ejHu8ei1ufV3CZKlZ/ZY yqQQ== X-Forwarded-Encrypted: i=1; AJvYcCU0tWNL38d+4jJXs0q8I+Mxc1LD2KTSf9ycJkms1aQVHE82lTjqg/YgzrYnb3bSgW5UPDUghyCj4g==@kvack.org X-Gm-Message-State: AOJu0YwFiYxfaYartChDBVdUI40XN+W+y4z9EXUCWBOl+ub34M5DnvW9 rKLg6YaogBD2oAUUlSxHSt2GUzR1TeQ1GOeBbSStVBn1rJuDFHMm+lhaRlXOSu0= X-Google-Smtp-Source: AGHT+IH75tlHFY+xDD0L05P6I4e5i4mq/QT/nf3Kc4ckvIK+23NRCaD0FQ2upLKZkK1gutE6MZuxCA== X-Received: by 2002:ad4:4ba6:0:b0:6cb:a286:5807 with SMTP id 6a1803df08f44-6cba28659afmr160226446d6.24.1728396046336; Tue, 08 Oct 2024 07:00:46 -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 6a1803df08f44-6cbc78650efsm698396d6.39.2024.10.08.07.00.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 07:00:45 -0700 (PDT) From: Gregory Price To: linux-cxl@vger.kernel.org, x86@kernel.org, linux-mm@kvack.org, linux-acpi@vger.kernel.org Cc: 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, david@redhat.com, osalvador@suse.de, gregkh@linuxfoundation.org, rafael@kernel.org, akpm@linux-foundation.org, dan.j.williams@intel.com, Jonathan.Cameron@Huawei.com, alison.schofield@intel.com, rrichter@amd.com, terry.bowman@amd.com, lenb@kernel.org, dave.jiang@intel.com, ira.weiny@intel.com Subject: [PATCH 0/3] memory,acpi: resize memory blocks based on CFMW alignment Date: Tue, 8 Oct 2024 00:43:52 -0400 Message-ID: <20241008044355.4325-1-gourry@gourry.net> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 8D2C4100008 X-Stat-Signature: 3rpfbyfak3ehj966jw1jnp63u9kon7a9 X-Rspam-User: X-HE-Tag: 1728396048-224087 X-HE-Meta: U2FsdGVkX1+anAgSzcYmbtlxxAM4AzHJZroENJrX8JbNe8n25nQkMLzhZyYDVm69S3gQ4uvcM0A3oERYyRXqk5SPUtlmtgV9WXPPce69qRv5rAepetoZTCzWEJInf7F0Jted3Ff3EUaIDIDzHTQ762ZwyUu3FjV6SWnxkAEx+h82gGBRjBdh7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2AMfP5zbqEfPCn1a0oSJNrO0XjFBYex6WMbG6CSm0ZmLWXMSRVEXFQffMMpmAfXI9vQnY0= 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 capacity is not aligned to the size of a memory block managed size, the misaligned portion is not mapped - creating an effective loss of capacity. This appears to be a calculated decision based on the fact that most regions would generally be aligned, and the loss of capacity would be relatively limited. With CXL devices, this is no longer the case. 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. On X86, memory block capacity increases based on the overall capacity of the machine - eventually reaching a maximum of 2GB per memory block. When a CFMW aligns on 256MB, this causes a loss of at least 2GB of capacity, and in some cases more. It is also possible for multiple CFMW to be exposed for a single device. This can happen if a reserved region intersects with the target memory location of the memory device. This happens on AMD x86 platforms. This patch set detects the alignments of all CFMW in the ACPI CEDT, and changes the memory block size downward to meet the largest common denomenator of the supported memory regions. To do this, we needed 3 changes: 1) extern memory block management functions for the acpi driver 2) modify x86 to update its cached block size value 3) add code in acpi/numa/srat.c to do the alignment check Presently this only affects x86, since this is the only architecture that implements set_memory_block_size_order. Presently this appears to only affect x86, and we only mitigated there since it is the only arch to implement set_memory_block_size_order. Suggested-by: Dan Williams Signed-off-by: Gregory Price Gregory Price (3): memory: extern memory_block_size_bytes and set_memory_block_size_order x86/mm: if memblock size is adjusted, update the cached value acpi,srat: reduce memory block size if CFMWS has a smaller alignment arch/x86/mm/init_64.c | 17 ++++++++++++-- drivers/acpi/numa/srat.c | 48 ++++++++++++++++++++++++++++++++++++++++ drivers/base/memory.c | 6 +++++ include/linux/memory.h | 4 ++-- 4 files changed, 71 insertions(+), 4 deletions(-)