On Thu, Nov 16, 2023 at 09:15:26AM +0800, Hou Tao wrote: > > If we have a machine with 8GB, 6 present CPUs and 512 possible CPUs (yes, > > this is a realistic scenario) the memory consumption directly after boot > > is: > > > > $ cat /sys/devices/system/cpu/present > > 0-5 > > $ cat /sys/devices/system/cpu/possible > > 0-511 > > Will the present CPUs be hot-added dynamically and eventually increase > to 512 CPUs ? Or will the present CPUs rarely be hot-added ? After all > possible CPUs are online, will these CPUs be hot-plugged dynamically ? > Because I am considering add CPU hotplug support for bpf mem allocator, > so we can allocate memory according to the present CPUs instead of > possible CPUs. But if the present CPUs will be increased to all possible > CPUs quickly, there will be not too much benefit to support hotplug in > bpf mem allocator. You can assume that the present CPUs would change only very rarely. Even though we are only talking about virtual CPUs in this case systems are usually setup in a way that they have enough CPUs for their workload. Only if that is not the case additional CPUs may be added (and brought online) - which is usually much later than boot time. Obviously the above is even more true for systems where you have to add new CPUs in a physical way in order to change present CPUs. So I guess it is fair to assume that if there is such a large difference between present and possible CPUs, that this will also stay that way while the system is running in most cases. Or in other words: it sounds like it is worth to add CPU hotplug support for the the bpf mem allocator (without that I would know what that would really mean for the bpf code). Note for the above numbers: I hacked the number of possible CPUs manually in the kernel code just to illustrate the high memory consumption for the report. On a real system you would see "0-399" CPUs instead. But that's just a minor detail.