On 09/22/23 at 09:00am, Vlastimil Babka wrote: > On 9/16/23 03:28, Baoquan He wrote: > > On 09/08/23 at 04:53pm, Vlastimil Babka wrote: > >> @@ -4152,7 +4147,7 @@ static inline int calculate_order(unsigned int size) > >> * order on systems that appear larger than they are, and too > >> * low order on systems that appear smaller than they are. > >> */ > >> - nr_cpus = num_present_cpus(); > >> + unsigned int nr_cpus = num_present_cpus(); > >> if (nr_cpus <= 1) > >> nr_cpus = nr_cpu_ids; > >> min_objects = 4 * (fls(nr_cpus) + 1); > > > > A minor concern, should we change 'min_objects' to be a local static > > to avoid the "if (!min_objects) {" code block every time? It's deducing > > the value from nr_cpus, we may not need do the calculation each time. > > Maybe, although it's not a hot path. But we should make sure the > num_present_cpus() cannot change. Could it be e.g. low (1) very early when > we bootstrap the initial caches, but then update and at least most of the > caches then reflect the real number of cpus? With a static we would create > everything with 1. Yeah, I was silly, didn't think about it. We may check via system_state, but it's not worth to bother since it's not hot path as you said. Sorry for the noise.