From patchwork Tue Oct 8 04:43:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Price X-Patchwork-Id: 13826533 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 6F0BFCEF17A for ; Tue, 8 Oct 2024 14:00:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B6CA86B0096; Tue, 8 Oct 2024 10:00:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AF5FD6B0098; Tue, 8 Oct 2024 10:00:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9223D6B0099; Tue, 8 Oct 2024 10:00:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 66EC16B0096 for ; Tue, 8 Oct 2024 10:00:52 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E652F140135 for ; Tue, 8 Oct 2024 14:00:50 +0000 (UTC) X-FDA: 82650595902.09.E2FBF8D Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) by imf02.hostedemail.com (Postfix) with ESMTP id DA1718000E for ; Tue, 8 Oct 2024 14:00:49 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gourry.net header.s=google header.b=LzH6fAbg; dmarc=none; spf=pass (imf02.hostedemail.com: domain of gourry@gourry.net designates 209.85.219.51 as permitted sender) smtp.mailfrom=gourry@gourry.net ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728395940; a=rsa-sha256; cv=none; b=Ba/g9cSx3Ro/GWVuxloA1p0S7ADeqDGBvgsxZKTYbS/cPImlJmsIOC+8z7Ao78hYKfuOfH 8rFHIfxDnnthhpGdDck5S3w+2H/IC5tAyDfIqrQ3uLBr6LvJDgp9DnHf8CPenirZgz86Fp r0pNf8hdCuvGvouTZLauYTB1Nb2++Z8= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gourry.net header.s=google header.b=LzH6fAbg; dmarc=none; spf=pass (imf02.hostedemail.com: domain of gourry@gourry.net designates 209.85.219.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=1728395940; 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:in-reply-to:references:references:dkim-signature; bh=tYVH9bPzhptOKAKA155SqTUHRG9AKR7xI41sAuZER68=; b=rGnQooUjCBXMPdcOMWrqK4FOwq/rCR0gIGrCTo58wpLHvBA9IzTI9jv2RwkK3P3XuNfds8 TDFiYL4DBWGORdWx24hIZHJj2vwb7zJvz8ce36ffWDDkjlw9ru5SnTDhisN97QTAJWdLBN q9AWaKlx4+PhAy+nQz0tR/B29nELp6w= Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-6cb54eef205so51888596d6.2 for ; Tue, 08 Oct 2024 07:00:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1728396049; x=1729000849; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tYVH9bPzhptOKAKA155SqTUHRG9AKR7xI41sAuZER68=; b=LzH6fAbgTvpI+F/QGw73GCtQYSGJ6GNZKT3zB7sI8TfYYVALQWtM9HpDM/f1Oicf5B XroUC3LmjBEy0X+kHfDzSJaZJDV7nQhTUw+GZkiG8jxpP0sWej0vsDQQbrhw2X8TlGTu d7YU8xSudT6KQnYBJc1ZcMxLT+HWIiDJ1oFteCA3uLFC8xOqAM3ib4Pmy1QczpCvu2jz UNm5C7iSBYgJxmCI7jm9v/hbyLKd54nMuM2xe6uH6LcV9CL+17LHPuD2jz6umnVDa6KJ i393XHZtQuwzok7LHJgtoLsdZWQjf143EjFtx3lqItYM4bHlrpOZD6sLBsjinirCtQXK u7fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728396049; x=1729000849; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tYVH9bPzhptOKAKA155SqTUHRG9AKR7xI41sAuZER68=; b=u2FnRT2h6l+yXtYywHpC6JfFpLbYJpVy0MzA92tRMt4heQLf6wlrWvfRW0YTkhy+P2 seNUPURUPFq7/6sSwfPUz4fQE7JV7EgAy4iWIiI3zV+rcvCNxNArwxfi5923Bf+VayeP X46joqFaAL3sQA5wZm0VdzRFFPqJtFzgJkXCvUbD9gSJiOxhN5Dsx6OKDrrrngND094Z kkr1ATb/PW3hgbNjtivRtglpAClcU6DbwN9iM3Ih9GgA/Y1TMRp1WbwJuYv18Huv7ujm 3b6bJvOgmhTMA81V+dzpqb2QlsYKZqmY3zksnq6TQ+eZPXPzqSOXDLF19bAVq0a3E54k J6qA== X-Forwarded-Encrypted: i=1; AJvYcCXm6aE6mjebfdnXAS+9X053sWkhT6RPCKFOz3Bn7UnzG0851VnZDv/eh9bQA0e4TcC/jyxMSshkbQ==@kvack.org X-Gm-Message-State: AOJu0YxeHInFC7oWRjeEfjfkc7cam+AESCsi/RvePGqYKIzIOTMXO0wM UELKZdkzghP6GPxT0zFcSR0ywIOtCbA5Y8ueO8NNURla7vwOnv8ICOq7x+Tz9mc= X-Google-Smtp-Source: AGHT+IH1G8ITusE7F8TZWngF/LW6FSnDnTSAvzMp2nN4Kfl3aRMl8OFWOkAOoxtA/bT+IIYMoMEjDg== X-Received: by 2002:a05:6214:2b91:b0:6cb:5eea:8a3e with SMTP id 6a1803df08f44-6cb9a2ed3d2mr210771516d6.10.1728396048953; Tue, 08 Oct 2024 07:00:48 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 07:00:48 -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 1/3] memory: extern memory_block_size_bytes and set_memory_block_size_order Date: Tue, 8 Oct 2024 00:43:53 -0400 Message-ID: <20241008044355.4325-2-gourry@gourry.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241008044355.4325-1-gourry@gourry.net> References: <20241008044355.4325-1-gourry@gourry.net> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: DA1718000E X-Stat-Signature: mi8bmjbay6f443ne3ju7e8iw88zmn433 X-Rspam-User: X-HE-Tag: 1728396049-740251 X-HE-Meta: U2FsdGVkX19uHu5WVp/pY3oqciGoXRCUkHl9doah70wBrnEfoKrxfgj/XOZKra57fj31tdJQEBLJ3nQB6LeTxMgREarTwT1cI10G9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yk/gKrhu/T1vIFQ+99V3GpSe7WiWHHtn5HunQlJ9KQQSPLDg6mN8TULB+pLFPRV0LDdLx4pg4HuQuMoxoBO9QQaVpEnCqsshOcILKMdDHN6t2Ca4fTILKlH7Oi0ZoXp6tbjeZKEWUk/ldjLw/F 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: On CXL systems, block alignment may be as small as 256MB, which may require a resize of the block size during initialization. This is done in the ACPI driver, so the resize function need to be made available. Presently, only x86 provides the functionality to resize memory block sizes. Wire up a weak stub for set_memory_block_size_order, similar to memory_block_size_bytes, that simply returns -ENODEV. Since set_memory_block_size_order is now extern, we also need to drop the __init macro. Signed-off-by: Gregory Price --- arch/x86/mm/init_64.c | 2 +- drivers/base/memory.c | 6 ++++++ include/linux/memory.h | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index ff253648706f..6086f99449fa 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -1424,7 +1424,7 @@ void mark_rodata_ro(void) /* Adjustable memory block size */ static unsigned long set_memory_block_size; -int __init set_memory_block_size_order(unsigned int order) +int set_memory_block_size_order(unsigned int order) { unsigned long size = 1UL << order; diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 67858eeb92ed..f9045642f69e 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -110,6 +110,12 @@ static void memory_block_release(struct device *dev) kfree(mem); } +int __weak set_memory_block_size_order(unsigned int order) +{ + return -ENODEV; +} +EXPORT_SYMBOL_GPL(set_memory_block_size_order); + unsigned long __weak memory_block_size_bytes(void) { return MIN_MEMORY_BLOCK_SIZE; diff --git a/include/linux/memory.h b/include/linux/memory.h index c0afee5d126e..c57706178354 100644 --- a/include/linux/memory.h +++ b/include/linux/memory.h @@ -86,8 +86,8 @@ struct memory_block { }; int arch_get_memory_phys_device(unsigned long start_pfn); -unsigned long memory_block_size_bytes(void); -int set_memory_block_size_order(unsigned int order); +extern unsigned long memory_block_size_bytes(void); +extern int set_memory_block_size_order(unsigned int order); /* These states are exposed to userspace as text strings in sysfs */ #define MEM_ONLINE (1<<0) /* exposed to userspace */ From patchwork Tue Oct 8 04:43:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Price X-Patchwork-Id: 13826534 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 2E6A0CEF17A for ; Tue, 8 Oct 2024 14:00:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 970EA6B0099; Tue, 8 Oct 2024 10:00:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8FA356B009A; Tue, 8 Oct 2024 10:00:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 74D516B009B; Tue, 8 Oct 2024 10:00:55 -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 4EDBA6B0099 for ; Tue, 8 Oct 2024 10:00:55 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id EB0C7160146 for ; Tue, 8 Oct 2024 14:00:53 +0000 (UTC) X-FDA: 82650596028.08.2BF1E13 Received: from mail-qv1-f50.google.com (mail-qv1-f50.google.com [209.85.219.50]) by imf09.hostedemail.com (Postfix) with ESMTP id C966E14002D for ; Tue, 8 Oct 2024 14:00:52 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=gourry.net header.s=google header.b=alcdHeys; spf=pass (imf09.hostedemail.com: domain of gourry@gourry.net designates 209.85.219.50 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=1728395917; 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:in-reply-to:references:references:dkim-signature; bh=iOmfBB2o+BmwtYmn6lEeWqW0gfRN00aP7+NLXlUlw00=; b=Rs1f6i2B61/H9fCDLX6RSNyvC5vi5CopsfMxVbQ/F5xcmw5ITnJwLE+MHiR3X6MFzeWf51 L9gKcH1kXKkipIYRNRC/fPYVPdX5gY9kUPFG9RNliO3U770hyv6ABAYHWLMBWWmfd7AjKF GWNEnPK5UlZxLpOdPSUHNv1BFCaKki4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728395917; a=rsa-sha256; cv=none; b=vkCb5NeoMI7uHXi5x15eyqK/Pa/o9dXuTUsAHk1AnYaTW6vqsVvsKgmgH4Kc/IreML9FsV jYt3ETOYhchU6Ajuz6k8RUWrusXPnXwJBChPlp4nogS9xg2ljsdGfteowwxo7IE7aVPST3 knMGfQMFPjG7u0RnLqAyTyMG/EAzWy8= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=gourry.net header.s=google header.b=alcdHeys; spf=pass (imf09.hostedemail.com: domain of gourry@gourry.net designates 209.85.219.50 as permitted sender) smtp.mailfrom=gourry@gourry.net; dmarc=none Received: by mail-qv1-f50.google.com with SMTP id 6a1803df08f44-6cbc5d17c2eso3202556d6.1 for ; Tue, 08 Oct 2024 07:00:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1728396052; x=1729000852; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iOmfBB2o+BmwtYmn6lEeWqW0gfRN00aP7+NLXlUlw00=; b=alcdHeysjmRoqem+XRBMArGxGstxvRcz8ZCpkfypIBP07cv3ky2xWo3wxG+fc4rEV2 VvomnXshBXWVZJhGW1YXiTe8d7ZiS5+7yajRlWpzihxbEjxqHcEVY1ZFym4bCBidpMQu dUUrdTBH3nfsGixtOUBtHrmXy0DanBo/8w+1RthTRnndg9c8OI+37iphbTuRTxS9v+Ya TukwCwMlbuEdykcIpzAEWVFJ0JLk4U47c+dqoq0Vk7+tGiY7szcXTH8GbV75cCQeIegT xIy514k2sIA15tnj1UTJdQTZcH6jP44P8AM5AnmqHdICLwq0I9emcZm+OaAGJ9SyP0Gm 9MRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728396052; x=1729000852; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iOmfBB2o+BmwtYmn6lEeWqW0gfRN00aP7+NLXlUlw00=; b=Xj6uM4J8pZHYcB3hpgKEW6HrVoeYd4ivCAYlPDNvifgNdoq7IMSS0l3GtmzuEp35OZ 7+xYIfl3OtGp3ttnFWtYw+7IqOrQMhYS5LhqE8DS7atzDNXOyLk6GbqQJ2AH+Z99Adq+ ag41VkUgoR1kD8WY9fKjhvAyiViU8PMnq3OPpjBQQj0HlBEDPQY8tzaNvkheiV/xsvXf +SldKTcsc/+3lVVJjlDupBWl1fvD0qs8SBfLrtmBoNbQ31QVzO/5NsMYCCw+M6MJr2cS DrbIx4liX6Ybc7WYDnwGhdRb1wkumoU+MQ8aTrRhkK07XjJgz/Qn8SBdwam/u2Ki7rOx NAVQ== X-Forwarded-Encrypted: i=1; AJvYcCUX8ifFYSIv9UpU18q41GCrIQzY3zYD75g68evVLXxfk7e8Nw0G1yzKZ/vI8xC1I8l82azB+k8dBw==@kvack.org X-Gm-Message-State: AOJu0YziHePOUUZRFM69z+pF8bOZlNquDYp95cKa0ku1oFnj5q1IbQn8 wUTLW30GD56Y5xR9KcWZJ9D2PyuJCoeKOrtUtKcD4uQW0OR3F0nBYE4kMHzGdfo= X-Google-Smtp-Source: AGHT+IHe1DIW8UN+mP+xqS2Oh3mXbQusW6tw3/R+BVrHed7J8ntdmkY9QJ5q2+XDvRLblwgEqMcXNQ== X-Received: by 2002:a05:6214:3b85:b0:6cb:c745:4f44 with SMTP id 6a1803df08f44-6cbc745517dmr10453496d6.26.1728396051760; Tue, 08 Oct 2024 07:00:51 -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.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 07:00:50 -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 2/3] x86/mm: if memblock size is adjusted, update the cached value Date: Tue, 8 Oct 2024 00:43:54 -0400 Message-ID: <20241008044355.4325-3-gourry@gourry.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241008044355.4325-1-gourry@gourry.net> References: <20241008044355.4325-1-gourry@gourry.net> MIME-Version: 1.0 X-Stat-Signature: saxp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UJfjDP ZVwssF9h 2+8OqYWiFH40gMTT9tK8dXJe80MMKenN7a8jhpgAoIR/W4lj0gYvsSu8Iujt+WX7SwtPbrvKmQa2xiDqtj5uj9Uev6JlxGeZW635s6wxA0fsHo5VopE+g17e/kq6ggXftSrk9IUTvJh0xx4DpwXeuxdfFRGqztsvBj2bODQ/9s8fwcxK7QlXwXFlFkIXZyREC7tNDKmlJUFUcBtF7Km645YJsqIUxbDWhLfzna5ZpHCqKANE6Jlc4h2Xtd0BwYETD1POxkj0oMSD3b3Ez7POSn+WRQfVU0JSb8axA7V4od2dfX/NMagkVeDBbPA== 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 parsing CFMWS, we need to know the currently registered memory block size to avoid accidentally adjusting the size upward. Querying the size causes it to be cached in a static global. Update the static global if the value is subsequently updated. Print a warning that this has occurred for debugging purposes if the memory block size is changed at an unexpected time (post-init). Signed-off-by: Gregory Price --- arch/x86/mm/init_64.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index 6086f99449fa..733dfa899232 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -1424,6 +1424,7 @@ void mark_rodata_ro(void) /* Adjustable memory block size */ static unsigned long set_memory_block_size; +static unsigned long memory_block_size_probed; int set_memory_block_size_order(unsigned int order) { unsigned long size = 1UL << order; @@ -1432,6 +1433,19 @@ int set_memory_block_size_order(unsigned int order) return -EINVAL; set_memory_block_size = size; + + /* + * If the block size has already been probed, we need to change it. + * This can happen during ACPI/CFMWS parsing, since it needs to + * probe the system for the existing block size to avoid increasing + * the block size if lower memory happens to be misaligned + */ + if (memory_block_size_probed) { + memory_block_size_probed = size; + pr_warn("x86/mm: Memory block size changed: %ldMB\n", + size >> 20); + } + return 0; } @@ -1471,7 +1485,6 @@ static unsigned long probe_memory_block_size(void) return bz; } -static unsigned long memory_block_size_probed; unsigned long memory_block_size_bytes(void) { if (!memory_block_size_probed) From patchwork Tue Oct 8 04:43:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Price X-Patchwork-Id: 13826535 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 71BA6CEF17A for ; Tue, 8 Oct 2024 14:00:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4DDDC6B009A; Tue, 8 Oct 2024 10:00:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 440206B009B; Tue, 8 Oct 2024 10:00:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F6A16B009C; Tue, 8 Oct 2024 10:00:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id ED5D56B009A for ; Tue, 8 Oct 2024 10:00:56 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id C8BC216015F for ; Tue, 8 Oct 2024 14:00:55 +0000 (UTC) X-FDA: 82650596112.30.2BA0ACD Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) by imf25.hostedemail.com (Postfix) with ESMTP id 9F016A000E for ; Tue, 8 Oct 2024 14:00:54 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=gourry.net header.s=google header.b=nyUtUPPZ; spf=pass (imf25.hostedemail.com: domain of gourry@gourry.net designates 209.85.222.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=1728395919; 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:in-reply-to:references:references:dkim-signature; bh=BnKzHoFsIxSKvnCi298qgtwKBJFTSXeEqlrSeNMpfd8=; b=eWQ0XXunS3Bdh4CWPvTL/S5SmhQrwh216lYTNfP8dQ3dm/1ykoQdy1Tq2l7tHy1W76e3WA AMpljI38HMRlHg7cTlmrCj27KbBq4IjyxeeIk/rhtZD0bfIiHN+3dqz9ubirr5TK7bJwOn w1XNUUVsPwY5DOFAOl7Se6ChXQWiX8s= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728395919; a=rsa-sha256; cv=none; b=b8J1+0jm79gw3luGNMjbCNrVKkqCMgFouFvR7MRZHKQHBFWZJmTdnN6JJVx2V4xua0Z6lO /AdFLErF0YMYA7v/tuIMPKotuBzzYSyhwZG3qe5ayI98W/W1EW0JYgT+aiSPOinxGKKqHf u8wBidu28+urbEiFVfqPnP8o/bHDhuY= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=gourry.net header.s=google header.b=nyUtUPPZ; spf=pass (imf25.hostedemail.com: domain of gourry@gourry.net designates 209.85.222.176 as permitted sender) smtp.mailfrom=gourry@gourry.net; dmarc=none Received: by mail-qk1-f176.google.com with SMTP id af79cd13be357-7afcf0625a9so5276885a.0 for ; Tue, 08 Oct 2024 07:00:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1728396053; x=1729000853; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BnKzHoFsIxSKvnCi298qgtwKBJFTSXeEqlrSeNMpfd8=; b=nyUtUPPZY1ntY8aw01/+UHE0YkNo1zj8/pBydPAGE8PBVay9pgZiiU9j+5IgYxrQQT U3nBIWWVnULvDjEfhH2mW2tgAnicnFF8Fq2ND+K7XzGUZccbqwkwMljd4IhWZGcnlGwv mO/FpYhuZYiod9rX1KbDzRx0ygu7knF4UWJvdPDxQsh2FcN+Q22DEA9ROXiYes8s7BI+ fxwgwjQ1dF9r5clbfIVP5oPrAqi2tKVvFAyc0sOBQZQP2oYqJ9EHXWnsWIjHZwHNKlVR mfd09JnumN6FpEoMELfEgA3AXebz4Cn0l1yOyUo0+yCswdcM9vNWzjHyuwIhgU7tCrHW 3JfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728396053; x=1729000853; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BnKzHoFsIxSKvnCi298qgtwKBJFTSXeEqlrSeNMpfd8=; b=O57CjsYtcDIcA3jUqnBvVoi7JfqLIPTk6NZJhnEjKYbXK/MXWvVD82Dl2F3domeZ2A 1LlhodAcfWMls5auc6ixi7X4jXpVE2DuhC6Tke19vGVPaj2/EA+wbhudvQffRyRXweUR QTXG7rC9PsGVyDB8HpNwQBcAs76onEsMxQvaguiHdePk4alSbwNJ+xrYRUPwj4kUGhrC 9JrP4KIE7wCY6wmiyIR4eOeNhzrb4oLoNyqpx5hRuDdETLkOqqk2/C95RjNhm4WgzBBp Q3IJYR84WlnE3ozD8wLogxisPSgFO+A1jcqxYmFZ0y3S3daljKG1ZkxivcFkDsMSk3Nt orUw== X-Forwarded-Encrypted: i=1; AJvYcCXYZL4DknqiWLHzXZJCWPp35b4zQg7xiu0yoCCXAu/6Vm5rpt8s+biEHCA+WaQGiBCJQwHp1Cv8NQ==@kvack.org X-Gm-Message-State: AOJu0YzceLkdg7Sxr4j0jyIOD+CAHNn8VTsq0iNrEfsb0UshJ1uedMr/ 5hOPLssjjGoW6xTj5VpPQYQWz8wSLAq/iLTb3NI6Uw6vgN8o9xGDg56XTHBgaRQ= X-Google-Smtp-Source: AGHT+IEWQaL+bYEjt3RyVfxhNXMy9Cz/JlOtCh7gn34GRctxubICCfzpYSUr2ZJbwepGsgKWAr958Q== X-Received: by 2002:a0c:e5c4:0:b0:6cb:a705:c05e with SMTP id 6a1803df08f44-6cba705c0aamr170960556d6.6.1728396053465; Tue, 08 Oct 2024 07:00:53 -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.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 07:00:53 -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 3/3] acpi,srat: reduce memory block size if CFMWS has a smaller alignment Date: Tue, 8 Oct 2024 00:43:55 -0400 Message-ID: <20241008044355.4325-4-gourry@gourry.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241008044355.4325-1-gourry@gourry.net> References: <20241008044355.4325-1-gourry@gourry.net> MIME-Version: 1.0 X-Stat-Signature: itd5n6455qjn7kx46tj4xoz7e59zourh X-Rspamd-Queue-Id: 9F016A000E X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1728396054-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ejZt+ELO1/GSLmV4fmx7rKAdgubg6W1XV9Lz95Ixj1R+Jc73kEHZG7BsxYQOy9f4pS5fzWyObM/M4DFR6WoX0oQmJV+tSZ+kIn9zS17F2bDy81SlCo/wN+pPI+caljMnkKWFm+sWs5YXiEJwPnMH4w9trAJ5nYOWDBObcxFKtx98cJOBhbrj5I9W7CRhJU7BAheExOc94NL31eFHPI4no12ZlifA/IWDSPzp8hPsMzGp09To+/GK04/kqWI= 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: The CXL Fixed Memory Window allows for memory aligned down to the size of 256MB. However, by default on x86, memory blocks increase in size as total System RAM capacity increases. On x86, this caps out at 2G when 64GB of System RAM is reached. When the CFMWS regions are not aligned to memory block size, this results in lost capacity on either side of the alignment. Parse all CFMWS to detect the largest common denomenator among all regions, and reduce the block size accordingly. This can only be done when MEMORY_HOTPLUG and SPARSEMEM configs are enabled, but the surrounding code may not necessarily require these configs, so build accordingly. Suggested-by: Dan Williams Signed-off-by: Gregory Price --- drivers/acpi/numa/srat.c | 48 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c index 44f91f2c6c5d..9367d36eba9a 100644 --- a/drivers/acpi/numa/srat.c +++ b/drivers/acpi/numa/srat.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -333,6 +334,37 @@ acpi_parse_memory_affinity(union acpi_subtable_headers *header, return 0; } +#if defined(CONFIG_MEMORY_HOTPLUG) +/* + * CXL allows CFMW to be aligned along 256MB boundaries, but large memory + * systems default to larger alignments (2GB on x86). Misalignments can + * cause some capacity to become unreachable. Calculate the largest supported + * alignment for all CFMW to maximize the amount of mappable capacity. + */ +static int __init acpi_align_cfmws(union acpi_subtable_headers *header, + void *arg, const unsigned long table_end) +{ + struct acpi_cedt_cfmws *cfmws = (struct acpi_cedt_cfmws *)header; + u64 start = cfmws->base_hpa; + u64 size = cfmws->window_size; + unsigned long *fin_bz = arg; + unsigned long bz; + + for (bz = SZ_64T; bz >= SZ_256M; bz >>= 1) { + if (IS_ALIGNED(start, bz) && IS_ALIGNED(size, bz)) + break; + } + + /* Only adjust downward, we never want to increase block size */ + if (bz < *fin_bz && bz >= SZ_256M) + *fin_bz = bz; + else if (bz < SZ_256M) + pr_err("CFMWS: [BIOS BUG] base/size alignment violates spec\n"); + + return 0; +} +#endif /* defined(CONFIG_MEMORY_HOTPLUG) */ + static int __init acpi_parse_cfmws(union acpi_subtable_headers *header, void *arg, const unsigned long table_end) { @@ -501,6 +533,10 @@ acpi_table_parse_srat(enum acpi_srat_type id, int __init acpi_numa_init(void) { int i, fake_pxm, cnt = 0; +#if defined(CONFIG_MEMORY_HOTPLUG) + unsigned long block_sz = memory_block_size_bytes(); + unsigned long cfmw_align = block_sz; +#endif /* defined(CONFIG_MEMORY_HOTPLUG) */ if (acpi_disabled) return -EINVAL; @@ -552,6 +588,18 @@ int __init acpi_numa_init(void) } last_real_pxm = fake_pxm; fake_pxm++; + +#if defined(CONFIG_MEMORY_HOTPLUG) + /* Calculate and set largest supported memory block size alignment */ + acpi_table_parse_cedt(ACPI_CEDT_TYPE_CFMWS, acpi_align_cfmws, + &cfmw_align); + if (cfmw_align < block_sz && cfmw_align >= SZ_256M) { + if (set_memory_block_size_order(ffs(cfmw_align)-1)) + pr_warn("CFMWS: Unable to adjust memory block size\n"); + } +#endif /* defined(CONFIG_MEMORY_HOTPLUG) */ + + /* Then parse and fill the numa nodes with the described memory */ acpi_table_parse_cedt(ACPI_CEDT_TYPE_CFMWS, acpi_parse_cfmws, &fake_pxm);