Page Coloring Defines in vm_page.h
Matthew Dillon
dillon at apollo.backplane.com
Tue Jun 24 09:30:27 PDT 2003
: - The page queue structures are sized according to these
: defines at boot-time.
:
: - If someone could fill me in on how the primes are arrived at that
: would be very helpful.
:
:Comments/discussion/correction welcomed, it would be good to get some
:feedback on this before I start patching my tree.
:
:BMS
The primes are designed such that the page allocation code covers
*ALL* the free lists in the array, so it will still be able to find
any available free pages if its first choice(s) are empty.
For example, prime number 3 an array size 8 will scan the array in
the following order N = (N + PRIME) & (ARRAY_SIZE_MASK).
N = (N + 3) & 7:
0 3 6 1 4 7 2 5 ... 0
As you can see, all the array entries are covered before the sequence
repeats. So if we want a free page in array slot 0 but the only
free pages available happen to be in array slot 5, the above algorithm
is guarenteed to find it.
Only certain prime number / power-of-2-array size combinations have
this effect, but it is very easy to write a little program to test
combinations and find the numbers best suited to your goals.
-Matt
Matthew Dillon
<dillon at backplane.com>
More information about the freebsd-hackers
mailing list