From patchwork Tue Oct 22 21:34:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Price X-Patchwork-Id: 13846187 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 226FDCDD0EA for ; Tue, 22 Oct 2024 21:35:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 63CA66B00AB; Tue, 22 Oct 2024 17:34:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5EC816B00B4; Tue, 22 Oct 2024 17:34:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 48FC96B00B5; Tue, 22 Oct 2024 17:34:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2A7D36B00AB for ; Tue, 22 Oct 2024 17:34:59 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id D2DCF1A053D for ; Tue, 22 Oct 2024 21:34:28 +0000 (UTC) X-FDA: 82702543014.30.C8404C6 Received: from mail-qt1-f180.google.com (mail-qt1-f180.google.com [209.85.160.180]) by imf21.hostedemail.com (Postfix) with ESMTP id 7650B1C0016 for ; Tue, 22 Oct 2024 21:34:25 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gourry.net header.s=google header.b=i7kzuVo5; spf=pass (imf21.hostedemail.com: domain of gourry@gourry.net designates 209.85.160.180 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=1729632845; 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=AqCv7heAkmMbGyHort0yESB5tthHSXy3Avmci0WyUUs=; b=kR9zR75ZF/IuTdf+IEY/oGjUVtmoAu/yZ7eJ9CvAlGnFsqeY8kZpvh+2Xr1DX85A1B5BqK zID81YvTJWrbEtdMmQt0OLBU0fafkHOTbqFhWKYOFGkbmqGkeaDOhubkI/APmEdNchaDSP HUZPxSSpl5h0DcUrMrojFhAUZZ25714= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=gourry.net header.s=google header.b=i7kzuVo5; spf=pass (imf21.hostedemail.com: domain of gourry@gourry.net designates 209.85.160.180 as permitted sender) smtp.mailfrom=gourry@gourry.net; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729632845; a=rsa-sha256; cv=none; b=Ermtow9huBy4xcpfFxJ7nBKhgMTQCqHqCK2XxS1lv5fdFTqNSq2yQ9jB72HzfA+gp0JQJ1 KhfWUJ7/8XbEC4zX9Z1MV7RQfNLy9kzvhWM+5SSk07FzEIE208XuQ8Q83AW/fxVdmr3AUi eTUA+PsYC8p8UAgMXGNrKtaUbjGGhDQ= Received: by mail-qt1-f180.google.com with SMTP id d75a77b69052e-460b2e4c50fso29640961cf.0 for ; Tue, 22 Oct 2024 14:34:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1729632896; x=1730237696; 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=AqCv7heAkmMbGyHort0yESB5tthHSXy3Avmci0WyUUs=; b=i7kzuVo5cdoMYRGe9T1skeuwiGcvF4hyxZeqQncYS1d/h6BHqw9O2zRsGEkTPAg6JH q4B+kJgq2zYpLvAK5b6k3nbifuCP58xHslhbRx7MbJqHy8vEcMSkaHkynUuzNlXmG7v+ kho2SZOXMX7FKIQOakTRo95BqzGxGr/GgwghuK0za268PhGoDtpWuwE/JAOxhGepek7o lwDB4z7nqEAdpFq3wBDQ/vpyDWvRWgU+22fUfgSfL0nf9czzkxxdqa0+stgL/Oq4xkAQ gor0bi7dYBIawc0ml6daiUf6AEjhH6DAasz8bcKhsKHTy9KYSarO2/l/ERARbpH9OhQH OHGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729632896; x=1730237696; 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=AqCv7heAkmMbGyHort0yESB5tthHSXy3Avmci0WyUUs=; b=DLIPIzQz+CXIPJn/iRqeXgf2aWTHgXQrQ3tlf/v4Xsn80IsH1/+c0yjev0j8pRpAly IZS3c6das0YSHlI9Wz5bryVwiZoz+vN4RNSjy9Vt5ZZqLgh8lNvKIkhqjCLTUJ2oN2+N gyje1Hpi62urdaCGGVLtvvKS5xE1mg3INlvC5SCfrgiBS70pIviN+f5Ur7tMJ5ztzlN9 Ilkx3DVmeCcnKETee8hqYsCZS2MQkVpxOPMxrkhkRsKU+8CAGkVOjYJuXHL5S08UJGfr z8lKhAuPhUx4FKH8L5stIJjoEVrOaXUgofK0HIJthvsVMgii+DITv5XTCOxOt2/xhm0P O4dQ== X-Forwarded-Encrypted: i=1; AJvYcCUCoY6SDl4EBVzuLZTCaLq0HiujZFAMmFDpg/WEV6ryprZsetRMEkQhf3hf4y1/DikVK8wVuLlhug==@kvack.org X-Gm-Message-State: AOJu0Yz+ePISw3u7rHt5IijQoCUdJ4vKPqRw6i/Y538xVEmEhDIhutS9 r9+VeQhB3oQ33NOyw+hkG1nHyy28hAP0LmT75gy84q4oY9LsSoQfkPs4N/iK38E= X-Google-Smtp-Source: AGHT+IG6u8nXwqeHHa2iAZjSeQvjzXX9LlJNqnqKjo6O88p7xQbadR2zh6+g2YkgEfRojyf8qrAQmQ== X-Received: by 2002:ac8:59d4:0:b0:460:8e3b:6790 with SMTP id d75a77b69052e-4611470b2b0mr4519561cf.48.1729632896082; Tue, 22 Oct 2024 14:34:56 -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-460d3c62f4dsm33845841cf.28.2024.10.22.14.34.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 14:34:55 -0700 (PDT) From: Gregory Price To: x86@kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-mm@kvack.org Cc: linux-cxl@kvack.org, 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 v3 2/3] x86: probe memory block size advisement value during mm init Date: Tue, 22 Oct 2024 17:34:49 -0400 Message-ID: <20241022213450.15041-3-gourry@gourry.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241022213450.15041-1-gourry@gourry.net> References: <20241022213450.15041-1-gourry@gourry.net> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: pw3pj93e3j6nhb46515fi4tkmqna7q6u X-Rspamd-Queue-Id: 7650B1C0016 X-Rspamd-Server: rspam11 X-HE-Tag: 1729632865-995240 X-HE-Meta: U2FsdGVkX1+MtHcNDQ9+hXQwWwYcMEwr8xlHbYOF5+eG1AXxgGggT3a3+h6cZcOnNeY/tO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eGLOT5DOfsz9hb2p0r4UgSVEjvymRSPN00SptOGtxy5s2ANF7vPpNunmr0aAs4T5njB/rNUwAE9CnEs60oyrEdoYbhl2r694Hu2lI5jzYMD+mqVDg10J+QWHubY92AAIv64wjeskkliIWt3bSCj8RwfNYoDZsh1V1KK4+ARaGtPfO4= 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: Systems with hotplug may provide an advisement value on what the memblock size should be. Probe this value when the rest of the configuration values are considered. The new heuristic is as follows 1) set_memory_block_size_order value if already set (cmdline param) 2) minimum block size if memory is less than large block limit 3) if no hotplug advice: Max block size if system is bare-metal, otherwise use end of memory alignment. 4) if hotplug advice: lesser of advice and end of memory alignment. Suggested-by: David Hildenbrand Signed-off-by: Gregory Price Acked-by: David Hildenbrand --- arch/x86/mm/init_64.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index ff253648706f..93d669f467f7 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -1452,13 +1452,17 @@ static unsigned long probe_memory_block_size(void) } /* - * Use max block size to minimize overhead on bare metal, where - * alignment for memory hotplug isn't a concern. + * When hotplug alignment is not a concern, maximize blocksize + * to minimize overhead. Otherwise, align to the lesser of advice + * alignment and end of memory alignment. */ - if (!boot_cpu_has(X86_FEATURE_HYPERVISOR)) { + bz = memory_block_probe_max_size(); + if (!bz) { bz = MAX_BLOCK_SIZE; - goto done; - } + if (!boot_cpu_has(X86_FEATURE_HYPERVISOR)) + goto done; + } else + bz = max(min(bz, MAX_BLOCK_SIZE), MIN_MEMORY_BLOCK_SIZE); /* Find the largest allowed block size that aligns to memory end */ for (bz = MAX_BLOCK_SIZE; bz > MIN_MEMORY_BLOCK_SIZE; bz >>= 1) {