DEBUG: pollers: add name hint for large memory areas used by pollers

Thanks to ("MINOR: tools: add vma_set_name() helper"), set a name hint
for large memory areas allocated by pollers upon init so that they can
be easily indentified in /proc/<pid>/maps.

For now, only linux-compatible pollers are considered since vma_set_name()
requires a recent linux kernel (>= 5.17).

Depending on malloc() implementation, such memory areas will normally be
merged on the heap under MMAP_THRESHOLD (128 kB by default) and will
have a dedicated memory area once the threshold is exceeded. As such, when
large enough, they will appear like this in /proc/<pid>/maps:

7ec6b2d40000-7ec6b2d61000 rw-p 00000000 00:00 0                          [anon:ev_poll:fd_evts_wr]
7ec6b2d61000-7ec6b2d82000 rw-p 00000000 00:00 0                          [anon:ev_poll:fd_evts_rd]
This commit is contained in:
Aurelien DARRAGON 2024-05-21 10:21:24 +02:00
parent 6c5869f846
commit abb8412d20
3 changed files with 11 additions and 0 deletions

View File

@ -275,6 +275,8 @@ static int init_epoll_per_thread()
epoll_events = calloc(1, sizeof(struct epoll_event) * global.tune.maxpollevents);
if (epoll_events == NULL)
goto fail_alloc;
vma_set_name(epoll_events, sizeof(struct epoll_event) * global.tune.maxpollevents,
"ev_epoll", "epoll_events");
if (MAX_THREADS > 1 && tid) {
epoll_fd[tid] = epoll_create(global.maxsock + 1);

View File

@ -25,6 +25,7 @@
#include <haproxy/signal.h>
#include <haproxy/task.h>
#include <haproxy/ticks.h>
#include <haproxy/tools.h>
#ifndef POLLRDHUP
@ -249,6 +250,7 @@ static int init_poll_per_thread()
poll_events = calloc(1, sizeof(struct pollfd) * global.maxsock);
if (poll_events == NULL)
return 0;
vma_set_name(poll_events, sizeof(struct pollfd) * global.maxsock, "ev_poll", "poll_events");
return 1;
}
@ -279,8 +281,10 @@ static int _do_init(struct poller *p)
if ((fd_evts[DIR_RD] = calloc(1, fd_evts_bytes)) == NULL)
goto fail_srevt;
vma_set_name(fd_evts[DIR_RD], fd_evts_bytes, "ev_poll", "fd_evts_rd");
if ((fd_evts[DIR_WR] = calloc(1, fd_evts_bytes)) == NULL)
goto fail_swevt;
vma_set_name(fd_evts[DIR_WR], fd_evts_bytes, "ev_poll", "fd_evts_wr");
hap_register_per_thread_init(init_poll_per_thread);
hap_register_per_thread_deinit(deinit_poll_per_thread);

View File

@ -21,6 +21,7 @@
#include <haproxy/global.h>
#include <haproxy/task.h>
#include <haproxy/ticks.h>
#include <haproxy/tools.h>
/* private data */
@ -223,9 +224,11 @@ static int init_select_per_thread()
tmp_evts[DIR_RD] = calloc(1, fd_set_bytes);
if (tmp_evts[DIR_RD] == NULL)
goto fail;
vma_set_name(tmp_evts[DIR_RD], fd_set_bytes, "ev_select", "tmp_evts_rd");
tmp_evts[DIR_WR] = calloc(1, fd_set_bytes);
if (tmp_evts[DIR_WR] == NULL)
goto fail;
vma_set_name(tmp_evts[DIR_WR], fd_set_bytes, "ev_select", "tmp_evts_wr");
return 1;
fail:
free(tmp_evts[DIR_RD]);
@ -263,8 +266,10 @@ static int _do_init(struct poller *p)
if ((fd_evts[DIR_RD] = calloc(1, fd_set_bytes)) == NULL)
goto fail_srevt;
vma_set_name(fd_evts[DIR_RD], fd_set_bytes, "ev_select", "fd_evts_rd");
if ((fd_evts[DIR_WR] = calloc(1, fd_set_bytes)) == NULL)
goto fail_swevt;
vma_set_name(fd_evts[DIR_WR], fd_set_bytes, "ev_select", "fd_evts_wr");
hap_register_per_thread_init(init_select_per_thread);
hap_register_per_thread_deinit(deinit_select_per_thread);