From nobody Thu Dec 18 20:38:35 2025 Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86B021BD9FB for ; Mon, 13 Jan 2025 17:44:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736790296; cv=none; b=i5O6bnC0UP6e6ZTSBlQMAKZ45o3+tfivLAONQctMBzbjBLLNDMHq4z0bTjFBs/jkEDPev2WcEZA69xEdyRQQDNJHM8ZXQpnE4WC7Aeet9Li24EgNWLbNWY10up7b1zVmFSQWUHpdih9pimR1Sd2tuvZyHroxDKUkC4mD17AeGWs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736790296; c=relaxed/simple; bh=Z6hmuojvYtXTroj1JJWHKwTtvZg1ohkoBA7CDtsjZso=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oIUWjA/FcofcjoXjsx0FFRb0hNiLKxloCQn8PrxmE7oLDJfiAVpjqYBUbieWCC1vQ2lNAAG8GOM503v+T9m98oogji9nKKsyBNkzWjx/EEzrNp6omEcQsiB55SpTELZl1O+V6S6IfRCtMzV277EeTiPUZD2e81NIQ53CB5JfKl8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net; spf=pass smtp.mailfrom=gourry.net; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b=cDLsdk0w; arc=none smtp.client-ip=209.85.222.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gourry.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b="cDLsdk0w" Received: by mail-qk1-f173.google.com with SMTP id af79cd13be357-7b6c3629816so260199985a.1 for ; Mon, 13 Jan 2025 09:44:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1736790292; x=1737395092; darn=vger.kernel.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=xZSM7cd0rzVSNSrAghH4+54a5vGC27L1Y4nGLMrRkSY=; b=cDLsdk0wSNVC6HsXeucUQLdvPy3zy9q05WcNaAUzzEnlg8Cxf8l0nVVrDC/i6zRhCy 2Jxx1UmKL6UgEv2mXTz71gQb9puPzYSiiJ2ifHX4jBL7h/uFy9LuLKOKSbd5i0iLBQds YYRrbIKgJdvYyJwHaT5omy8i3fWcDoc+gfHVBq7O9QGfaLosivCDBlNCiPEy2xwFQ8Fs JdqBC3vleqV4naM5YGU8N148XpoB1d6LcUzM9YkAV/4jnTHmwA5q7gHR4yKnKOzD7Zo1 ZEhU1knkgyTRDbjnofPWcew3JFYvKZ8LB/Z3TnAPMTh52lC7BTUfVFGGOENOO2dnpKlK u43w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736790292; x=1737395092; 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=xZSM7cd0rzVSNSrAghH4+54a5vGC27L1Y4nGLMrRkSY=; b=Qd34hKoFWUmxDvXr4HQh10RPs7r/uwNLqgO77L6zaRqYlPccPM2srpuqo0z11f4lkg PSSGWUgMzQ6Kgw12mflL5BKNiaYejKwaYZmoVo8F5oyewZH0iQfNejAEsCMMTle/hRYh cs2f2nqNhHcTB9+ACQlqMRA+9Fce7SxKjwVlsdrk7VlznV8YbpO2wZXDWjOZY4a3wejp zNzxRmTOv12E+b+KJj+xgL2/Le+Dssf08WhZoQ+0KrJAVsIncxAYeHvhqLSuXLqKsALJ eLVbKvsawKKpucKN7bBCrmWuPXHPsfl2BatTI1DOlVfQeTxQhvLc+n3CQ4nizKlkBs03 Kfuw== X-Forwarded-Encrypted: i=1; AJvYcCVWIeBRT1W/oNXYcGwBohUWVxeNcY5YNqa9gkj8yDKuZw3YU0y+WyH8GqTyzQvPb18q4rrcpncxTGl0CAA=@vger.kernel.org X-Gm-Message-State: AOJu0Yy2xKEk0nYz37hcQsF6vZKWdl4xbY88JBOOrlv06joERJQ/c+Jl 5wgf4QGFcYYiaiOOn4Mlwk5r7qwMfkAkF+s+E/4BDrCQUNmu3bz5JwrE6XO03mg= X-Gm-Gg: ASbGncsE1VJjmTTncJmUoK4JprNTnbJUcOgBmWY3o1mDj/t39BBiwI6q5V3lSH/MPcR tjd3VVyFrIABBoVFk4XX8z4hRnmoTVefmnShGGIxaW0b50Pr3749dQXBItfh9h1JPBxoOL9gNrP ZXAldIydbgQA6uMxOsZWfP+pPHiM16wXQpp6CPK0sPY7dP5o+VSSiHOsYEd8knTsWhRxuhXu3yP nTHuK2+dqIjDqbO17BT9UOMIdf33RkLI5jXzLynC9ixKYxVoIPKS4AaDfaEjjTDmfBZmGg5yLFr N4n9uSwrOgC7jv8Fy9HePg3OLezYmFqS83FbX3+asrSx X-Google-Smtp-Source: AGHT+IF+IF6Rv5no47DpWYrkZUPK0sDnR8tgi7nlXfUyokU9C1+7BbgLKk1J4eOLXpCwFls4u2oImw== X-Received: by 2002:a05:620a:2697:b0:7b7:24b:dc58 with SMTP id af79cd13be357-7bcd97627d1mr3005432485a.43.1736790292471; Mon, 13 Jan 2025 09:44:52 -0800 (PST) Received: from gourry-fedora-PF4VCD3F.lan (pool-173-79-56-208.washdc.fios.verizon.net. [173.79.56.208]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7bce3248c80sm511214185a.49.2025.01.13.09.44.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2025 09:44:52 -0800 (PST) From: Gregory Price To: linux-mm@kvack.org, linux-acpi@vger.kernel.org Cc: kernel-team@meta.com, x86@kernel.org, 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, rafael@kernel.org, lenb@kernel.org, david@redhat.com, osalvador@suse.de, gregkh@linuxfoundation.org, akpm@linux-foundation.org, dan.j.williams@intel.com, Jonathan.Cameron@huawei.com, alison.schofield@intel.com, rrichter@amd.com, rppt@kernel.org, gourry@gourry.net, bfaccini@nvidia.com, haibo1.xu@intel.com, dave.jiang@intel.com, Fan Ni Subject: [RESEND v7 2/3] x86: probe memory block size advisement value during mm init Date: Mon, 13 Jan 2025 12:44:38 -0500 Message-ID: <20250113174439.1965168-3-gourry@gourry.net> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250113174439.1965168-1-gourry@gourry.net> References: <20250113174439.1965168-1-gourry@gourry.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. Convert to cpu_feature_enabled() while at it.[1] [1] https://lore.kernel.org/all/20241031103401.GBZyNdGQ-ZyXKyzC_z@fat_crate= .local/ Suggested-by: Borislav Petkov Suggested-by: David Hildenbrand Signed-off-by: Gregory Price Acked-by: David Hildenbrand Acked-by: Dave Hansen Acked-by: Mike Rapoport (Microsoft) Acked-by: Dan Williams Tested-by: Fan Ni Reviewed-by: Ira Weiny --- arch/x86/mm/init_64.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index 01ea7c6df303..58ace82874eb 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -1462,16 +1462,21 @@ static unsigned long probe_memory_block_size(void) } =20 /* - * 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 =3D memory_block_advised_max_size(); + if (!bz) { bz =3D MAX_BLOCK_SIZE; - goto done; + if (!cpu_feature_enabled(X86_FEATURE_HYPERVISOR)) + goto done; + } else { + bz =3D max(min(bz, MAX_BLOCK_SIZE), MIN_MEMORY_BLOCK_SIZE); } =20 /* Find the largest allowed block size that aligns to memory end */ - for (bz =3D MAX_BLOCK_SIZE; bz > MIN_MEMORY_BLOCK_SIZE; bz >>=3D 1) { + for (; bz > MIN_MEMORY_BLOCK_SIZE; bz >>=3D 1) { if (IS_ALIGNED(boot_mem_end, bz)) break; } --=20 2.47.1