From bc31075886288487b51b1a856f8718011a5d69e6 Mon Sep 17 00:00:00 2001 From: neal Date: Mon, 23 Jun 2008 19:53:37 +0000 Subject: 2008-06-23 Neal H. Walfield * pager.h (pager_min_alloc_before_next_collect): New declaration. (pager_collect_needed): Only collect if AVAILABLE_PAGES > PAGER_LOW_WATER_MARK and PAGER_MIN_ALLOC_BEFORE_NEXT_COLLECT > 0. (pager_collect_needed): Don't include the dirty, non-discardable pages when consider if a collection is required. * pager.c (pager_min_alloc_before_next_collect): New variable. (pager_collect): If we don't collect enough pages to exceed the high water mark, set PAGER_MIN_ALLOC_BEFORE_NEXT_COLLECT to two-thirds the available pages. * memory.c (memory_frame_allocate): On success, decrement PAGER_MIN_ALLOC_BEFORE_NEXT_COLLECT. --- viengoos/pager.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'viengoos/pager.h') diff --git a/viengoos/pager.h b/viengoos/pager.h index d5f8cf7..1d8d1ef 100644 --- a/viengoos/pager.h +++ b/viengoos/pager.h @@ -31,8 +31,15 @@ extern int pager_collect (int goal); /* We try to keep at least 1/8 (12.5%) of memory available for - immediate allocation. */ + immediate allocation... */ #define PAGER_LOW_WATER_MARK (memory_total / 8) + +/* ... although we try, we don't always succeed. In such a case, + repeated collections won't help. Instead, we need to hope that + user-tasks clean up a bit. This requires giving them a bit of + time. Thus, we only collect again after this many allocations. */ +extern int pager_min_alloc_before_next_collect; + /* When we start freeing, we try to get at least 3/16 (~19%) of memory available for immediate allocation. */ #define PAGER_HIGH_WATER_MARK \ @@ -45,12 +52,16 @@ static inline int pager_collect_needed (void) { int available_pages = zalloc_memory - + available_list_count (&available) + + available_list_count (&available); +#if 0 + /* XXX: Until we have a disk pager... */ /* We only count the pages on the laundry half as they won't be available immediately. */ + laundry_list_count (&laundry) / 2; +#endif - if (available_pages > PAGER_LOW_WATER_MARK) + if (available_pages > PAGER_LOW_WATER_MARK + || pager_min_alloc_before_next_collect > 0) return 0; return PAGER_HIGH_WATER_MARK - available_pages; -- cgit v1.2.3