]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
DEBUG: sink: add name hint for memory area used by memory-backed sinks
authorAurelien DARRAGON <adarragon@haproxy.com>
Mon, 20 May 2024 13:16:10 +0000 (15:16 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Tue, 21 May 2024 15:55:09 +0000 (17:55 +0200)
Thanks to ("MINOR: tools: add vma_set_name() helper"), set a name hint
for user created memory-backed sinks (ring sections without backing-file)
so that they can be easily indentified in /proc/<pid>/maps.

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:

7b8e8ac00000-7b8e8bf13000 rw-p 00000000 00:00 0                          [anon:ring:myring]

src/sink.c

index 279a0eb95817d60fe4a8a45576f76d1655a19f8e..1a9165e7c934bb882eca8f8c5aa87961dd28d118 100644 (file)
@@ -829,6 +829,12 @@ static int sink_finalize(struct sink *sink)
                        ha_alert("error when trying to initialize sink buffer forwarding.\n");
                        err_code |= ERR_ALERT | ERR_FATAL;
                }
+               if (!sink->store) {
+                       /* virtual memory backed sink */
+                       vma_set_name(ring_allocated_area(sink->ctx.ring),
+                                    ring_allocated_size(sink->ctx.ring),
+                                    "ring", sink->name);
+               }
        }
        return err_code;
 }