Thread (33 messages) 33 messages, 9 authors, 2021-12-15

Re: [PATCH 7/9] lib/cpumask: add num_{possible,present,active}_cpus_{eq,gt,le}

From: Yury Norov <yury.norov@gmail.com>
Date: 2021-11-28 06:36:54
Also in: kvm, linux-alpha, linux-crypto, linux-mips, linux-mm, linux-perf-users, linux-riscv, linux-s390, lkml

(restore CC list)

On Sun, Nov 28, 2021 at 05:56:51AM +0100, Michał Mirosław wrote:
On Sat, Nov 27, 2021 at 07:57:02PM -0800, Yury Norov wrote:
quoted
Add num_{possible,present,active}_cpus_{eq,gt,le} and replace num_*_cpus()
with one of new functions where appropriate. This allows num_*_cpus_*()
to return earlier depending on the condition.
[...]
quoted
@@ -3193,7 +3193,7 @@ int __init pcpu_page_first_chunk(size_t reserved_size,
 
 	/* allocate pages */
 	j = 0;
-	for (unit = 0; unit < num_possible_cpus(); unit++) {
+	for (unit = 0; num_possible_cpus_gt(unit); unit++) {
This looks dubious.
Only this?
The old version I could hope the compiler would call
num_possible_cpus() only once if it's marked const or pure, but the
alternative is going to count the bits every time making this a guaranteed
O(n^2) even though the bitmap doesn't change.
num_possible_cpus() is not const neither pure. This is O(n^2) before and after.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help