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 9069A7175B; Mon, 8 Apr 2024 13:04:14 +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=1712581454; cv=none; b=sFFUTZUMP9QuORucQLu/8YZIgxzK2iEk2zJAb26yqrWIyPmaBnT2V2EpknO92biDtP3BpVURrlQ++KoIqSGPAVzNiNsqntzDtY2AX+60pHPuooSzcCWqSzwEdQn8YnEuJnADuO+0vSgjmyy8c4oLWX/iex6cNT/BDYq3fDYZtY4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712581454; c=relaxed/simple; bh=3Bj6yCY0is7iVoGbnPPmym2zbw20LNmgPv7VK83kR8Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sO8fGQ23Fd2e04VPPuCYt2S/3LDcp1LYatwdnhOXbQASQMgnreOKYxxGYuEdRdpu3AAuUSkE+pyoHW3hqNOqWO5mEkwGPw6J+B76N1EUebfuuKEAheI8CZFRgPVCgnJtBPtU2M8vVqBoLE0W54xyWvAoD1EXSTJ4vwmmyUJR4Sc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ANOYDfeE; 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="ANOYDfeE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1821BC433F1; Mon, 8 Apr 2024 13:04:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1712581454; bh=3Bj6yCY0is7iVoGbnPPmym2zbw20LNmgPv7VK83kR8Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ANOYDfeE+YzQ8D7rigVMF+XH6UGHazvjqk0yn4c4yGwKU9AbaZSmPA6y/xaB/bale bUu54HrbErUMyfR2rQxTRGJoBQSchPPkejjkDpvGpxSund1VeJDRGF3Hn7Oea+NjTQ 0p/igOxegvTGn0bimbr/Ev2NeTs92/79vmEhsNQM= 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 5.15 029/690] bounds: support non-power-of-two CONFIG_NR_CPUS Date: Mon, 8 Apr 2024 14:48:15 +0200 Message-ID: <20240408125400.611180376@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240408125359.506372836@linuxfoundation.org> References: <20240408125359.506372836@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 5.15-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 9795d75b09b23..a94e3769347ee 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)); /* End of constants */ -- 2.43.0