diff options
author | Neal H. Walfield <neal@gnu.org> | 2008-12-16 20:11:34 +0100 |
---|---|---|
committer | Neal H. Walfield <neal@gnu.org> | 2008-12-16 20:11:34 +0100 |
commit | 86182db253e1dbb63ee2969a3e1a7f5ab144aed5 (patch) | |
tree | d821fa11f0eddb58b1dc9e45384744a299e633fc /libhurd-mm | |
parent | 2916276d50d4ed059453984fd48c187e7fc94338 (diff) |
Make the storage low-water mark a function of the number of threads.
2008-12-16 Neal H. Walfield <neal@gnu.org>
* storage.c (num_threads): New function.
(FREE_PAGES_LOW_WATER): Make it a function of the number of
threads.
(FREE_PAGES_SERIALIZE): Likewise.
Diffstat (limited to 'libhurd-mm')
-rw-r--r-- | libhurd-mm/ChangeLog | 7 | ||||
-rw-r--r-- | libhurd-mm/storage.c | 18 |
2 files changed, 21 insertions, 4 deletions
diff --git a/libhurd-mm/ChangeLog b/libhurd-mm/ChangeLog index f8fb701..ac6dace 100644 --- a/libhurd-mm/ChangeLog +++ b/libhurd-mm/ChangeLog @@ -1,5 +1,12 @@ 2008-12-16 Neal H. Walfield <neal@gnu.org> + * storage.c (num_threads): New function. + (FREE_PAGES_LOW_WATER): Make it a function of the number of + threads. + (FREE_PAGES_SERIALIZE): Likewise. + +2008-12-16 Neal H. Walfield <neal@gnu.org> + * storage.c (struct storage_desc) [!NDEBUG]: Add field owner. (shadow_setup): Set DESC->OWNER appropriately. (storage_alloc): Likewise. diff --git a/libhurd-mm/storage.c b/libhurd-mm/storage.c index cfdb6ed..3f774e1 100644 --- a/libhurd-mm/storage.c +++ b/libhurd-mm/storage.c @@ -325,14 +325,24 @@ storage_shadow_setup (struct cap *cap, addr_t folio) static bool storage_init_done; -/* The minimum number of pages that should be available. This should - probably be per-thread (or at least per-CPU). */ -#define FREE_PAGES_LOW_WATER 64 +static int +num_threads (void) +{ + extern int __pthread_num_threads __attribute__ ((weak)); + + if (&__pthread_num_threads) + return __pthread_num_threads; + else + return 1; +} + +/* The minimum number of pages that should be available. */ +#define FREE_PAGES_LOW_WATER (32 + 16 * num_threads ()) /* If the number of free pages drops below this amount, the we might soon have a problem. In this case, we serialize access to the pool of available pages to allow some thread that is able to allocate more pages the chance to do so. */ -#define FREE_PAGES_SERIALIZE 32 +#define FREE_PAGES_SERIALIZE (16 + 8 * num_threads ()) static pthread_mutex_t storage_low_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; |