On Thu, 21 Jan 2021 at 11:01, Christoph Lameter <cl@xxxxxxxxx> wrote: > > On Thu, 21 Jan 2021, Bharata B Rao wrote: > > > > The problem is that calculate_order() is called a number of times > > > before secondaries CPUs are booted and it returns 1 instead of 224. > > > This makes the use of num_online_cpus() irrelevant for those cases > > > > > > After adding in my command line "slub_min_objects=36" which equals to > > > 4 * (fls(num_online_cpus()) + 1) with a correct num_online_cpus == 224 > > > , the regression diseapears: > > > > > > 9 iterations of hackbench -l 16000 -g 16: 3.201sec (+/- 0.90%) > > > > Should we have switched to num_present_cpus() rather than > > num_online_cpus()? If so, the below patch should address the > > above problem. > > There is certainly an initcall after secondaries are booted where we could > redo the calculate_order? > > Or the num_online_cpus needs to be up to date earlier. Why does this issue > not occur on x86? Does x86 have an up to date num_online_cpus earlier? I have added a printk in calculate_order() : pr_info(" SLUB calculate_order cmd %d min %d online %d present %d possible %d cpus %d", slub_min_objects, min_objects, num_online_cpus(), num_present_cpus(), num_possible_cpus(), nr_cpu_ids); And checked with qemu-system-x86_64 -kernel bzImage -nographic -smp 4 -append "console=ttyS0" [ 0.064927] SLUB calculate_order cmd 0 min 8 online 1 present 4 possible 4 cpus 4 [ 0.064970] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1 The num_online_cpus has the same behavior as on my platform and num_online_cpus = 1 when kmem_cache_init() is called Only the num_present_cpus = 4 from the beginning but that's probably just because it runs in a VM Also it's interesting to notice that num_possible_cpus and nr_cpu_ids are set to the correct value > >