diff --git a/nest/cmds.c b/nest/cmds.c index 96a3ec91..0748c74f 100644 --- a/nest/cmds.c +++ b/nest/cmds.c @@ -120,9 +120,9 @@ cmd_show_memory(void) print_size("Protocols:", rmemsize(proto_pool)); struct resmem total = rmemsize(&root_pool); #ifdef HAVE_MMAP - int pages_kept = atomic_load_explicit(&pages_kept, memory_order_relaxed); - print_size("Standby memory:", (struct resmem) { .overhead = page_size * pages_kept }); - total.overhead += page_size * pages_kept; + int pk = atomic_load_explicit(&pages_kept, memory_order_relaxed); + print_size("Standby memory:", (struct resmem) { .overhead = page_size * pk }); + total.overhead += page_size * pk; #endif print_size("Total:", total); cli_msg(0, ""); diff --git a/sysdep/unix/alloc.c b/sysdep/unix/alloc.c index 47cd4624..1559fe97 100644 --- a/sysdep/unix/alloc.c +++ b/sysdep/unix/alloc.c @@ -93,9 +93,7 @@ alloc_page(void) if (!fp) return alloc_sys_page(); - if (atomic_fetch_sub_explicit(&pages_kept, 1, memory_order_relaxed) <= KEEP_PAGES_MIN) - SCHEDULE_CLEANUP; - + atomic_fetch_sub_explicit(&pages_kept, 1, memory_order_relaxed); return fp; #endif } @@ -146,15 +144,15 @@ page_cleanup(void *_ UNUSED) else free_page(f); } - while (stack && (atomic_fetch_sub_explicit(&pages_kept, 1, memory_order_relaxed) >= KEEP_PAGES_MAX / 2)); + while ((atomic_fetch_sub_explicit(&pages_kept, 1, memory_order_relaxed) >= KEEP_PAGES_MAX / 2) && stack); while (stack) { - atomic_fetch_sub_explicit(&pages_kept, 1, memory_order_relaxed); - struct free_page *f = stack; stack = atomic_load_explicit(&f->next, memory_order_acquire); free_page(f); + + atomic_fetch_sub_explicit(&pages_kept, 1, memory_order_relaxed); } } #endif