0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-11-18 17:18:42 +00:00

Fixed display of standby memory

This commit is contained in:
Maria Matejka 2022-09-20 14:57:43 +02:00
parent a00e0b5930
commit 28d4ac6c97
2 changed files with 7 additions and 9 deletions

View File

@ -120,9 +120,9 @@ cmd_show_memory(void)
print_size("Protocols:", rmemsize(proto_pool)); print_size("Protocols:", rmemsize(proto_pool));
struct resmem total = rmemsize(&root_pool); struct resmem total = rmemsize(&root_pool);
#ifdef HAVE_MMAP #ifdef HAVE_MMAP
int pages_kept = atomic_load_explicit(&pages_kept, memory_order_relaxed); int pk = atomic_load_explicit(&pages_kept, memory_order_relaxed);
print_size("Standby memory:", (struct resmem) { .overhead = page_size * pages_kept }); print_size("Standby memory:", (struct resmem) { .overhead = page_size * pk });
total.overhead += page_size * pages_kept; total.overhead += page_size * pk;
#endif #endif
print_size("Total:", total); print_size("Total:", total);
cli_msg(0, ""); cli_msg(0, "");

View File

@ -93,9 +93,7 @@ alloc_page(void)
if (!fp) if (!fp)
return alloc_sys_page(); return alloc_sys_page();
if (atomic_fetch_sub_explicit(&pages_kept, 1, memory_order_relaxed) <= KEEP_PAGES_MIN) atomic_fetch_sub_explicit(&pages_kept, 1, memory_order_relaxed);
SCHEDULE_CLEANUP;
return fp; return fp;
#endif #endif
} }
@ -146,15 +144,15 @@ page_cleanup(void *_ UNUSED)
else else
free_page(f); 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) while (stack)
{ {
atomic_fetch_sub_explicit(&pages_kept, 1, memory_order_relaxed);
struct free_page *f = stack; struct free_page *f = stack;
stack = atomic_load_explicit(&f->next, memory_order_acquire); stack = atomic_load_explicit(&f->next, memory_order_acquire);
free_page(f); free_page(f);
atomic_fetch_sub_explicit(&pages_kept, 1, memory_order_relaxed);
} }
} }
#endif #endif