1 1.1 christos #ifndef JEMALLOC_INTERNAL_EXP_GROW_H 2 1.1 christos #define JEMALLOC_INTERNAL_EXP_GROW_H 3 1.1 christos 4 1.1 christos typedef struct exp_grow_s exp_grow_t; 5 1.1 christos struct exp_grow_s { 6 1.1 christos /* 7 1.1 christos * Next extent size class in a growing series to use when satisfying a 8 1.1 christos * request via the extent hooks (only if opt_retain). This limits the 9 1.1 christos * number of disjoint virtual memory ranges so that extent merging can 10 1.1 christos * be effective even if multiple arenas' extent allocation requests are 11 1.1 christos * highly interleaved. 12 1.1 christos * 13 1.1 christos * retain_grow_limit is the max allowed size ind to expand (unless the 14 1.1 christos * required size is greater). Default is no limit, and controlled 15 1.1 christos * through mallctl only. 16 1.1 christos */ 17 1.1 christos pszind_t next; 18 1.1 christos pszind_t limit; 19 1.1 christos }; 20 1.1 christos 21 1.1 christos static inline bool 22 1.1 christos exp_grow_size_prepare(exp_grow_t *exp_grow, size_t alloc_size_min, 23 1.1 christos size_t *r_alloc_size, pszind_t *r_skip) { 24 1.1 christos *r_skip = 0; 25 1.1 christos *r_alloc_size = sz_pind2sz(exp_grow->next + *r_skip); 26 1.1 christos while (*r_alloc_size < alloc_size_min) { 27 1.1 christos (*r_skip)++; 28 1.1 christos if (exp_grow->next + *r_skip >= 29 1.1 christos sz_psz2ind(SC_LARGE_MAXCLASS)) { 30 1.1 christos /* Outside legal range. */ 31 1.1 christos return true; 32 1.1 christos } 33 1.1 christos *r_alloc_size = sz_pind2sz(exp_grow->next + *r_skip); 34 1.1 christos } 35 1.1 christos return false; 36 1.1 christos } 37 1.1 christos 38 1.1 christos static inline void 39 1.1 christos exp_grow_size_commit(exp_grow_t *exp_grow, pszind_t skip) { 40 1.1 christos if (exp_grow->next + skip + 1 <= exp_grow->limit) { 41 1.1 christos exp_grow->next += skip + 1; 42 1.1 christos } else { 43 1.1 christos exp_grow->next = exp_grow->limit; 44 1.1 christos } 45 1.1 christos 46 1.1 christos } 47 1.1 christos 48 1.1 christos void exp_grow_init(exp_grow_t *exp_grow); 49 1.1 christos 50 1.1 christos #endif /* JEMALLOC_INTERNAL_EXP_GROW_H */ 51