diff options
Diffstat (limited to 'libhurd-mm/storage.c')
-rw-r--r-- | libhurd-mm/storage.c | 18 |
1 files changed, 14 insertions, 4 deletions
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; |