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 */