From nobody Tue Nov 26 20:03:39 2024 Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) (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 580222141C3 for ; Wed, 16 Oct 2024 19:25:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729106718; cv=none; b=Rnq08jOGC9naWizEtcGdu+zzniBBcR4pERgkxGmsXTU8PQXRh3Wq0FrYdqKIaDlePwEt46X+gcWHupijsZa1nQBhEeg8MK1wlrwZnqdp6o0X+qriBZ+Y/RxzrsDLxTZnEk3IbkFfS2zemu5+iH7cvQZ3RG3efxtNo0oM0bxbeXY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729106718; c=relaxed/simple; bh=UFARBbqayRLFnWF98y3uEkaCwwYUXXMM3OzZ3HiPfXw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VAlUK3bKlf2eyI/vt+UCUIyp00gD+Vo+Prbv4uHAQol+xiWLNYTS6FxFeuJiqdskfb3tvG3dG9H9hHhXvGjm3Jg9/ZtcT7r/KbW8H59n07riPCW0P5uADLNqFQ5CR0/ZA0v5LPTrmoDgaAJwGGlK0PYZ7Tq/M82pIIfPOLbhtbE= 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=Hk5bp7aR; arc=none smtp.client-ip=209.85.160.170 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="Hk5bp7aR" Received: by mail-qt1-f170.google.com with SMTP id d75a77b69052e-46094b68e30so1380531cf.0 for ; Wed, 16 Oct 2024 12:25:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1729106716; x=1729711516; 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=KhSiZfD9mtqxRJdpC7TxMcZ82+QcCBZVMQrw8INyhYE=; b=Hk5bp7aR84sV4AFuoNdhLQKYRO1SAzKp65QOnd3latWq2n7RjMIOFxLRmQKJjo1AMM Ztkn2eRk1mra+G1ouMF1rJMJtntTMuIQbUduj++L1WCshVGa1INCz34oZaraXbZ6XuYo O3a6a6Bffj1J3ncunOU/gzIolYy/+CuXakCGqQvF0bBbUzpL0S44anj9f5LqkiXxdsbO SLdnw/TC81o/6M5XvZiFDjucVNYycfXv9Mf8Cx+IHg8JNh+svjM2Kly3+s1tiPmj5pow 1BHDHpRyZnXSp55iTNrx2kqHLNPCXdRrWF34pTVUC//6j4brkXdY3afOewwoQjOgomlB 9XzA== 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=RBCeFqVqq8JXZbk/xLLg/QsYRWatEc8G2kRtnv3qhJCBp+xrILsiJpE+3qbyJg+wVJ Xs9B2w08okdoS7iWhhpGJP9va4RqlGGcC+ILf3Z2WIZ/T8EKytsZGMjR+5PSXu84aRGB GrmFppFY2lH4XVLvi788pNwD7w2N8/mabV/Eiuyw4Am1Hem4h8CD50ddKEoUopD7Bt7Y KDmy8MgWIi8jjqv+FbYTlNGtmj556/NT97IBnLcdYP++FEq+bw9P5mUtRaUUFnDEpCuh PX3TXXdKsKQYjdC/L8rBM8pfkqCtLRoxWeL0C4TqimXHf2pbmBvHpZCZ8SculsKgndTn RU4A== X-Forwarded-Encrypted: i=1; AJvYcCXsFijOxpAGvTpo5DIHqWfPOrjnXwknlfmalfPy2DQvCL2oTvVhbVtPDN/aEcc5rllO+MPXhBLaHwse1Vw=@vger.kernel.org X-Gm-Message-State: AOJu0YzArfKhSM5y3dFn4kygnJ7rRGQrCi5MPCplIsDQpix2SLVL6udA 7FT2+qtxpdd+q6wnYJLj4oTu8/yC+ZP8Xx59aHMLk4Xn59mrSHxsY1CF+f2wpls= 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> 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) [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 =3D max_pfn << PAGE_SHIFT; unsigned long bz; + int order; =20 /* If memory block size has been set, then use it */ bz =3D set_memory_block_size; @@ -1451,6 +1452,21 @@ static unsigned long probe_memory_block_size(void) goto done; } =20 + /* Consider hotplug advisement value (if set) */ + order =3D memblock_probe_size_order(); + bz =3D order > 0 ? (1UL << order) : 0; + if (bz) { + /* Align down to max and up to min supported */ + bz =3D 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 >>=3D 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. --=20 2.43.0