On 8/26/21 10:03 AM, Jason Xing wrote:
Honestly, I'm a little confused right now. @nr_cpu_ids is the fixed
number which means the total number of cpus the machine has.
I think, using @nr_cpu_ids is safe one way or the other regardless of
whether the cpu goes offline or not. What do you think?
More exactly, nr_cpu_ids is the max number cpu id can reach,
even in presence of holes.
I think that most/many num_online_cpus() in drivers/net are simply broken
and should be replaced by nr_cpu_ids.
The assumptions of cpus being nicely numbered from [0 to X-1],
with X==num_online_cpus() is wrong.
Same remark for num_possible_cpus(), see commit
88d4f0db7fa8 ("perf: Fix alloc_callchain_buffers()") for reference.