]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
DEBUG: pollers: add name hint for large memory areas used by pollers
authorAurelien DARRAGON <adarragon@haproxy.com>
Tue, 21 May 2024 08:21:24 +0000 (10:21 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Tue, 21 May 2024 15:55:14 +0000 (17:55 +0200)
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]

src/ev_epoll.c
src/ev_poll.c
src/ev_select.c

index c42cf2ea5d35f4b8689089f4318bb9cef1d82bda..2a41b73730c9f795021cc7f6db2c48a1af3f2b03 100644 (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);
index e98630c7180797ba6e4a9aa83acc3a214a5efbab..bc70713c5deb94cd320dbfa5a74224421eafb9db 100644 (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);
index eadd5888abca57fcb8e67e14fc62ab6ea387225b..e41c30e17bdd621c33d29a1830af78f7642edf79 100644 (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);