Date: Tue, 24 Jun 2003 09:30:25 -0700 (PDT) From: Matthew Dillon <dillon@apollo.backplane.com> To: Bruce M Simpson <bms@spc.org> Cc: hackers@FreeBSD.ORG Subject: Re: Page Coloring Defines in vm_page.h Message-ID: <200306241630.h5OGUPU6094228@apollo.backplane.com> References: <20030624111942.GO31354@spc.org>
next in thread | previous in thread | raw e-mail | index | archive | help
: - 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@backplane.com>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200306241630.h5OGUPU6094228>