From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 155D1446AC; Mon, 1 Apr 2024 16:14:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711988071; cv=none; b=GB8/ouqCIdVe72BdJSK4QUnkdqYV1vKm79PlVYqhceWqBe5zZLBdgYd/c5y0YEjNJTpga53LnRpCvDznpNU37LdNRnlOTk3g5dYRRPskhzv0JpFrrnCIgw25NRYTYQ0aR48UUZ7XrkCPGzFV/WHK0uQU4qebXZ3nZmxWoanwyUw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711988071; c=relaxed/simple; bh=tcDaBtd+gRbaiKqRVZZO9RCUmkTwp8D7bdtZPeY/Br4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UhOPEyG80mB1Vsv/auh7HcqGlEX1Gh7oRZwO+8h7d3wq3nuWu4lBQowYyuDmd5UlxnGGkDHIdqWonzoWDYih1tZq9sLvRkjftI2Hvr/hT1yLRpKpCC1Bx37q1dvmzZwqqmn+fnnYoITyU4jJ2314FJfhxC0hQCA3U9VbrhCsAOc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=kggIbE+P; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="kggIbE+P" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 759B9C433C7; Mon, 1 Apr 2024 16:14:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1711988070; bh=tcDaBtd+gRbaiKqRVZZO9RCUmkTwp8D7bdtZPeY/Br4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kggIbE+P1CXg6J0otvoaRIU8uo8DilA8Wf6iL99hflf2AaddCHuVfyHYC8MpZkyjZ oN8ChbGJEZNXCGptXDcAWFiyvN6IkruSvccZnZO7SC8layRc7gHNCgXyqy9PXxFfet /KXGj9LUVeuJbXxhlNLeyXKfO8ccwdxUW1gbLSfs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Matthew Wilcox (Oracle)" , Rik van Riel , Mel Gorman , Peter Zijlstra , Ingo Molnar , Andrew Morton , Sasha Levin Subject: [PATCH 6.7 046/432] bounds: support non-power-of-two CONFIG_NR_CPUS Date: Mon, 1 Apr 2024 17:40:33 +0200 Message-ID: <20240401152554.502437574@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240401152553.125349965@linuxfoundation.org> References: <20240401152553.125349965@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.7-stable review patch. If anyone has any objections, please let me know. ------------------ From: Matthew Wilcox (Oracle) [ Upstream commit f2d5dcb48f7ba9e3ff249d58fc1fa963d374e66a ] ilog2() rounds down, so for example when PowerPC 85xx sets CONFIG_NR_CPUS to 24, we will only allocate 4 bits to store the number of CPUs instead of 5. Use bits_per() instead, which rounds up. Found by code inspection. The effect of this would probably be a misaccounting when doing NUMA balancing, so to a user, it would only be a performance penalty. The effects may be more wide-spread; it's hard to tell. Link: https://lkml.kernel.org/r/20231010145549.1244748-1-willy@infradead.org Signed-off-by: Matthew Wilcox (Oracle) Fixes: 90572890d202 ("mm: numa: Change page last {nid,pid} into {cpu,pid}") Reviewed-by: Rik van Riel Acked-by: Mel Gorman Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Signed-off-by: Andrew Morton Signed-off-by: Sasha Levin --- kernel/bounds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/bounds.c b/kernel/bounds.c index b529182e8b04f..c5a9fcd2d6228 100644 --- a/kernel/bounds.c +++ b/kernel/bounds.c @@ -19,7 +19,7 @@ int main(void) DEFINE(NR_PAGEFLAGS, __NR_PAGEFLAGS); DEFINE(MAX_NR_ZONES, __MAX_NR_ZONES); #ifdef CONFIG_SMP - DEFINE(NR_CPUS_BITS, ilog2(CONFIG_NR_CPUS)); + DEFINE(NR_CPUS_BITS, bits_per(CONFIG_NR_CPUS)); #endif DEFINE(SPINLOCK_SIZE, sizeof(spinlock_t)); #ifdef CONFIG_LRU_GEN -- 2.43.0