0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2025-03-11 17:08:46 +00:00

Merge commit '707cad61' into thread-next

This commit is contained in:
Maria Matejka 2024-12-13 18:40:11 +01:00
commit 93621ed9f4
5 changed files with 31 additions and 13 deletions

View File

@ -1508,11 +1508,12 @@ This argument can be omitted if there exists only a single instance.
Control protocol debugging. Control protocol debugging.
<tag><label id="cli-dump">dump resources|sockets|interfaces|neighbors|attributes|routes|protocols "<m/file/"</tag> <tag><label id="cli-dump">dump resources|sockets|interfaces|neighbors|attributes|routes|protocols "<m/file/"</tag>
Truncates the given file and dumps contents of internal data structures Creates the given file (it must not exist) and dumps contents of
there. By sending SIGUSR1, you get all of these concatenated to internal data structures there. By sending SIGUSR1, you get all of
<cf/bird.dump/ in the current directory. The file is only readable for these concatenated to <cf/bird.dump/ in the current directory.
the user running the daemon. The format of dump files is internal and The file is only readable for the user running the daemon.
could change in the future. The format of dump files is internal and could change in the future
without any notice.
<tag><label id="cli-echo">echo all|off|{ <m/list of log classes/ } [ <m/buffer-size/ ]</tag> <tag><label id="cli-echo">echo all|off|{ <m/list of log classes/ } [ <m/buffer-size/ ]</tag>
Control echoing of log messages to the command-line output. Control echoing of log messages to the command-line output.

View File

@ -153,6 +153,7 @@ extern _Atomic int pages_kept;
extern _Atomic int pages_kept_locally; extern _Atomic int pages_kept_locally;
extern _Atomic int pages_kept_cold; extern _Atomic int pages_kept_cold;
extern _Atomic int pages_kept_cold_index; extern _Atomic int pages_kept_cold_index;
extern _Atomic int pages_total;
void *alloc_page(void); void *alloc_page(void);
void free_page(void *); void free_page(void *);
void flush_local_pages(void); void flush_local_pages(void);

View File

@ -123,18 +123,29 @@ cmd_show_memory(void)
print_size("Current config:", rmemsize(config_pool)); print_size("Current config:", rmemsize(config_pool));
struct resmem total = rmemsize(&root_pool); struct resmem total = rmemsize(&root_pool);
#ifdef HAVE_MMAP #ifdef HAVE_MMAP
int pk = atomic_load_explicit(&pages_kept, memory_order_relaxed) uint hot_pages = atomic_load_explicit(&pages_kept, memory_order_relaxed)
+ atomic_load_explicit(&pages_kept_locally, memory_order_relaxed) + atomic_load_explicit(&pages_kept_locally, memory_order_relaxed);
+ atomic_load_explicit(&pages_kept_cold_index, memory_order_relaxed); uint cold_pages_index = atomic_load_explicit(&pages_kept_cold_index, memory_order_relaxed);
print_size("Standby memory:", (struct resmem) { .overhead = page_size * pk }); print_size("Standby memory:", (struct resmem) { .overhead = page_size * (hot_pages + cold_pages_index) });
total.overhead += page_size * pk; total.overhead += page_size * (hot_pages + cold_pages_index);
#endif #endif
print_size("Total:", total); print_size("Total:", total);
cli_msg(-1018, "");
#ifdef HAVE_MMAP #ifdef HAVE_MMAP
struct size_args cold = get_size_args(atomic_load_explicit(&pages_kept_cold, memory_order_relaxed) * page_size); uint cold_pages = atomic_load_explicit(&pages_kept_cold, memory_order_relaxed);
cli_msg(-1018, "%-23s " SIZE_FORMAT, "Cold memory:", SIZE_ARGS(cold)); uint pages_total_loc = atomic_load_explicit(&pages_total, memory_order_relaxed);
uint pages_active = pages_total_loc - hot_pages - cold_pages_index - cold_pages;
struct size_args active = get_size_args(page_size * pages_active);
struct size_args kept = get_size_args(page_size * (hot_pages + cold_pages_index));
struct size_args cold = get_size_args(page_size * cold_pages);
cli_msg(-1018, "%-17s " SIZE_FORMAT, "Active pages:", SIZE_ARGS(active));
cli_msg(-1018, "%-17s " SIZE_FORMAT, "Kept free pages:", SIZE_ARGS(kept));
cli_msg(-1018, "%-17s " SIZE_FORMAT, "Cold free pages:", SIZE_ARGS(cold));
#endif #endif
cli_msg(0, ""); cli_msg(0, "");
} }

View File

@ -126,6 +126,7 @@ long page_size = 0;
static struct empty_pages *empty_pages = NULL; static struct empty_pages *empty_pages = NULL;
_Atomic int pages_kept_cold = 0; _Atomic int pages_kept_cold = 0;
_Atomic int pages_kept_cold_index = 0; _Atomic int pages_kept_cold_index = 0;
_Atomic int pages_total = 0;
static struct free_page * _Atomic page_stack = NULL; static struct free_page * _Atomic page_stack = NULL;
static _Thread_local struct free_page * local_page_stack = NULL; static _Thread_local struct free_page * local_page_stack = NULL;
@ -155,6 +156,7 @@ long page_size = 0;
if (ptr == MAP_FAILED) if (ptr == MAP_FAILED)
die("mmap(%ld) failed: %m", (s64) page_size); die("mmap(%ld) failed: %m", (s64) page_size);
atomic_fetch_add_explicit(&pages_total, ALLOC_PAGES_AT_ONCE, memory_order_acq_rel);
return ptr; return ptr;
} }
@ -173,6 +175,7 @@ alloc_page(void)
/* If the system page allocator is goofy, we use posix_memalign to get aligned blocks of memory. */ /* If the system page allocator is goofy, we use posix_memalign to get aligned blocks of memory. */
if (use_fake) if (use_fake)
{ {
atomic_fetch_add_explicit(&pages_total, 1, memory_order_acq_rel);
void *ptr = NULL; void *ptr = NULL;
int err = posix_memalign(&ptr, page_size, page_size); int err = posix_memalign(&ptr, page_size, page_size);
@ -271,6 +274,7 @@ free_page(void *ptr)
/* If the system page allocator is goofy, we just free the block and care no more. */ /* If the system page allocator is goofy, we just free the block and care no more. */
if (use_fake) if (use_fake)
{ {
atomic_fetch_sub_explicit(&pages_total, 1, memory_order_acq_rel);
free(ptr); free(ptr);
return; return;
} }
@ -452,6 +456,7 @@ page_dump(struct dump_request *dreq)
RDUMP(" %p\n", ep->pages[i]); RDUMP(" %p\n", ep->pages[i]);
} }
UNLOCK_DOMAIN(resource, empty_pages_domain); UNLOCK_DOMAIN(resource, empty_pages_domain);
RDUMP("This request: %p\n", dreq);
#endif #endif
} }

View File

@ -373,7 +373,7 @@ void
dump_to_file_run(struct dump_request *dr, const char *file, const char *what, void (*dump)(struct dump_request *)) dump_to_file_run(struct dump_request *dr, const char *file, const char *what, void (*dump)(struct dump_request *))
{ {
struct dump_request_file *req = SKIP_BACK(struct dump_request_file, dr, dr); struct dump_request_file *req = SKIP_BACK(struct dump_request_file, dr, dr);
req->fd = open(file, O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR); req->fd = open(file, O_CREAT | O_WRONLY | O_EXCL, S_IRUSR);
if (req->fd < 0) if (req->fd < 0)
{ {