2020-11-07 06:38:17 +08:00
|
|
|
#ifndef JEMALLOC_INTERNAL_EXP_GROW_H
|
|
|
|
#define JEMALLOC_INTERNAL_EXP_GROW_H
|
2020-08-08 09:03:40 +08:00
|
|
|
|
2023-06-10 08:37:47 +08:00
|
|
|
#include "jemalloc/internal/jemalloc_preamble.h"
|
|
|
|
#include "jemalloc/internal/sz.h"
|
2020-11-07 06:38:17 +08:00
|
|
|
typedef struct exp_grow_s exp_grow_t;
|
|
|
|
struct exp_grow_s {
|
2020-08-08 09:03:40 +08:00
|
|
|
/*
|
|
|
|
* Next extent size class in a growing series to use when satisfying a
|
|
|
|
* request via the extent hooks (only if opt_retain). This limits the
|
|
|
|
* number of disjoint virtual memory ranges so that extent merging can
|
|
|
|
* be effective even if multiple arenas' extent allocation requests are
|
|
|
|
* highly interleaved.
|
|
|
|
*
|
|
|
|
* retain_grow_limit is the max allowed size ind to expand (unless the
|
|
|
|
* required size is greater). Default is no limit, and controlled
|
|
|
|
* through mallctl only.
|
|
|
|
*/
|
|
|
|
pszind_t next;
|
|
|
|
pszind_t limit;
|
|
|
|
};
|
|
|
|
|
2020-08-08 09:16:31 +08:00
|
|
|
static inline bool
|
2020-11-07 06:38:17 +08:00
|
|
|
exp_grow_size_prepare(exp_grow_t *exp_grow, size_t alloc_size_min,
|
2020-08-08 09:16:31 +08:00
|
|
|
size_t *r_alloc_size, pszind_t *r_skip) {
|
|
|
|
*r_skip = 0;
|
2020-11-07 06:38:17 +08:00
|
|
|
*r_alloc_size = sz_pind2sz(exp_grow->next + *r_skip);
|
2020-08-08 09:16:31 +08:00
|
|
|
while (*r_alloc_size < alloc_size_min) {
|
|
|
|
(*r_skip)++;
|
2020-11-07 06:38:17 +08:00
|
|
|
if (exp_grow->next + *r_skip >=
|
2020-08-08 09:16:31 +08:00
|
|
|
sz_psz2ind(SC_LARGE_MAXCLASS)) {
|
|
|
|
/* Outside legal range. */
|
|
|
|
return true;
|
|
|
|
}
|
2020-11-07 06:38:17 +08:00
|
|
|
*r_alloc_size = sz_pind2sz(exp_grow->next + *r_skip);
|
2020-08-08 09:16:31 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2020-11-07 06:38:17 +08:00
|
|
|
exp_grow_size_commit(exp_grow_t *exp_grow, pszind_t skip) {
|
|
|
|
if (exp_grow->next + skip + 1 <= exp_grow->limit) {
|
|
|
|
exp_grow->next += skip + 1;
|
2020-08-08 09:16:31 +08:00
|
|
|
} else {
|
2020-11-07 06:38:17 +08:00
|
|
|
exp_grow->next = exp_grow->limit;
|
2020-08-08 09:16:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-11-07 06:38:17 +08:00
|
|
|
void exp_grow_init(exp_grow_t *exp_grow);
|
2020-08-08 09:03:40 +08:00
|
|
|
|
2020-11-07 06:38:17 +08:00
|
|
|
#endif /* JEMALLOC_INTERNAL_EXP_GROW_H */
|