]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: debug/memstats: permit to pass the size to free()
authorWilly Tarreau <w@1wt.eu>
Tue, 9 Aug 2022 07:08:18 +0000 (09:08 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 9 Aug 2022 07:11:27 +0000 (09:11 +0200)
commitdb3716b8db98c45fcf24fd4a10d326c9a3b3e9c1
tree22a6d1af8e7618db72ce5bf05144d260c1705d82
parent4a426e2082eb5620603e1a0a43afff5687a8cdb9
MINOR: debug/memstats: permit to pass the size to free()

Right now the free() call is not intercepted since all this is done
using macros and that would break a lot of stuff. Instead a __free()
macro was provided but never used. In addition it used to only report
a zero size, which is not very convenient.

With this patch comes a better solution. Instead it provides a new
will_free() macro that can be prepended before a call to free(). It
only keeps the counters up to date, and also supports being passed a
size. The pool_free_area() command now uses it, which finally allows
the stats to look correct:

  pool-os.h:38   MALLOC  size:   5802127832  calls:   3868044  size/call:   1500
  pool-os.h:47     FREE  size:   5800041576  calls:   3867444  size/call:   1499

The few other places directly calling free() could now be instrumented to
use this and to pass the correct sizeof() when known.
include/haproxy/bug.h
include/haproxy/pool-os.h