From patchwork Tue Oct 29 20:20:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Price X-Patchwork-Id: 13855354 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 81584D3A696 for ; Tue, 29 Oct 2024 20:20:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E0AC26B0095; Tue, 29 Oct 2024 16:20:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D906E6B0096; Tue, 29 Oct 2024 16:20:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B47346B0099; Tue, 29 Oct 2024 16:20:49 -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 92C846B0095 for ; Tue, 29 Oct 2024 16:20:49 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 3D4B01A05CC for ; Tue, 29 Oct 2024 20:20:49 +0000 (UTC) X-FDA: 82727757714.04.28388AF Received: from mail-yb1-f169.google.com (mail-yb1-f169.google.com [209.85.219.169]) by imf04.hostedemail.com (Postfix) with ESMTP id A7F0F4000D for ; Tue, 29 Oct 2024 20:20:15 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gourry.net header.s=google header.b=f3wAUqPG; spf=pass (imf04.hostedemail.com: domain of gourry@gourry.net designates 209.85.219.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=1730233167; 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=RLCkoovWy+4BTP/Blm5LQHaaqE7ZHx2x3Kcfu38vCw4=; b=SjoUCf5I7SV1LdzZ43V5HRvuXBbcWcPXkb6l03FHQQF3d95wd/qs1Gh9TAxtl2d5MgHNvU 0uxqepHFLjQpWcDp2EiipwCzdLzpGXMKUoDInWuXt0+pAZ5v/T4iz3wlcP3oDcNCLgsnsB 3MMT33rinXjTP3rDbDHaWDRCu96xXAs= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=gourry.net header.s=google header.b=f3wAUqPG; spf=pass (imf04.hostedemail.com: domain of gourry@gourry.net designates 209.85.219.169 as permitted sender) smtp.mailfrom=gourry@gourry.net; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730233167; a=rsa-sha256; cv=none; b=g5yPhd5BJU8qIIlbMTjxsP5/vg5N++jJNfe3BzPfK3Luzz/MW4XtXKNBwQROPB6dJOtMZg pNgZm3mgcM+vwSzlLw3JfS47ax2jLA+leXAo20d5ey18nPaKfeD0dQCQc9FAKCj+aOXR7g rDuNAnOghNFjpVDXkizMBdtxTpyyZ2Q= Received: by mail-yb1-f169.google.com with SMTP id 3f1490d57ef6-e29267b4dc4so6151581276.0 for ; Tue, 29 Oct 2024 13:20:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1730233246; x=1730838046; 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=RLCkoovWy+4BTP/Blm5LQHaaqE7ZHx2x3Kcfu38vCw4=; b=f3wAUqPGxii5ctekiZttzG/CVqRg5d8Sg8/PUp6TXRKvJnrozM4rtc1/GOe8GiL7hg qSqVP4LueF/vzb52XH0jopHISM28XOaPwve62EMTdXBg1lSn+VBN24t09nnfGpNt3JG5 Ql4mi5hK988l54rZKEi0iHnWLdyAWEsl99YM8n31UwrA/bKo2XIvdkLfRyMLhGT+XphE e4xEKGYh2kgoXTCUA3DRvUWkSFaLEh7LPYNS0okXzLwHks+j8ZLlnBomkagu70OFMQZz zac2PhW3TrI+jGJlpadpcTbCVszQhI65ZDCvuYW8yOjYAiYntHt/z/YxW1m1Xy/UMxMQ LreA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730233246; x=1730838046; 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=RLCkoovWy+4BTP/Blm5LQHaaqE7ZHx2x3Kcfu38vCw4=; b=QkgsykkCaHlh1d9XbeeC+Y+MKX0E2BsnXOBeo+zBC2863gJ27tUMrsSI2klm6auk2C 0G/735e4f21/oJK3E/bQfDswvy2mm4xaLgtZPxYwgd80qJCWD87l8TzrFL0ZgkrD16OV O3TlWqz90U4AqEKRmKvuhXiTBeiLi3Eezr3vG5bAc9og272KHFkubvJ9+68H5jVmGDPJ 94VFiYvbDBb3psFJYI29LhVuG0ofgw5ERqs55u/gvFoTcQM+PG8GVoIbnKwi7/k1gAJo 1mFf7mQHzMT86x0HUOn9YjIxD4sr1q0ZVKY7INsloRJxqzmdtkvLRoNH8I7GXF/gf08c x48w== X-Forwarded-Encrypted: i=1; AJvYcCVBgzp9dCWTL4VStWsAzn2PuG/JXSsEP9LAJOlrdbsLWEwV19Y64/K8rIFjwvwPiJA8WQG+bwKTEA==@kvack.org X-Gm-Message-State: AOJu0Yz2Rw6wvkIzRPAm1CQsW8Yz2rgiFxBHT+uH9eOTibijJAO6mZk1 l7gKx5wsmwJGZOvxDQRx3vD1Z3j/oXtp/w4PX8+YPBAF6B3gOhjYi26jnd9EhZ0= X-Google-Smtp-Source: AGHT+IHrVUT2Y/bn1A2eEhZ3B/4Cio2x63OgV+iZejuf4OHZLNTMyIcoastoD+p+X+Hd1T8kconCzQ== X-Received: by 2002:a05:6902:102c:b0:e30:c8db:34cd with SMTP id 3f1490d57ef6-e30c8db3652mr2549661276.3.1730233246317; Tue, 29 Oct 2024 13:20: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-6d1798bd8bdsm45071796d6.54.2024.10.29.13.20.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 13:20:46 -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@vger.kernel.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 v4 2/3] x86: probe memory block size advisement value during mm init Date: Tue, 29 Oct 2024 16:20:40 -0400 Message-ID: <20241029202041.25334-3-gourry@gourry.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241029202041.25334-1-gourry@gourry.net> References: <20241029202041.25334-1-gourry@gourry.net> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: A7F0F4000D X-Stat-Signature: 1khniza56znb56ad8qjfotfy3kzkhwju X-HE-Tag: 1730233215-3052 X-HE-Meta: U2FsdGVkX1/Y4tvyIjEl6yAwUuz8dJeNG/BoR7uh4CyKtt5PSXfPhVnt+1a6NYZqNXBs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lZyg7CiyET1yM9UcpgI/voz60qKvp6R+RjM4cTVOOmoEJEtL9ESqS+43iaYZRdbF5o72e2OhlkNsICrJFd3hNxGuw0ojF+WCv9ujqil6B6u8WlXlmV4PxOOiDLqFnQDTa3OwS/N81T79HlWgm+IDh2xHZ4MfH+yESYwBGQ7lVYqN9bVg8= 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 | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index ff253648706f..01876629f21f 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -1452,16 +1452,20 @@ 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_advised_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) { + for (; bz > MIN_MEMORY_BLOCK_SIZE; bz >>= 1) { if (IS_ALIGNED(boot_mem_end, bz)) break; }