diff options
author | Richard Braun <rbraun@sceen.net> | 2012-07-08 00:31:53 +0000 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2012-07-08 00:31:53 +0000 |
commit | 8d219eab0dcfbdcf464340630d568c4e16d7acbd (patch) | |
tree | affcb7ed98bf127697f53393e9437bd10ff957a5 | |
parent | 27150b21c3366d6b474fe3e69140ecac65ab7ed2 (diff) |
Fix slab collection timing
The slab garbage collector uses sched_tick as its time reference, which
is increased every seconds, while the interval is expressed in clock
ticks. Use the proper time reference instead.
* kern/slab.c (kmem_gc_last_tick): Declare as unsigned long.
(slab_collect): Use elapsed_ticks instead of sched_tick.
-rw-r--r-- | kern/slab.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/kern/slab.c b/kern/slab.c index ea38eb0..64f1fa8 100644 --- a/kern/slab.c +++ b/kern/slab.c @@ -130,7 +130,7 @@ #define KMEM_BUF_SIZE_THRESHOLD (PAGE_SIZE / 8) /* - * Time (in seconds) between two garbage collection operations. + * Time (in ticks) between two garbage collection operations. */ #define KMEM_GC_INTERVAL (5 * hz) @@ -286,7 +286,7 @@ vm_map_t kmem_map = &kmem_map_store; /* * Time of the last memory reclaim, in clock ticks. */ -static unsigned int kmem_gc_last_tick; +static unsigned long kmem_gc_last_tick; #define kmem_error(format, ...) \ printf("mem: error: %s(): " format "\n", __func__, \ @@ -1312,10 +1312,10 @@ void slab_collect(void) { struct kmem_cache *cache; - if (sched_tick <= (kmem_gc_last_tick + KMEM_GC_INTERVAL)) + if (elapsed_ticks <= (kmem_gc_last_tick + KMEM_GC_INTERVAL)) return; - kmem_gc_last_tick = sched_tick; + kmem_gc_last_tick = elapsed_ticks; simple_lock(&mem_cache_list_lock); |