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]
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);
#include <haproxy/signal.h>
#include <haproxy/task.h>
#include <haproxy/ticks.h>
+#include <haproxy/tools.h>
#ifndef POLLRDHUP
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;
}
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);
#include <haproxy/global.h>
#include <haproxy/task.h>
#include <haproxy/ticks.h>
+#include <haproxy/tools.h>
/* private data */
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]);
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);