Coverage Report

Created: 2026-01-03 06:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/haproxy/include/haproxy/pool.h
Line
Count
Source
1
/*
2
 * include/haproxy/pool.h
3
 * Memory management definitions..
4
 *
5
 * Copyright (C) 2000-2020 Willy Tarreau - w@1wt.eu
6
 *
7
 * This library is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU Lesser General Public
9
 * License as published by the Free Software Foundation, version 2.1
10
 * exclusively.
11
 *
12
 * This library is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 * Lesser General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with this library; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
20
 */
21
22
#ifndef _HAPROXY_POOL_H
23
#define _HAPROXY_POOL_H
24
25
#include <string.h>
26
27
#include <haproxy/api.h>
28
#include <haproxy/freq_ctr.h>
29
#include <haproxy/list.h>
30
#include <haproxy/pool-t.h>
31
#include <haproxy/thread.h>
32
33
/* This creates a pool_reg registers a call to create_pool_callback(ptr) with it.
34
 * Do not use this one, use REGISTER_POOL() instead.
35
 */
36
#define __REGISTER_POOL(_line, _ptr, _name, _size, _type_align, _align)    \
37
  static struct pool_registration __pool_reg_##_line = { \
38
    .name = _name,               \
39
    .file = __FILE__,            \
40
    .line = __LINE__,            \
41
    .size = _size,               \
42
    .flags = MEM_F_STATREG,            \
43
    .type_align = _type_align,           \
44
    .align = _align,             \
45
  };                   \
46
  INITCALL3(STG_POOL, create_pool_callback, (_ptr), (_name), &__pool_reg_##_line);
47
48
/* intermediary level for line number resolution, do not use this one, use
49
 * REGISTER_POOL() instead.
50
 */
51
#define _REGISTER_POOL(line, ptr, name, size, align, type_align)  \
52
  __REGISTER_POOL(line, ptr, name, size, align, type_align)
53
54
/* This registers a call to create_pool_callback(ptr) with these args */
55
#define REGISTER_POOL(ptr, name, size)  \
56
  _REGISTER_POOL(__LINE__, ptr, name, size, 0, 0)
57
58
/* This macro declares a pool head <ptr> and registers its creation */
59
#define DECLARE_POOL(ptr, name, size)   \
60
  struct pool_head *(ptr) __read_mostly = NULL; \
61
  _REGISTER_POOL(__LINE__, &ptr, name, size, 0, 0)
62
63
/* This macro declares a static pool head <ptr> and registers its creation */
64
#define DECLARE_STATIC_POOL(ptr, name, size) \
65
  static struct pool_head *(ptr) __read_mostly; \
66
  _REGISTER_POOL(__LINE__, &ptr, name, size, 0, 0)
67
68
/*** below are the aligned pool macros, taking one extra arg for alignment ***/
69
70
/* This registers a call to create_pool_callback(ptr) with these args */
71
#define REGISTER_ALIGNED_POOL(ptr, name, size, align) \
72
  _REGISTER_POOL(__LINE__, ptr, name, size, 0, align)
73
74
/* This macro declares an aligned pool head <ptr> and registers its creation */
75
#define DECLARE_ALIGNED_POOL(ptr, name, size, align)        \
76
  struct pool_head *(ptr) __read_mostly = NULL; \
77
  _REGISTER_POOL(__LINE__, &ptr, name, size, 0, align)
78
79
/* This macro declares a static aligned pool head <ptr> and registers its creation */
80
#define DECLARE_STATIC_ALIGNED_POOL(ptr, name, size, align) \
81
  static struct pool_head *(ptr) __read_mostly; \
82
  _REGISTER_POOL(__LINE__, &ptr, name, size, 0, align)
83
84
/*** below are the typed pool macros, taking a type and an extra size ***/
85
86
/* This is only used by REGISTER_TYPED_POOL below */
87
#define _REGISTER_TYPED_POOL(ptr, name, type, extra, align, ...)    \
88
  _REGISTER_POOL(__LINE__, ptr, name, sizeof(type) + extra, __alignof__(type), align)
89
90
/* This registers a call to create_pool_callback(ptr) with these args.
91
 * It supports two optional args:
92
 *  - extra: the extra size to be allocated at the end of the type. Def: 0.
93
 *  - align: the desired alignment on the type. Def: 0 = same as type.
94
 */
95
#define REGISTER_TYPED_POOL(ptr, name, type, args...) \
96
  _REGISTER_TYPED_POOL(ptr, name, type, ##args, 0, 0)
97
98
/* This macro declares an aligned pool head <ptr> and registers its creation */
99
#define DECLARE_TYPED_POOL(ptr, name, type, args...)        \
100
  struct pool_head *(ptr) __read_mostly = NULL; \
101
  _REGISTER_TYPED_POOL(&ptr, name, type, ##args, 0, 0)
102
103
/* This macro declares a static aligned pool head <ptr> and registers its creation */
104
#define DECLARE_STATIC_TYPED_POOL(ptr, name, type, args...)   \
105
  static struct pool_head *(ptr) __read_mostly; \
106
  _REGISTER_TYPED_POOL(&ptr, name, type, ##args, 0, 0)
107
108
/* By default, free objects are linked by a pointer stored at the beginning of
109
 * the memory area. When DEBUG_MEMORY_POOLS is set, the allocated area is
110
 * inflated by the size of a pointer so that the link is placed at the end
111
 * of the objects. Hence free objects in pools remain intact. In addition,
112
 * this location is used to keep a pointer to the pool the object was
113
 * allocated from, and verify it's freed into the appropriate one.
114
 */
115
0
# define POOL_EXTRA_MARK (sizeof(void *))
116
# define POOL_DEBUG_SET_MARK(pool, item)        \
117
0
  do {               \
118
0
    typeof(pool) __p = (pool);        \
119
0
    typeof(item) __i = (item);        \
120
0
    if (likely(!(pool_debugging & POOL_DBG_TAG)))   \
121
0
      break;           \
122
0
    *(typeof(pool)*)(((char *)__i) + __p->size) = __p;  \
123
0
  } while (0)
124
125
# define POOL_DEBUG_RESET_MARK(pool, item)        \
126
0
  do {               \
127
0
    typeof(pool) __p = (pool);        \
128
0
    typeof(item) __i = (item);        \
129
0
    if (likely(!(pool_debugging & POOL_DBG_TAG)))   \
130
0
      break;           \
131
0
    *(typeof(pool)*)(((char *)__i) + __p->size) = __builtin_return_address(0); \
132
0
  } while (0)
133
134
# define POOL_DEBUG_CHECK_MARK(pool, item, caller)        \
135
0
  do {               \
136
0
    typeof(pool) __p = (pool);        \
137
0
    typeof(item) __i = (item);        \
138
0
    if (likely(!(pool_debugging & POOL_DBG_TAG)))   \
139
0
      break;           \
140
0
    if (*(typeof(pool)*)(((char *)__i) + __p->size) != __p) { \
141
0
      pool_inspect_item("tag mismatch on free()", __p, __i, caller, -1); \
142
0
      ABORT_NOW();         \
143
0
    }             \
144
0
  } while (0)
145
146
/* It's possible to trace callers of pool_free() by placing their pointer
147
 * after the end of the area and the optional mark above, which means the
148
 * end of the allocated array.
149
 */
150
0
# define POOL_EXTRA_CALLER (sizeof(void *))
151
# define POOL_DEBUG_TRACE_CALLER(pool, item, caller)      \
152
0
  do {               \
153
0
    typeof(pool) __p = (pool);        \
154
0
    typeof(item) __i = (item);        \
155
0
    typeof(caller) __c = (caller);        \
156
0
    if (likely(!(pool_debugging & POOL_DBG_CALLER)))  \
157
0
      break;           \
158
0
    *(typeof(caller)*)(((char *)__i) + __p->alloc_sz - sizeof(void*)) = __c; \
159
0
  } while (0)
160
161
/* poison each newly allocated area with this byte if >= 0 */
162
extern int mem_poison_byte;
163
164
/* trim() in progress */
165
extern int pool_trim_in_progress;
166
167
/* set of POOL_DBG_* flags */
168
extern uint pool_debugging;
169
170
/* pools are listed here */
171
extern struct list pools;
172
173
int malloc_trim(size_t pad);
174
void trim_all_pools(void);
175
176
void *pool_get_from_os_noinc(struct pool_head *pool);
177
void pool_put_to_os_nodec(struct pool_head *pool, void *ptr);
178
void *pool_alloc_nocache(struct pool_head *pool, const void *caller);
179
void pool_free_nocache(struct pool_head *pool, void *ptr);
180
int pool_parse_debugging(const char *str, char **err);
181
int pool_total_failures(void);
182
unsigned long long pool_total_allocated(void);
183
unsigned long long pool_total_used(void);
184
void pool_flush(struct pool_head *pool);
185
void pool_gc(struct pool_head *pool_ctx);
186
struct pool_head *create_pool_with_loc(const char *name, unsigned int size, unsigned int align,
187
                                       unsigned int flags, const char *file, unsigned int line);
188
struct pool_head *create_pool_from_reg(const char *name, struct pool_registration *reg);
189
void create_pool_callback(struct pool_head **ptr, char *name, struct pool_registration *reg);
190
void *pool_destroy(struct pool_head *pool);
191
void pool_destroy_all(void);
192
void *__pool_alloc(struct pool_head *pool, unsigned int flags);
193
void __pool_free(struct pool_head *pool, void *ptr);
194
void pool_inspect_item(const char *msg, struct pool_head *pool, const void *item, const void *caller, ssize_t ofs);
195
196
#define create_pool(name, size, flags) \
197
0
  create_pool_with_loc(name, size, 0, flags, __FILE__, __LINE__)
198
199
#define create_aligned_pool(name, size, align, flags)     \
200
0
  create_pool_with_loc(name, size, align, flags, __FILE__, __LINE__)
201
202
203
/****************** Thread-local cache management ******************/
204
205
extern THREAD_LOCAL size_t pool_cache_bytes;   /* total cache size */
206
extern THREAD_LOCAL size_t pool_cache_count;   /* #cache objects   */
207
208
void pool_evict_from_local_cache(struct pool_head *pool, int full);
209
void pool_evict_from_local_caches(void);
210
void pool_put_to_cache(struct pool_head *pool, void *ptr, const void *caller);
211
void pool_fill_pattern(struct pool_cache_head *pch, struct pool_cache_item *item, uint size);
212
void pool_check_pattern(struct pool_cache_head *pch, struct pool_head *pool, struct pool_cache_item *item, const void *caller);
213
void pool_refill_local_from_shared(struct pool_head *pool, struct pool_cache_head *pch);
214
void pool_put_to_shared_cache(struct pool_head *pool, struct pool_item *item);
215
216
/* returns the total number of allocated entries for a pool across all buckets */
217
static inline uint pool_allocated(const struct pool_head *pool)
218
0
{
219
0
  int bucket;
220
0
  uint ret;
221
222
0
  for (bucket = ret = 0; bucket < CONFIG_HAP_POOL_BUCKETS; bucket++)
223
0
    ret += HA_ATOMIC_LOAD(&pool->buckets[bucket].allocated);
224
0
  return ret;
225
0
}
Unexecuted instantiation: cfgparse.c:pool_allocated
Unexecuted instantiation: chunk.c:pool_allocated
Unexecuted instantiation: cli.c:pool_allocated
Unexecuted instantiation: clock.c:pool_allocated
Unexecuted instantiation: connection.c:pool_allocated
Unexecuted instantiation: debug.c:pool_allocated
Unexecuted instantiation: dynbuf.c:pool_allocated
Unexecuted instantiation: errors.c:pool_allocated
Unexecuted instantiation: fd.c:pool_allocated
Unexecuted instantiation: filters.c:pool_allocated
Unexecuted instantiation: flt_http_comp.c:pool_allocated
Unexecuted instantiation: freq_ctr.c:pool_allocated
Unexecuted instantiation: frontend.c:pool_allocated
Unexecuted instantiation: haproxy.c:pool_allocated
Unexecuted instantiation: http.c:pool_allocated
Unexecuted instantiation: http_ana.c:pool_allocated
Unexecuted instantiation: http_ext.c:pool_allocated
Unexecuted instantiation: http_htx.c:pool_allocated
Unexecuted instantiation: http_rules.c:pool_allocated
Unexecuted instantiation: htx.c:pool_allocated
Unexecuted instantiation: lb_chash.c:pool_allocated
Unexecuted instantiation: lb_fas.c:pool_allocated
Unexecuted instantiation: lb_fwlc.c:pool_allocated
Unexecuted instantiation: lb_fwrr.c:pool_allocated
Unexecuted instantiation: lb_map.c:pool_allocated
Unexecuted instantiation: limits.c:pool_allocated
Unexecuted instantiation: listener.c:pool_allocated
Unexecuted instantiation: log.c:pool_allocated
Unexecuted instantiation: mailers.c:pool_allocated
Unexecuted instantiation: mworker.c:pool_allocated
Unexecuted instantiation: peers.c:pool_allocated
Unexecuted instantiation: pool.c:pool_allocated
Unexecuted instantiation: proto_rhttp.c:pool_allocated
Unexecuted instantiation: proto_sockpair.c:pool_allocated
Unexecuted instantiation: protocol.c:pool_allocated
Unexecuted instantiation: proxy.c:pool_allocated
Unexecuted instantiation: queue.c:pool_allocated
Unexecuted instantiation: regex.c:pool_allocated
Unexecuted instantiation: resolvers.c:pool_allocated
Unexecuted instantiation: ring.c:pool_allocated
Unexecuted instantiation: sample.c:pool_allocated
Unexecuted instantiation: server.c:pool_allocated
Unexecuted instantiation: session.c:pool_allocated
Unexecuted instantiation: signal.c:pool_allocated
Unexecuted instantiation: sink.c:pool_allocated
Unexecuted instantiation: sock.c:pool_allocated
Unexecuted instantiation: sock_inet.c:pool_allocated
Unexecuted instantiation: stats-html.c:pool_allocated
Unexecuted instantiation: stats.c:pool_allocated
Unexecuted instantiation: stconn.c:pool_allocated
Unexecuted instantiation: stick_table.c:pool_allocated
Unexecuted instantiation: stream.c:pool_allocated
Unexecuted instantiation: systemd.c:pool_allocated
Unexecuted instantiation: task.c:pool_allocated
Unexecuted instantiation: tcp_rules.c:pool_allocated
Unexecuted instantiation: tcpcheck.c:pool_allocated
Unexecuted instantiation: thread.c:pool_allocated
Unexecuted instantiation: tools.c:pool_allocated
Unexecuted instantiation: trace.c:pool_allocated
Unexecuted instantiation: vars.c:pool_allocated
Unexecuted instantiation: acl.c:pool_allocated
Unexecuted instantiation: action.c:pool_allocated
Unexecuted instantiation: activity.c:pool_allocated
Unexecuted instantiation: applet.c:pool_allocated
Unexecuted instantiation: arg.c:pool_allocated
Unexecuted instantiation: backend.c:pool_allocated
Unexecuted instantiation: cache.c:pool_allocated
Unexecuted instantiation: cfgcond.c:pool_allocated
Unexecuted instantiation: cfgparse-global.c:pool_allocated
Unexecuted instantiation: cfgparse-listen.c:pool_allocated
Unexecuted instantiation: channel.c:pool_allocated
Unexecuted instantiation: check.c:pool_allocated
Unexecuted instantiation: compression.c:pool_allocated
Unexecuted instantiation: counters.c:pool_allocated
Unexecuted instantiation: dgram.c:pool_allocated
Unexecuted instantiation: dns.c:pool_allocated
Unexecuted instantiation: dns_ring.c:pool_allocated
Unexecuted instantiation: event_hdl.c:pool_allocated
Unexecuted instantiation: extcheck.c:pool_allocated
Unexecuted instantiation: fcgi-app.c:pool_allocated
Unexecuted instantiation: fix.c:pool_allocated
Unexecuted instantiation: guid.c:pool_allocated
Unexecuted instantiation: h1.c:pool_allocated
Unexecuted instantiation: http_fetch.c:pool_allocated
Unexecuted instantiation: mqtt.c:pool_allocated
Unexecuted instantiation: mux_spop.c:pool_allocated
Unexecuted instantiation: pattern.c:pool_allocated
Unexecuted instantiation: payload.c:pool_allocated
Unexecuted instantiation: pipe.c:pool_allocated
Unexecuted instantiation: proto_tcp.c:pool_allocated
Unexecuted instantiation: shctx.c:pool_allocated
Unexecuted instantiation: stats-file.c:pool_allocated
Unexecuted instantiation: stats-json.c:pool_allocated
Unexecuted instantiation: stats-proxy.c:pool_allocated
Unexecuted instantiation: flt_spoe.c:pool_allocated
Unexecuted instantiation: h1_htx.c:pool_allocated
226
227
/* returns the total number of used entries for a pool across all buckets */
228
static inline uint pool_used(const struct pool_head *pool)
229
0
{
230
0
  int bucket;
231
0
  uint ret;
232
233
0
  for (bucket = ret = 0; bucket < CONFIG_HAP_POOL_BUCKETS; bucket++)
234
0
    ret += HA_ATOMIC_LOAD(&pool->buckets[bucket].used);
235
0
  return ret;
236
0
}
Unexecuted instantiation: cfgparse.c:pool_used
Unexecuted instantiation: chunk.c:pool_used
Unexecuted instantiation: cli.c:pool_used
Unexecuted instantiation: clock.c:pool_used
Unexecuted instantiation: connection.c:pool_used
Unexecuted instantiation: debug.c:pool_used
Unexecuted instantiation: dynbuf.c:pool_used
Unexecuted instantiation: errors.c:pool_used
Unexecuted instantiation: fd.c:pool_used
Unexecuted instantiation: filters.c:pool_used
Unexecuted instantiation: flt_http_comp.c:pool_used
Unexecuted instantiation: freq_ctr.c:pool_used
Unexecuted instantiation: frontend.c:pool_used
Unexecuted instantiation: haproxy.c:pool_used
Unexecuted instantiation: http.c:pool_used
Unexecuted instantiation: http_ana.c:pool_used
Unexecuted instantiation: http_ext.c:pool_used
Unexecuted instantiation: http_htx.c:pool_used
Unexecuted instantiation: http_rules.c:pool_used
Unexecuted instantiation: htx.c:pool_used
Unexecuted instantiation: lb_chash.c:pool_used
Unexecuted instantiation: lb_fas.c:pool_used
Unexecuted instantiation: lb_fwlc.c:pool_used
Unexecuted instantiation: lb_fwrr.c:pool_used
Unexecuted instantiation: lb_map.c:pool_used
Unexecuted instantiation: limits.c:pool_used
Unexecuted instantiation: listener.c:pool_used
Unexecuted instantiation: log.c:pool_used
Unexecuted instantiation: mailers.c:pool_used
Unexecuted instantiation: mworker.c:pool_used
Unexecuted instantiation: peers.c:pool_used
Unexecuted instantiation: pool.c:pool_used
Unexecuted instantiation: proto_rhttp.c:pool_used
Unexecuted instantiation: proto_sockpair.c:pool_used
Unexecuted instantiation: protocol.c:pool_used
Unexecuted instantiation: proxy.c:pool_used
Unexecuted instantiation: queue.c:pool_used
Unexecuted instantiation: regex.c:pool_used
Unexecuted instantiation: resolvers.c:pool_used
Unexecuted instantiation: ring.c:pool_used
Unexecuted instantiation: sample.c:pool_used
Unexecuted instantiation: server.c:pool_used
Unexecuted instantiation: session.c:pool_used
Unexecuted instantiation: signal.c:pool_used
Unexecuted instantiation: sink.c:pool_used
Unexecuted instantiation: sock.c:pool_used
Unexecuted instantiation: sock_inet.c:pool_used
Unexecuted instantiation: stats-html.c:pool_used
Unexecuted instantiation: stats.c:pool_used
Unexecuted instantiation: stconn.c:pool_used
Unexecuted instantiation: stick_table.c:pool_used
Unexecuted instantiation: stream.c:pool_used
Unexecuted instantiation: systemd.c:pool_used
Unexecuted instantiation: task.c:pool_used
Unexecuted instantiation: tcp_rules.c:pool_used
Unexecuted instantiation: tcpcheck.c:pool_used
Unexecuted instantiation: thread.c:pool_used
Unexecuted instantiation: tools.c:pool_used
Unexecuted instantiation: trace.c:pool_used
Unexecuted instantiation: vars.c:pool_used
Unexecuted instantiation: acl.c:pool_used
Unexecuted instantiation: action.c:pool_used
Unexecuted instantiation: activity.c:pool_used
Unexecuted instantiation: applet.c:pool_used
Unexecuted instantiation: arg.c:pool_used
Unexecuted instantiation: backend.c:pool_used
Unexecuted instantiation: cache.c:pool_used
Unexecuted instantiation: cfgcond.c:pool_used
Unexecuted instantiation: cfgparse-global.c:pool_used
Unexecuted instantiation: cfgparse-listen.c:pool_used
Unexecuted instantiation: channel.c:pool_used
Unexecuted instantiation: check.c:pool_used
Unexecuted instantiation: compression.c:pool_used
Unexecuted instantiation: counters.c:pool_used
Unexecuted instantiation: dgram.c:pool_used
Unexecuted instantiation: dns.c:pool_used
Unexecuted instantiation: dns_ring.c:pool_used
Unexecuted instantiation: event_hdl.c:pool_used
Unexecuted instantiation: extcheck.c:pool_used
Unexecuted instantiation: fcgi-app.c:pool_used
Unexecuted instantiation: fix.c:pool_used
Unexecuted instantiation: guid.c:pool_used
Unexecuted instantiation: h1.c:pool_used
Unexecuted instantiation: http_fetch.c:pool_used
Unexecuted instantiation: mqtt.c:pool_used
Unexecuted instantiation: mux_spop.c:pool_used
Unexecuted instantiation: pattern.c:pool_used
Unexecuted instantiation: payload.c:pool_used
Unexecuted instantiation: pipe.c:pool_used
Unexecuted instantiation: proto_tcp.c:pool_used
Unexecuted instantiation: shctx.c:pool_used
Unexecuted instantiation: stats-file.c:pool_used
Unexecuted instantiation: stats-json.c:pool_used
Unexecuted instantiation: stats-proxy.c:pool_used
Unexecuted instantiation: flt_spoe.c:pool_used
Unexecuted instantiation: h1_htx.c:pool_used
237
238
/* returns the raw total number needed entries across all buckets. It must
239
 * be passed to swrate_avg() to get something usable.
240
 */
241
static inline uint pool_needed_avg(const struct pool_head *pool)
242
0
{
243
0
  int bucket;
244
0
  uint ret;
245
246
0
  for (bucket = ret = 0; bucket < CONFIG_HAP_POOL_BUCKETS; bucket++)
247
0
    ret += HA_ATOMIC_LOAD(&pool->buckets[bucket].needed_avg);
248
0
  return ret;
249
0
}
Unexecuted instantiation: cfgparse.c:pool_needed_avg
Unexecuted instantiation: chunk.c:pool_needed_avg
Unexecuted instantiation: cli.c:pool_needed_avg
Unexecuted instantiation: clock.c:pool_needed_avg
Unexecuted instantiation: connection.c:pool_needed_avg
Unexecuted instantiation: debug.c:pool_needed_avg
Unexecuted instantiation: dynbuf.c:pool_needed_avg
Unexecuted instantiation: errors.c:pool_needed_avg
Unexecuted instantiation: fd.c:pool_needed_avg
Unexecuted instantiation: filters.c:pool_needed_avg
Unexecuted instantiation: flt_http_comp.c:pool_needed_avg
Unexecuted instantiation: freq_ctr.c:pool_needed_avg
Unexecuted instantiation: frontend.c:pool_needed_avg
Unexecuted instantiation: haproxy.c:pool_needed_avg
Unexecuted instantiation: http.c:pool_needed_avg
Unexecuted instantiation: http_ana.c:pool_needed_avg
Unexecuted instantiation: http_ext.c:pool_needed_avg
Unexecuted instantiation: http_htx.c:pool_needed_avg
Unexecuted instantiation: http_rules.c:pool_needed_avg
Unexecuted instantiation: htx.c:pool_needed_avg
Unexecuted instantiation: lb_chash.c:pool_needed_avg
Unexecuted instantiation: lb_fas.c:pool_needed_avg
Unexecuted instantiation: lb_fwlc.c:pool_needed_avg
Unexecuted instantiation: lb_fwrr.c:pool_needed_avg
Unexecuted instantiation: lb_map.c:pool_needed_avg
Unexecuted instantiation: limits.c:pool_needed_avg
Unexecuted instantiation: listener.c:pool_needed_avg
Unexecuted instantiation: log.c:pool_needed_avg
Unexecuted instantiation: mailers.c:pool_needed_avg
Unexecuted instantiation: mworker.c:pool_needed_avg
Unexecuted instantiation: peers.c:pool_needed_avg
Unexecuted instantiation: pool.c:pool_needed_avg
Unexecuted instantiation: proto_rhttp.c:pool_needed_avg
Unexecuted instantiation: proto_sockpair.c:pool_needed_avg
Unexecuted instantiation: protocol.c:pool_needed_avg
Unexecuted instantiation: proxy.c:pool_needed_avg
Unexecuted instantiation: queue.c:pool_needed_avg
Unexecuted instantiation: regex.c:pool_needed_avg
Unexecuted instantiation: resolvers.c:pool_needed_avg
Unexecuted instantiation: ring.c:pool_needed_avg
Unexecuted instantiation: sample.c:pool_needed_avg
Unexecuted instantiation: server.c:pool_needed_avg
Unexecuted instantiation: session.c:pool_needed_avg
Unexecuted instantiation: signal.c:pool_needed_avg
Unexecuted instantiation: sink.c:pool_needed_avg
Unexecuted instantiation: sock.c:pool_needed_avg
Unexecuted instantiation: sock_inet.c:pool_needed_avg
Unexecuted instantiation: stats-html.c:pool_needed_avg
Unexecuted instantiation: stats.c:pool_needed_avg
Unexecuted instantiation: stconn.c:pool_needed_avg
Unexecuted instantiation: stick_table.c:pool_needed_avg
Unexecuted instantiation: stream.c:pool_needed_avg
Unexecuted instantiation: systemd.c:pool_needed_avg
Unexecuted instantiation: task.c:pool_needed_avg
Unexecuted instantiation: tcp_rules.c:pool_needed_avg
Unexecuted instantiation: tcpcheck.c:pool_needed_avg
Unexecuted instantiation: thread.c:pool_needed_avg
Unexecuted instantiation: tools.c:pool_needed_avg
Unexecuted instantiation: trace.c:pool_needed_avg
Unexecuted instantiation: vars.c:pool_needed_avg
Unexecuted instantiation: acl.c:pool_needed_avg
Unexecuted instantiation: action.c:pool_needed_avg
Unexecuted instantiation: activity.c:pool_needed_avg
Unexecuted instantiation: applet.c:pool_needed_avg
Unexecuted instantiation: arg.c:pool_needed_avg
Unexecuted instantiation: backend.c:pool_needed_avg
Unexecuted instantiation: cache.c:pool_needed_avg
Unexecuted instantiation: cfgcond.c:pool_needed_avg
Unexecuted instantiation: cfgparse-global.c:pool_needed_avg
Unexecuted instantiation: cfgparse-listen.c:pool_needed_avg
Unexecuted instantiation: channel.c:pool_needed_avg
Unexecuted instantiation: check.c:pool_needed_avg
Unexecuted instantiation: compression.c:pool_needed_avg
Unexecuted instantiation: counters.c:pool_needed_avg
Unexecuted instantiation: dgram.c:pool_needed_avg
Unexecuted instantiation: dns.c:pool_needed_avg
Unexecuted instantiation: dns_ring.c:pool_needed_avg
Unexecuted instantiation: event_hdl.c:pool_needed_avg
Unexecuted instantiation: extcheck.c:pool_needed_avg
Unexecuted instantiation: fcgi-app.c:pool_needed_avg
Unexecuted instantiation: fix.c:pool_needed_avg
Unexecuted instantiation: guid.c:pool_needed_avg
Unexecuted instantiation: h1.c:pool_needed_avg
Unexecuted instantiation: http_fetch.c:pool_needed_avg
Unexecuted instantiation: mqtt.c:pool_needed_avg
Unexecuted instantiation: mux_spop.c:pool_needed_avg
Unexecuted instantiation: pattern.c:pool_needed_avg
Unexecuted instantiation: payload.c:pool_needed_avg
Unexecuted instantiation: pipe.c:pool_needed_avg
Unexecuted instantiation: proto_tcp.c:pool_needed_avg
Unexecuted instantiation: shctx.c:pool_needed_avg
Unexecuted instantiation: stats-file.c:pool_needed_avg
Unexecuted instantiation: stats-json.c:pool_needed_avg
Unexecuted instantiation: stats-proxy.c:pool_needed_avg
Unexecuted instantiation: flt_spoe.c:pool_needed_avg
Unexecuted instantiation: h1_htx.c:pool_needed_avg
250
251
/* returns the total number of failed allocations for a pool across all buckets */
252
static inline uint pool_failed(const struct pool_head *pool)
253
0
{
254
0
  int bucket;
255
0
  uint ret;
256
257
0
  for (bucket = ret = 0; bucket < CONFIG_HAP_POOL_BUCKETS; bucket++)
258
0
    ret += HA_ATOMIC_LOAD(&pool->buckets[bucket].failed);
259
0
  return ret;
260
0
}
Unexecuted instantiation: cfgparse.c:pool_failed
Unexecuted instantiation: chunk.c:pool_failed
Unexecuted instantiation: cli.c:pool_failed
Unexecuted instantiation: clock.c:pool_failed
Unexecuted instantiation: connection.c:pool_failed
Unexecuted instantiation: debug.c:pool_failed
Unexecuted instantiation: dynbuf.c:pool_failed
Unexecuted instantiation: errors.c:pool_failed
Unexecuted instantiation: fd.c:pool_failed
Unexecuted instantiation: filters.c:pool_failed
Unexecuted instantiation: flt_http_comp.c:pool_failed
Unexecuted instantiation: freq_ctr.c:pool_failed
Unexecuted instantiation: frontend.c:pool_failed
Unexecuted instantiation: haproxy.c:pool_failed
Unexecuted instantiation: http.c:pool_failed
Unexecuted instantiation: http_ana.c:pool_failed
Unexecuted instantiation: http_ext.c:pool_failed
Unexecuted instantiation: http_htx.c:pool_failed
Unexecuted instantiation: http_rules.c:pool_failed
Unexecuted instantiation: htx.c:pool_failed
Unexecuted instantiation: lb_chash.c:pool_failed
Unexecuted instantiation: lb_fas.c:pool_failed
Unexecuted instantiation: lb_fwlc.c:pool_failed
Unexecuted instantiation: lb_fwrr.c:pool_failed
Unexecuted instantiation: lb_map.c:pool_failed
Unexecuted instantiation: limits.c:pool_failed
Unexecuted instantiation: listener.c:pool_failed
Unexecuted instantiation: log.c:pool_failed
Unexecuted instantiation: mailers.c:pool_failed
Unexecuted instantiation: mworker.c:pool_failed
Unexecuted instantiation: peers.c:pool_failed
Unexecuted instantiation: pool.c:pool_failed
Unexecuted instantiation: proto_rhttp.c:pool_failed
Unexecuted instantiation: proto_sockpair.c:pool_failed
Unexecuted instantiation: protocol.c:pool_failed
Unexecuted instantiation: proxy.c:pool_failed
Unexecuted instantiation: queue.c:pool_failed
Unexecuted instantiation: regex.c:pool_failed
Unexecuted instantiation: resolvers.c:pool_failed
Unexecuted instantiation: ring.c:pool_failed
Unexecuted instantiation: sample.c:pool_failed
Unexecuted instantiation: server.c:pool_failed
Unexecuted instantiation: session.c:pool_failed
Unexecuted instantiation: signal.c:pool_failed
Unexecuted instantiation: sink.c:pool_failed
Unexecuted instantiation: sock.c:pool_failed
Unexecuted instantiation: sock_inet.c:pool_failed
Unexecuted instantiation: stats-html.c:pool_failed
Unexecuted instantiation: stats.c:pool_failed
Unexecuted instantiation: stconn.c:pool_failed
Unexecuted instantiation: stick_table.c:pool_failed
Unexecuted instantiation: stream.c:pool_failed
Unexecuted instantiation: systemd.c:pool_failed
Unexecuted instantiation: task.c:pool_failed
Unexecuted instantiation: tcp_rules.c:pool_failed
Unexecuted instantiation: tcpcheck.c:pool_failed
Unexecuted instantiation: thread.c:pool_failed
Unexecuted instantiation: tools.c:pool_failed
Unexecuted instantiation: trace.c:pool_failed
Unexecuted instantiation: vars.c:pool_failed
Unexecuted instantiation: acl.c:pool_failed
Unexecuted instantiation: action.c:pool_failed
Unexecuted instantiation: activity.c:pool_failed
Unexecuted instantiation: applet.c:pool_failed
Unexecuted instantiation: arg.c:pool_failed
Unexecuted instantiation: backend.c:pool_failed
Unexecuted instantiation: cache.c:pool_failed
Unexecuted instantiation: cfgcond.c:pool_failed
Unexecuted instantiation: cfgparse-global.c:pool_failed
Unexecuted instantiation: cfgparse-listen.c:pool_failed
Unexecuted instantiation: channel.c:pool_failed
Unexecuted instantiation: check.c:pool_failed
Unexecuted instantiation: compression.c:pool_failed
Unexecuted instantiation: counters.c:pool_failed
Unexecuted instantiation: dgram.c:pool_failed
Unexecuted instantiation: dns.c:pool_failed
Unexecuted instantiation: dns_ring.c:pool_failed
Unexecuted instantiation: event_hdl.c:pool_failed
Unexecuted instantiation: extcheck.c:pool_failed
Unexecuted instantiation: fcgi-app.c:pool_failed
Unexecuted instantiation: fix.c:pool_failed
Unexecuted instantiation: guid.c:pool_failed
Unexecuted instantiation: h1.c:pool_failed
Unexecuted instantiation: http_fetch.c:pool_failed
Unexecuted instantiation: mqtt.c:pool_failed
Unexecuted instantiation: mux_spop.c:pool_failed
Unexecuted instantiation: pattern.c:pool_failed
Unexecuted instantiation: payload.c:pool_failed
Unexecuted instantiation: pipe.c:pool_failed
Unexecuted instantiation: proto_tcp.c:pool_failed
Unexecuted instantiation: shctx.c:pool_failed
Unexecuted instantiation: stats-file.c:pool_failed
Unexecuted instantiation: stats-json.c:pool_failed
Unexecuted instantiation: stats-proxy.c:pool_failed
Unexecuted instantiation: flt_spoe.c:pool_failed
Unexecuted instantiation: h1_htx.c:pool_failed
261
262
/* Returns the max number of entries that may be brought back to the pool
263
 * before it's considered as full. Note that it is only usable for releasing
264
 * objects, hence the function assumes that no more than ->used entries will
265
 * be released in the worst case, and that this value is always lower than or
266
 * equal to ->allocated. It's important to understand that under thread
267
 * contention these values may not always be accurate but the principle is that
268
 * any deviation remains contained. When global pools are disabled, this
269
 * function always returns zero so that the caller knows it must free the
270
 * object via other ways.
271
 */
272
static inline uint pool_releasable(const struct pool_head *pool)
273
0
{
274
0
  uint alloc, used;
275
0
  uint needed_raw;
276
277
0
  if (unlikely(pool_debugging & (POOL_DBG_NO_CACHE|POOL_DBG_NO_GLOBAL)))
278
0
    return 0;
279
280
0
  alloc = pool_allocated(pool);
281
0
  used  = pool_used(pool);
282
0
  if (used > alloc)
283
0
    alloc = used;
284
285
0
  needed_raw = pool_needed_avg(pool);
286
0
  if (alloc < swrate_avg(needed_raw + needed_raw / 4, POOL_AVG_SAMPLES))
287
0
    return used; // less than needed is allocated, can release everything
288
289
0
  if ((uint)(alloc - used) < pool->minavail)
290
0
    return pool->minavail - (alloc - used); // less than minimum available
291
292
  /* there are enough objects in this pool */
293
0
  return 0;
294
0
}
Unexecuted instantiation: cfgparse.c:pool_releasable
Unexecuted instantiation: chunk.c:pool_releasable
Unexecuted instantiation: cli.c:pool_releasable
Unexecuted instantiation: clock.c:pool_releasable
Unexecuted instantiation: connection.c:pool_releasable
Unexecuted instantiation: debug.c:pool_releasable
Unexecuted instantiation: dynbuf.c:pool_releasable
Unexecuted instantiation: errors.c:pool_releasable
Unexecuted instantiation: fd.c:pool_releasable
Unexecuted instantiation: filters.c:pool_releasable
Unexecuted instantiation: flt_http_comp.c:pool_releasable
Unexecuted instantiation: freq_ctr.c:pool_releasable
Unexecuted instantiation: frontend.c:pool_releasable
Unexecuted instantiation: haproxy.c:pool_releasable
Unexecuted instantiation: http.c:pool_releasable
Unexecuted instantiation: http_ana.c:pool_releasable
Unexecuted instantiation: http_ext.c:pool_releasable
Unexecuted instantiation: http_htx.c:pool_releasable
Unexecuted instantiation: http_rules.c:pool_releasable
Unexecuted instantiation: htx.c:pool_releasable
Unexecuted instantiation: lb_chash.c:pool_releasable
Unexecuted instantiation: lb_fas.c:pool_releasable
Unexecuted instantiation: lb_fwlc.c:pool_releasable
Unexecuted instantiation: lb_fwrr.c:pool_releasable
Unexecuted instantiation: lb_map.c:pool_releasable
Unexecuted instantiation: limits.c:pool_releasable
Unexecuted instantiation: listener.c:pool_releasable
Unexecuted instantiation: log.c:pool_releasable
Unexecuted instantiation: mailers.c:pool_releasable
Unexecuted instantiation: mworker.c:pool_releasable
Unexecuted instantiation: peers.c:pool_releasable
Unexecuted instantiation: pool.c:pool_releasable
Unexecuted instantiation: proto_rhttp.c:pool_releasable
Unexecuted instantiation: proto_sockpair.c:pool_releasable
Unexecuted instantiation: protocol.c:pool_releasable
Unexecuted instantiation: proxy.c:pool_releasable
Unexecuted instantiation: queue.c:pool_releasable
Unexecuted instantiation: regex.c:pool_releasable
Unexecuted instantiation: resolvers.c:pool_releasable
Unexecuted instantiation: ring.c:pool_releasable
Unexecuted instantiation: sample.c:pool_releasable
Unexecuted instantiation: server.c:pool_releasable
Unexecuted instantiation: session.c:pool_releasable
Unexecuted instantiation: signal.c:pool_releasable
Unexecuted instantiation: sink.c:pool_releasable
Unexecuted instantiation: sock.c:pool_releasable
Unexecuted instantiation: sock_inet.c:pool_releasable
Unexecuted instantiation: stats-html.c:pool_releasable
Unexecuted instantiation: stats.c:pool_releasable
Unexecuted instantiation: stconn.c:pool_releasable
Unexecuted instantiation: stick_table.c:pool_releasable
Unexecuted instantiation: stream.c:pool_releasable
Unexecuted instantiation: systemd.c:pool_releasable
Unexecuted instantiation: task.c:pool_releasable
Unexecuted instantiation: tcp_rules.c:pool_releasable
Unexecuted instantiation: tcpcheck.c:pool_releasable
Unexecuted instantiation: thread.c:pool_releasable
Unexecuted instantiation: tools.c:pool_releasable
Unexecuted instantiation: trace.c:pool_releasable
Unexecuted instantiation: vars.c:pool_releasable
Unexecuted instantiation: acl.c:pool_releasable
Unexecuted instantiation: action.c:pool_releasable
Unexecuted instantiation: activity.c:pool_releasable
Unexecuted instantiation: applet.c:pool_releasable
Unexecuted instantiation: arg.c:pool_releasable
Unexecuted instantiation: backend.c:pool_releasable
Unexecuted instantiation: cache.c:pool_releasable
Unexecuted instantiation: cfgcond.c:pool_releasable
Unexecuted instantiation: cfgparse-global.c:pool_releasable
Unexecuted instantiation: cfgparse-listen.c:pool_releasable
Unexecuted instantiation: channel.c:pool_releasable
Unexecuted instantiation: check.c:pool_releasable
Unexecuted instantiation: compression.c:pool_releasable
Unexecuted instantiation: counters.c:pool_releasable
Unexecuted instantiation: dgram.c:pool_releasable
Unexecuted instantiation: dns.c:pool_releasable
Unexecuted instantiation: dns_ring.c:pool_releasable
Unexecuted instantiation: event_hdl.c:pool_releasable
Unexecuted instantiation: extcheck.c:pool_releasable
Unexecuted instantiation: fcgi-app.c:pool_releasable
Unexecuted instantiation: fix.c:pool_releasable
Unexecuted instantiation: guid.c:pool_releasable
Unexecuted instantiation: h1.c:pool_releasable
Unexecuted instantiation: http_fetch.c:pool_releasable
Unexecuted instantiation: mqtt.c:pool_releasable
Unexecuted instantiation: mux_spop.c:pool_releasable
Unexecuted instantiation: pattern.c:pool_releasable
Unexecuted instantiation: payload.c:pool_releasable
Unexecuted instantiation: pipe.c:pool_releasable
Unexecuted instantiation: proto_tcp.c:pool_releasable
Unexecuted instantiation: shctx.c:pool_releasable
Unexecuted instantiation: stats-file.c:pool_releasable
Unexecuted instantiation: stats-json.c:pool_releasable
Unexecuted instantiation: stats-proxy.c:pool_releasable
Unexecuted instantiation: flt_spoe.c:pool_releasable
Unexecuted instantiation: h1_htx.c:pool_releasable
295
296
/* These are generic cache-aware wrappers that allocate/free from/to the local
297
 * cache first, then from the second level if it exists.
298
 */
299
300
/* Tries to retrieve an object from the local pool cache corresponding to pool
301
 * <pool>. If none is available, tries to allocate from the shared cache if any
302
 * and returns NULL if nothing is available. Must not be used when pools are
303
 * disabled.
304
 */
305
static inline void *pool_get_from_cache(struct pool_head *pool, const void *caller)
306
0
{
307
0
  struct pool_cache_item *item;
308
0
  struct pool_cache_head *ph;
309
310
0
  BUG_ON(pool_debugging & POOL_DBG_NO_CACHE);
311
312
0
  ph = &pool->cache[tid];
313
0
  if (unlikely(LIST_ISEMPTY(&ph->list))) {
314
0
    if (!(pool_debugging & POOL_DBG_NO_GLOBAL))
315
0
      pool_refill_local_from_shared(pool, ph);
316
0
    if (LIST_ISEMPTY(&ph->list))
317
0
      return NULL;
318
0
  }
319
320
  /* allocate hottest objects first */
321
0
  item = LIST_NEXT(&ph->list, typeof(item), by_pool);
322
323
0
  if (unlikely(pool_debugging & (POOL_DBG_COLD_FIRST|POOL_DBG_INTEGRITY))) {
324
    /* allocate oldest objects first so as to keep them as long as possible
325
     * in the cache before being reused and maximizing the chance to detect
326
     * an overwrite.
327
     */
328
0
    if (pool_debugging & POOL_DBG_COLD_FIRST)
329
0
      item = LIST_PREV(&ph->list, typeof(item), by_pool);
330
331
0
    if (pool_debugging & POOL_DBG_INTEGRITY)
332
0
      pool_check_pattern(ph, pool, item, caller);
333
0
  }
334
335
0
  BUG_ON(&item->by_pool == &ph->list);
336
0
  LIST_DELETE(&item->by_pool);
337
0
  LIST_DELETE(&item->by_lru);
338
339
  /* keep track of where the element was allocated from */
340
0
  POOL_DEBUG_SET_MARK(pool, item);
341
0
  POOL_DEBUG_TRACE_CALLER(pool, item, caller);
342
343
0
  ph->count--;
344
0
  pool_cache_bytes -= pool->size;
345
0
  pool_cache_count--;
346
347
0
  return item;
348
0
}
Unexecuted instantiation: cfgparse.c:pool_get_from_cache
Unexecuted instantiation: chunk.c:pool_get_from_cache
Unexecuted instantiation: cli.c:pool_get_from_cache
Unexecuted instantiation: clock.c:pool_get_from_cache
Unexecuted instantiation: connection.c:pool_get_from_cache
Unexecuted instantiation: debug.c:pool_get_from_cache
Unexecuted instantiation: dynbuf.c:pool_get_from_cache
Unexecuted instantiation: errors.c:pool_get_from_cache
Unexecuted instantiation: fd.c:pool_get_from_cache
Unexecuted instantiation: filters.c:pool_get_from_cache
Unexecuted instantiation: flt_http_comp.c:pool_get_from_cache
Unexecuted instantiation: freq_ctr.c:pool_get_from_cache
Unexecuted instantiation: frontend.c:pool_get_from_cache
Unexecuted instantiation: haproxy.c:pool_get_from_cache
Unexecuted instantiation: http.c:pool_get_from_cache
Unexecuted instantiation: http_ana.c:pool_get_from_cache
Unexecuted instantiation: http_ext.c:pool_get_from_cache
Unexecuted instantiation: http_htx.c:pool_get_from_cache
Unexecuted instantiation: http_rules.c:pool_get_from_cache
Unexecuted instantiation: htx.c:pool_get_from_cache
Unexecuted instantiation: lb_chash.c:pool_get_from_cache
Unexecuted instantiation: lb_fas.c:pool_get_from_cache
Unexecuted instantiation: lb_fwlc.c:pool_get_from_cache
Unexecuted instantiation: lb_fwrr.c:pool_get_from_cache
Unexecuted instantiation: lb_map.c:pool_get_from_cache
Unexecuted instantiation: limits.c:pool_get_from_cache
Unexecuted instantiation: listener.c:pool_get_from_cache
Unexecuted instantiation: log.c:pool_get_from_cache
Unexecuted instantiation: mailers.c:pool_get_from_cache
Unexecuted instantiation: mworker.c:pool_get_from_cache
Unexecuted instantiation: peers.c:pool_get_from_cache
Unexecuted instantiation: pool.c:pool_get_from_cache
Unexecuted instantiation: proto_rhttp.c:pool_get_from_cache
Unexecuted instantiation: proto_sockpair.c:pool_get_from_cache
Unexecuted instantiation: protocol.c:pool_get_from_cache
Unexecuted instantiation: proxy.c:pool_get_from_cache
Unexecuted instantiation: queue.c:pool_get_from_cache
Unexecuted instantiation: regex.c:pool_get_from_cache
Unexecuted instantiation: resolvers.c:pool_get_from_cache
Unexecuted instantiation: ring.c:pool_get_from_cache
Unexecuted instantiation: sample.c:pool_get_from_cache
Unexecuted instantiation: server.c:pool_get_from_cache
Unexecuted instantiation: session.c:pool_get_from_cache
Unexecuted instantiation: signal.c:pool_get_from_cache
Unexecuted instantiation: sink.c:pool_get_from_cache
Unexecuted instantiation: sock.c:pool_get_from_cache
Unexecuted instantiation: sock_inet.c:pool_get_from_cache
Unexecuted instantiation: stats-html.c:pool_get_from_cache
Unexecuted instantiation: stats.c:pool_get_from_cache
Unexecuted instantiation: stconn.c:pool_get_from_cache
Unexecuted instantiation: stick_table.c:pool_get_from_cache
Unexecuted instantiation: stream.c:pool_get_from_cache
Unexecuted instantiation: systemd.c:pool_get_from_cache
Unexecuted instantiation: task.c:pool_get_from_cache
Unexecuted instantiation: tcp_rules.c:pool_get_from_cache
Unexecuted instantiation: tcpcheck.c:pool_get_from_cache
Unexecuted instantiation: thread.c:pool_get_from_cache
Unexecuted instantiation: tools.c:pool_get_from_cache
Unexecuted instantiation: trace.c:pool_get_from_cache
Unexecuted instantiation: vars.c:pool_get_from_cache
Unexecuted instantiation: acl.c:pool_get_from_cache
Unexecuted instantiation: action.c:pool_get_from_cache
Unexecuted instantiation: activity.c:pool_get_from_cache
Unexecuted instantiation: applet.c:pool_get_from_cache
Unexecuted instantiation: arg.c:pool_get_from_cache
Unexecuted instantiation: backend.c:pool_get_from_cache
Unexecuted instantiation: cache.c:pool_get_from_cache
Unexecuted instantiation: cfgcond.c:pool_get_from_cache
Unexecuted instantiation: cfgparse-global.c:pool_get_from_cache
Unexecuted instantiation: cfgparse-listen.c:pool_get_from_cache
Unexecuted instantiation: channel.c:pool_get_from_cache
Unexecuted instantiation: check.c:pool_get_from_cache
Unexecuted instantiation: compression.c:pool_get_from_cache
Unexecuted instantiation: counters.c:pool_get_from_cache
Unexecuted instantiation: dgram.c:pool_get_from_cache
Unexecuted instantiation: dns.c:pool_get_from_cache
Unexecuted instantiation: dns_ring.c:pool_get_from_cache
Unexecuted instantiation: event_hdl.c:pool_get_from_cache
Unexecuted instantiation: extcheck.c:pool_get_from_cache
Unexecuted instantiation: fcgi-app.c:pool_get_from_cache
Unexecuted instantiation: fix.c:pool_get_from_cache
Unexecuted instantiation: guid.c:pool_get_from_cache
Unexecuted instantiation: h1.c:pool_get_from_cache
Unexecuted instantiation: http_fetch.c:pool_get_from_cache
Unexecuted instantiation: mqtt.c:pool_get_from_cache
Unexecuted instantiation: mux_spop.c:pool_get_from_cache
Unexecuted instantiation: pattern.c:pool_get_from_cache
Unexecuted instantiation: payload.c:pool_get_from_cache
Unexecuted instantiation: pipe.c:pool_get_from_cache
Unexecuted instantiation: proto_tcp.c:pool_get_from_cache
Unexecuted instantiation: shctx.c:pool_get_from_cache
Unexecuted instantiation: stats-file.c:pool_get_from_cache
Unexecuted instantiation: stats-json.c:pool_get_from_cache
Unexecuted instantiation: stats-proxy.c:pool_get_from_cache
Unexecuted instantiation: flt_spoe.c:pool_get_from_cache
Unexecuted instantiation: h1_htx.c:pool_get_from_cache
349
350
351
/****************** Common high-level code ******************/
352
353
#if !defined(DEBUG_MEM_STATS)
354
355
/*
356
 * Returns a pointer to an object from pool <pool> allocated using
357
 * flags <flag> from the POOL_F_* set.
358
 */
359
0
#define pool_alloc_flag(pool, flag)  __pool_alloc((pool), (flag))
360
361
/*
362
 * Returns a pointer to type <type> taken from the pool <pool_type> or
363
 * dynamically allocated. Memory poisonning is performed if enabled.
364
 */
365
0
#define pool_alloc(pool) __pool_alloc((pool), 0)
366
367
/*
368
 * Returns a pointer to type <type> taken from the pool <pool_type> or
369
 * dynamically allocated. The area is zeroed.
370
 */
371
0
#define pool_zalloc(pool) __pool_alloc((pool), POOL_F_MUST_ZERO)
372
373
/*
374
 * Puts a memory area back to the corresponding pool. Just like with the libc's
375
 * free(), <ptr> may be NULL.
376
 */
377
#define pool_free(pool, ptr)        \
378
0
  do {           \
379
0
    typeof(ptr) __ptr = (ptr);    \
380
0
    if (likely((__ptr) != NULL))    \
381
0
      __pool_free(pool, __ptr); \
382
0
  } while (0)
383
384
385
#else /* DEBUG_MEM_STATS is set below */
386
387
#define pool_free(pool, ptr)  ({          \
388
  struct pool_head *__pool = (pool);        \
389
  typeof(ptr) __ptr = (ptr);          \
390
  static struct mem_stats _ __attribute__((used,__section__("mem_stats"),__aligned__(sizeof(void*)))) = { \
391
    .caller = {           \
392
      .file = __FILE__, .line = __LINE__,   \
393
      .what = MEM_STATS_TYPE_P_FREE,      \
394
      .func = __func__,       \
395
    },              \
396
  };                \
397
  _.extra = __pool;           \
398
  HA_WEAK(__start_mem_stats);         \
399
  HA_WEAK(__stop_mem_stats);          \
400
  if (__ptr)  {             \
401
    _HA_ATOMIC_INC(&_.calls);       \
402
    _HA_ATOMIC_ADD(&_.size, __pool->size);      \
403
    __pool_free(__pool, __ptr);       \
404
  }               \
405
})
406
407
#define pool_alloc_flag(pool, flag)  ({         \
408
  struct pool_head *__pool = (pool);        \
409
  uint __flag = (flag);           \
410
  size_t __x = __pool->size;          \
411
  static struct mem_stats _ __attribute__((used,__section__("mem_stats"),__aligned__(sizeof(void*)))) = { \
412
    .caller = {           \
413
      .file = __FILE__, .line = __LINE__,   \
414
      .what = MEM_STATS_TYPE_P_ALLOC,     \
415
      .func = __func__,       \
416
    },              \
417
  };                \
418
  _.extra = __pool;           \
419
  HA_WEAK(__start_mem_stats);         \
420
  HA_WEAK(__stop_mem_stats);          \
421
  _HA_ATOMIC_INC(&_.calls);         \
422
  _HA_ATOMIC_ADD(&_.size, __x);         \
423
  __pool_alloc(__pool, __flag);         \
424
})
425
426
#define pool_alloc(pool) pool_alloc_flag(pool, 0)
427
428
#define pool_zalloc(pool) pool_alloc_flag(pool, POOL_F_MUST_ZERO)
429
430
#endif /* DEBUG_MEM_STATS */
431
432
#endif /* _HAPROXY_POOL_H */
433
434
/*
435
 * Local variables:
436
 *  c-indent-level: 8
437
 *  c-basic-offset: 8
438
 * End:
439
 */