From nobody Wed Dec 17 12:49:20 2025 Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) (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 7BEAC149C7D for ; Mon, 27 Jan 2025 15:34:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737992059; cv=none; b=LFSSrtpxRQmTDdt8MLJ2bPQ3P0CF2/qcD2eQ9Ts21gKMpDQcweocbJ2P1LcoSXpelyk67fAz/Ef6tZpsDrb0zXKuSMbGxGrF/Gd8Djgzc7OAt9a95RY4Zx19+o3O7H9qVTOScNVj060L5Qv60Jdp5ZhlPQAnDK0mE1ABYk+O5Zo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737992059; c=relaxed/simple; bh=9Bnw9+CkdHqaCLM0YEFQRfjPOnve6pPOiFVrRE8u43Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sXy0zu08JpNggFJ/gC/gBET9f4073NTit7OsQ7wIqLdJzuBCmAoEL8STlzN7j+NXcjpa3ShLyJJSYIb/YL/IkB656/iuOVkjEQy1i452mMhUxDoBRLfQEi2Y5obHJa6thoHgDxCNgzhF61hUfzek7FIpmo6i3BTapOdFyo0SD6U= 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=lQIjy5KV; arc=none smtp.client-ip=209.85.219.43 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="lQIjy5KV" Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-6dcdd9a3e54so46012156d6.3 for ; Mon, 27 Jan 2025 07:34:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1737992056; x=1738596856; 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=cuGLm5QAWvME/iYTUeN4C38ZerEmS6SWYSvNtkJw+ks=; b=lQIjy5KVxE7WdL4ONGFzbxw4loh5PvryKwkMZJVwnKzMzHjpVIrznT7yXaX2Rus86I rRBbSR5SAvDfJOkX0Sj8eYL0+hpsqXbFoRvEYdc+5W52BWbTmeaAx9GnLWoDVD99mNDk OAQKoN/EHBKIwEg9B7AXfgwgAHO2WuGcURW1ZGMTutNyq7R9vq9DfKfQrNJnbrFCuP/3 z0JhYNARN0ixszY+/J2sXLIpm7BM2c4yGFuc+guvVLfe4MvGEHQ5jeLT6YRb0kexxZev 06iF2WBi8u46Il4Yk83+2i0WX6SsJ4ZN4oNatwRatbj4uAbK5AefpfOtwb1bYx1YR/xm URAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737992056; x=1738596856; 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=cuGLm5QAWvME/iYTUeN4C38ZerEmS6SWYSvNtkJw+ks=; b=AHLwJesWkh5MLcu54grcYc4Dejp1VuPoGE11PfHfdjDllj5L6QEAlYs70sTShMbv3G jzHs//BIkQzv+Zg8kK98WFjAbERQqqj1vBveSr5SHyeCPTy4Wt4KN/7go/X7oil3sk5+ 5D66njOF4MtX22b1Fi/Pwv4MjCYOOQgelYQuWbYwFSc41/qXX9LH268C0Pmtn1Chr5t0 uOEo4aCkApyIy34QdijxDGmi0Td8aMeEDcMF1yIVQpRUrg4W4y8Hnm1N+Ir6XEjBwbAr AFCgWP1icJYX/zaRpcAsVL6gTC0KJ/OyvnC37CSt/+vhVyJRnr1fsLD2Xeh807otRGv6 ijZw== X-Forwarded-Encrypted: i=1; AJvYcCUrSfAZ6ENTiJJg/2N3ZnfWS0llESMLZu99t7IGRegZuXhCljhqbiMrQxHxP2iWTRzgDs/s+BhWJd1Jk4A=@vger.kernel.org X-Gm-Message-State: AOJu0Yyc28yUiQY6oNJLFieDn5GsjQL91sdQYCcQ3Hbo0/Bkoc2BE6nc IK+EfWqsz/RvliJqaTtbsmHt7D2FlWqj72cD8QID7BAUslpBu+UgOqSc7nr8Tcw= X-Gm-Gg: ASbGncsmiT0EmFReIwT6my6LVMwib719BvBUr8fCWaiuiC7vXNEEwR+gp8AkSliQXMg B1npGKfEOmxxozksVrPFkAlF+egrgyp81Sp4eBP7eYPSMUlIBBjgD7Pt7YYJKfsALqOpSjrAnO2 afk32o0iW8IRpzMqmkGG8jYxG+fIlnudX5TLaL3yha6Zt9ZX3fvWcZDKz5qqsj2al+/IrVZsQqf ZK3CEdEHCsWS5NvGN80VV3vrjnMC45fWe6EYktKc81WBlCf+tiliGDKBv7TCCRLeQ6nwSi0TFg0 dX5wyVkeOZteoT39Yhut0vdMau5Yxvizk+/kVVjWEeT0BBHpZFek9Exi+MkBxpwOczqk X-Google-Smtp-Source: AGHT+IH3YD2uq0s2UOyUMAffGvHi1zghb5NCWsDgLZca9QQje9OVBrkdwmDEWT3QH9fizy2t68UjHA== X-Received: by 2002:a05:6214:1248:b0:6d8:b3ee:8b72 with SMTP id 6a1803df08f44-6e1b2229d49mr616446186d6.32.1737992056362; Mon, 27 Jan 2025 07:34:16 -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 6a1803df08f44-6e2058c2a51sm35380476d6.109.2025.01.27.07.34.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2025 07:34:15 -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 , Ira Weiny Subject: [PATCH v8 2/3] x86: probe memory block size advisement value during mm init Date: Mon, 27 Jan 2025 10:34:04 -0500 Message-ID: <20250127153405.3379117-3-gourry@gourry.net> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250127153405.3379117-1-gourry@gourry.net> References: <20250127153405.3379117-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 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 Signed-off-by: Gregory Price Acked-by: Oscar Salvador --- 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.48.1