LinuxKPI: reduce impact of large MAXCPU
authorBjoern A. Zeeb <bz@FreeBSD.org>
Mon, 23 Oct 2023 23:14:35 +0000 (23:14 +0000)
committerBjoern A. Zeeb <bz@FreeBSD.org>
Fri, 22 Dec 2023 00:22:04 +0000 (00:22 +0000)
commit488e8a7faca51a71987fbf00cd36cfcd19269db7
tree0d8bfde495fffbc27d8148391374242e3371fc6b
parente85eb4c8d7bd8051c351a6fc6982a8b3bcfdbb2d
LinuxKPI: reduce impact of large MAXCPU

Start scaling arrays dynamically instead of using MAXCPU, resulting in
extra allocations on startup but reducing the overall memory footprint.
For the static single CPU mask we provide two versions to further save
memory depending on a low or high CPU count system.  The threshold to
switch is currently at 128 CPUs on 64bit platforms.
More detailed comments on the implementations can be found in the code.

If I am not wrong on a MAXCPU=65536 system the memory footprint should
roughly go down from 512M to 1.5M for the static single CPU mask.

Submitted by: olce (most of this final version)
Sponsored by: The FreeBSD Foundation
PR: 274316
Differential Revision: https://reviews.freebsd.org/D42345
sys/compat/linuxkpi/common/include/asm/processor.h
sys/compat/linuxkpi/common/src/linux_compat.c