MINOR: pools: call malloc_trim() under thread isolation
authorWilly Tarreau <w@1wt.eu>
Thu, 10 Jun 2021 06:40:16 +0000 (08:40 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 17 Jun 2021 14:09:47 +0000 (16:09 +0200)
commitcbd13f8b3ea1dd59d98e363c2430a63feca5123d
treea4345a75a781cf5e3d041717f523f7e7d822d962
parent027eb8b83de984a8c5248a074664826956aa7495
MINOR: pools: call malloc_trim() under thread isolation

pool_gc() was adjusted to run under thread isolation by commit c0e2ff202
("MEDIUM: memory: make pool_gc() run under thread isolation") so that the
underlying malloc() and free() don't compete between threads during these
potentially aggressive moments (especially when mmap/munmap are involved).

Commit 88366c292 ("MEDIUM: pools: call malloc_trim() from pool_gc()")
later added a call to malloc_trim() but made it outside of the thread
isolation, which is contrary to the principle explained above. Also it
missed it in the locked version, meaning that those without a lockless
implementation cannot benefit from trimming.

This patch fixes that by calling it before thread_release() in both
places.

(cherry picked from commit 26ed183556f3df9e9bde6f6d47143aa4a18ae463)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit 46b515ca55b113827ed3e52937cf7ad154d2f6c0)
Signed-off-by: Willy Tarreau <w@1wt.eu>
src/pool.c