From patchwork Wed Oct 16 19:24:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Price X-Patchwork-Id: 13838790 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 BDC98D2A541 for ; Wed, 16 Oct 2024 19:25:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F01F66B0095; Wed, 16 Oct 2024 15:25:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E62BF6B0098; Wed, 16 Oct 2024 15:25:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C8DA96B0096; Wed, 16 Oct 2024 15:25:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A5F2F6B0093 for ; Wed, 16 Oct 2024 15:25:19 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id CF2D1ABFAA for ; Wed, 16 Oct 2024 19:24:58 +0000 (UTC) X-FDA: 82680443580.19.20C8A0E Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) by imf13.hostedemail.com (Postfix) with ESMTP id DCADD2000F for ; Wed, 16 Oct 2024 19:25:07 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gourry.net header.s=google header.b=IEOAKjU9; spf=pass (imf13.hostedemail.com: domain of gourry@gourry.net designates 209.85.160.169 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=1729106525; 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=KhSiZfD9mtqxRJdpC7TxMcZ82+QcCBZVMQrw8INyhYE=; b=FxxhQzeDexionfs/BDyX6G5zwR4Fi9N6YIfvZiMEwkHBB5uxyQvgce2YGuRFtod93uCT7S Gk4cU54DYxCxKzvSJlZ85O+TyCAgH5/xkn/LcpY/P4G/cFjRIZIwCktW5Ya+03566ZqZ18 +HFFv7NDXTYBKKJ1036LBsYzLQ6M/Tc= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=gourry.net header.s=google header.b=IEOAKjU9; spf=pass (imf13.hostedemail.com: domain of gourry@gourry.net designates 209.85.160.169 as permitted sender) smtp.mailfrom=gourry@gourry.net; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729106525; a=rsa-sha256; cv=none; b=SuhQxoPaJKBYBXVg8+CL1Dgi2Jq6YWYBxG0zpjZFZYPbv/wpcWeufEU1MCQG6u5UCwSd66 T3nnC0GxEy2YwmEjNR/2dRCaIntckpm/hoFtkK/AycQxNqbTtcH606O4JLpNSmCdyoKcxM PcxOerUGh+XFPcQCM9z63oys4MV838M= Received: by mail-qt1-f169.google.com with SMTP id d75a77b69052e-4606347c791so1369271cf.2 for ; Wed, 16 Oct 2024 12:25:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1729106716; x=1729711516; 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=KhSiZfD9mtqxRJdpC7TxMcZ82+QcCBZVMQrw8INyhYE=; b=IEOAKjU99fmHCZTs2r9YabxxHim+VRbja0H2zDRMwSFLzVhXE/Oek8855VFOIxfa49 jQ+xJrPedfwA7oM/I+EnT9r37WX4oH5+aDEDPS/YNkNdK6cI3ZYW8Ly3m+Mw74jliahX MVtA4c/zGeHlBPxG5Bqw+33205LufuKILvedSb1I8PM0jW/Z2ODPN9VDd7qet6P6a+E7 GwNLS69h1T7K9a14yJokCDETHVlpwUL2WJzs3aOAztkntN5X0IwlkWgasCZyFNC10HqD hyWNNqwrn6N1gdMcv0x9zUWQwC7DsD6fY4jk4vrGFRq51/Mi6fkHYiMUw0zf2LZxZXUM JOPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729106716; x=1729711516; 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=KhSiZfD9mtqxRJdpC7TxMcZ82+QcCBZVMQrw8INyhYE=; b=CbFdu/HF8kS8iWJ5eswhX7EhUhT6R6VsxeD880FAAgQLVlZOYc9fEKaSpbbEXxmdlG 9aBImXM+jAlrZ4WS3wAs7zRiigPV4pbi3u4B9Q1ypfApWSNAIHinDBGG2hfXykylUVVV AKxGiwKOr6DigQRrInPqUuXT5Oe4qirasgsqY9vuyp6bsYG4bVwq3RZxuNXygY0dM4NN uP0qA5bh0p2AQEpQE2usVvfoaECmRD7rrySqEEgF5syt2QWDqqNsvhAfBITybCLsqib1 wcdBwMNPtuUSQZUWTRq8Sn+/K/iuMp3bVjlXbEzBfkTjolvIWI+4X282803WEVq70iSu 2ivA== X-Forwarded-Encrypted: i=1; AJvYcCV5dt+IbMY37G37Je1hUkhn13AkYe/Z+qfGUu9nzgjYAUTdaYufKVBmCp8HHhnivDAN+VU9kblljg==@kvack.org X-Gm-Message-State: AOJu0Yylp0OAo88iSxClHAXoSRbmSRMhxJD7a5YA0s95Uf9hVDAvBaYK IoWbVoCqOZ+/rR9HQwLJkbJhqQ3TEA64U3ZYnl3IL4y0pnLlDikiskIhM7y1KT4sZsgwnCfgOIp x X-Google-Smtp-Source: AGHT+IFAUHFf6NguMqIqPpOUU8ECxUJfxWjg38Snyk4DLApeDSEpJ+qoxL7DfuWK9Mow+ZcYMf8Ygg== X-Received: by 2002:a05:622a:244b:b0:45f:784:1b5a with SMTP id d75a77b69052e-46058444fa6mr282643391cf.25.1729106716169; Wed, 16 Oct 2024 12:25:16 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2024 12:25:15 -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 2/3] x86: probe memblock size advisement value during mm init Date: Wed, 16 Oct 2024 15:24:44 -0400 Message-ID: <20241016192445.3118-3-gourry@gourry.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241016192445.3118-1-gourry@gourry.net> References: <20241016192445.3118-1-gourry@gourry.net> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: DCADD2000F X-Stat-Signature: dmxebb4gtup3fcgnmd81br17jt3xqpxj X-Rspam-User: X-HE-Tag: 1729106707-704459 X-HE-Meta: U2FsdGVkX18ag0S9H+IcAxNvIF54vaDYmcAdpO+gBQzE7WwRy8ZKa8PFeZBB/ZeobjDFPcigfyqPohVYnVEVNAe33tqeod2gZFP3CHuCB91dXe0GzvV6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RZEW1/NZP4QMv78eSMGYmQ7o70/TJqKCDz75q9QPwmzQJkVi8ukZJOS8VJtdwzmTst65kk3ifav94pMu9LkYDXLt3MPW0WyO6vsE9VGyjTO+ohy3LvyfakRCk= 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) [new] hotplug advise: lesser of advise value or memory alignment 4) Max block size if system is bare-metal 5) Largest size that aligns to end of memory. Suggested-by: David Hildenbrand Signed-off-by: Gregory Price --- arch/x86/mm/init_64.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index ff253648706f..b72923b12d99 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -1439,6 +1439,7 @@ static unsigned long probe_memory_block_size(void) { unsigned long boot_mem_end = max_pfn << PAGE_SHIFT; unsigned long bz; + int order; /* If memory block size has been set, then use it */ bz = set_memory_block_size; @@ -1451,6 +1452,21 @@ static unsigned long probe_memory_block_size(void) goto done; } + /* Consider hotplug advisement value (if set) */ + order = memblock_probe_size_order(); + bz = order > 0 ? (1UL << order) : 0; + if (bz) { + /* Align down to max and up to min supported */ + bz = max(min(bz, MAX_BLOCK_SIZE), MIN_MEMORY_BLOCK_SIZE); + /* Use lesser of advisement and end of memory alignment */ + for (; bz > MIN_MEMORY_BLOCK_SIZE; bz >>= 1) { + if (IS_ALIGNED(boot_mem_end, bz)) + goto done; + } + /* Barring clean alignment, default to min block size */ + goto done; + } + /* * Use max block size to minimize overhead on bare metal, where * alignment for memory hotplug isn't a concern.