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 0AF4E47F51; Mon, 1 Apr 2024 15:51:03 +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=1711986663; cv=none; b=eEmjCQi+QujB29eN3NYybhL0V8LFdMAViPBaq/TDuiSJR3VUaYFykR5AqfBa9M9Tv/Kfjm85TmmV8pBxHA5GWSO0CsSNbTb2lnMSAL/4izAFzIKPKLGWjF72UX6+J6K0mVgUXEzP0680a24rwxzryPpBsWU4K/NEP+wybw0NM4M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711986663; c=relaxed/simple; bh=NHqNq4fIZS2A22xOoPmT4wPnWLxXpYiTjL42cy3PQe8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LYOwtyXx5y3+LSn8FgSlorpBTDMhNO1+39z5WpOsxe1T+hMOqg7+UVxpKrzPbi2Nj0hVrYs4tQIjmz0PoFvpWg91pxinGgrcRBElxHTvz0dQHPOtU05XNzhb+VcQcGCiPGcYf15x5Wfdf+pzbRU1+Mn3Gq0TFsYATXxzie1k6FQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=H/eTtZ5l; 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="H/eTtZ5l" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89AC8C433B1; Mon, 1 Apr 2024 15:51:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1711986662; bh=NHqNq4fIZS2A22xOoPmT4wPnWLxXpYiTjL42cy3PQe8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H/eTtZ5ljxHb/ZgDtqO1s3Tywh5ewtscKqFy7D8Fv2HYM0mVKbl4E+DNqCcseD/Fe MvHN7DytmvnJDw42AHxvarUihAmG7SRemNj5vNQhHvfoI6lFJXuMR7b5uzVriR97vl M2BDU8LxJZfRSjMJBsskbwmNgotiWkYYvZ8wFtx8= 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.8 046/399] bounds: support non-power-of-two CONFIG_NR_CPUS Date: Mon, 1 Apr 2024 17:40:12 +0200 Message-ID: <20240401152550.550452258@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240401152549.131030308@linuxfoundation.org> References: <20240401152549.131030308@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.8-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