[Bug 274316] excessive memory consumed by static_single_cpu_mask

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 07 Oct 2023 00:02:42 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=274316

--- Comment #2 from Ed Maste <emaste@freebsd.org> ---
We can switch to run-time sizing for these, but there's a very interesting
observation used by Linux that we can adopt, to significantly reduce the memory
used.

We have (currently) MAXCPU count of cpuset_ts, each with one CPU set. Note that
all but one of the longs making up each cpuset_t is zero.

If n=__bitset_words(MAXCPU) then cpuset_t is an array of long __bits[n]. If we
have (n-1) long zeros, 0x1, (n-1) long zeros, 0x2, (n-1) long zeros, and so on,
with an appropriate offset we can use that same 0x1 for:

0000000000000000 0000000000000000 ... 0000000000000000 0000000000000001
0000000000000000 0000000000000000 ... 0000000000000001 0000000000000000
...
0000000000000000 0000000000000001 ... 0000000000000000 0000000000000000
0000000000000001 0000000000000000 ... 0000000000000000 0000000000000000

and so on for 0x2, etc.

-- 
You are receiving this mail because:
You are the assignee for the bug.