1 /******************************************************************************/
2 #ifdef JEMALLOC_H_TYPES
4 typedef struct extent_node_s extent_node_t
;
6 #endif /* JEMALLOC_H_TYPES */
7 /******************************************************************************/
8 #ifdef JEMALLOC_H_STRUCTS
10 /* Tree of extents. Use accessor functions for en_* fields. */
11 struct extent_node_s
{
12 /* Arena from which this extent came, if any. */
15 /* Pointer to the extent that this tree node is responsible for. */
18 /* Total region size. */
22 * The zeroed flag is used by chunk recycling code to track whether
23 * memory is zero-filled.
28 * True if physical memory is committed to the extent, whether
29 * explicitly or implicitly as on a system that overcommits and
30 * satisfies physical memory needs on demand via soft page faults.
35 * The achunk flag is used to validate that huge allocation lookups
36 * don't return arena chunks.
40 /* Profile counters, used for huge objects. */
41 prof_tctx_t
*en_prof_tctx
;
43 /* Linkage for arena's runs_dirty and chunks_cache rings. */
44 arena_runs_dirty_link_t rd
;
45 qr(extent_node_t
) cc_link
;
48 /* Linkage for the size/address-ordered tree. */
49 rb_node(extent_node_t
) szad_link
;
51 /* Linkage for arena's huge and node_cache lists. */
52 ql_elm(extent_node_t
) ql_link
;
55 /* Linkage for the address-ordered tree. */
56 rb_node(extent_node_t
) ad_link
;
58 typedef rb_tree(extent_node_t
) extent_tree_t
;
60 #endif /* JEMALLOC_H_STRUCTS */
61 /******************************************************************************/
62 #ifdef JEMALLOC_H_EXTERNS
64 rb_proto(, extent_tree_szad_
, extent_tree_t
, extent_node_t
)
66 rb_proto(, extent_tree_ad_
, extent_tree_t
, extent_node_t
)
68 #endif /* JEMALLOC_H_EXTERNS */
69 /******************************************************************************/
70 #ifdef JEMALLOC_H_INLINES
72 #ifndef JEMALLOC_ENABLE_INLINE
73 arena_t
*extent_node_arena_get(const extent_node_t
*node
);
74 void *extent_node_addr_get(const extent_node_t
*node
);
75 size_t extent_node_size_get(const extent_node_t
*node
);
76 bool extent_node_zeroed_get(const extent_node_t
*node
);
77 bool extent_node_committed_get(const extent_node_t
*node
);
78 bool extent_node_achunk_get(const extent_node_t
*node
);
79 prof_tctx_t
*extent_node_prof_tctx_get(const extent_node_t
*node
);
80 void extent_node_arena_set(extent_node_t
*node
, arena_t
*arena
);
81 void extent_node_addr_set(extent_node_t
*node
, void *addr
);
82 void extent_node_size_set(extent_node_t
*node
, size_t size
);
83 void extent_node_zeroed_set(extent_node_t
*node
, bool zeroed
);
84 void extent_node_committed_set(extent_node_t
*node
, bool committed
);
85 void extent_node_achunk_set(extent_node_t
*node
, bool achunk
);
86 void extent_node_prof_tctx_set(extent_node_t
*node
, prof_tctx_t
*tctx
);
87 void extent_node_init(extent_node_t
*node
, arena_t
*arena
, void *addr
,
88 size_t size
, bool zeroed
, bool committed
);
89 void extent_node_dirty_linkage_init(extent_node_t
*node
);
90 void extent_node_dirty_insert(extent_node_t
*node
,
91 arena_runs_dirty_link_t
*runs_dirty
, extent_node_t
*chunks_dirty
);
92 void extent_node_dirty_remove(extent_node_t
*node
);
95 #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_EXTENT_C_))
96 JEMALLOC_INLINE arena_t
*
97 extent_node_arena_get(const extent_node_t
*node
)
100 return (node
->en_arena
);
103 JEMALLOC_INLINE
void *
104 extent_node_addr_get(const extent_node_t
*node
)
107 return (node
->en_addr
);
110 JEMALLOC_INLINE
size_t
111 extent_node_size_get(const extent_node_t
*node
)
114 return (node
->en_size
);
118 extent_node_zeroed_get(const extent_node_t
*node
)
121 return (node
->en_zeroed
);
125 extent_node_committed_get(const extent_node_t
*node
)
128 assert(!node
->en_achunk
);
129 return (node
->en_committed
);
133 extent_node_achunk_get(const extent_node_t
*node
)
136 return (node
->en_achunk
);
139 JEMALLOC_INLINE prof_tctx_t
*
140 extent_node_prof_tctx_get(const extent_node_t
*node
)
143 return (node
->en_prof_tctx
);
147 extent_node_arena_set(extent_node_t
*node
, arena_t
*arena
)
150 node
->en_arena
= arena
;
154 extent_node_addr_set(extent_node_t
*node
, void *addr
)
157 node
->en_addr
= addr
;
161 extent_node_size_set(extent_node_t
*node
, size_t size
)
164 node
->en_size
= size
;
168 extent_node_zeroed_set(extent_node_t
*node
, bool zeroed
)
171 node
->en_zeroed
= zeroed
;
175 extent_node_committed_set(extent_node_t
*node
, bool committed
)
178 node
->en_committed
= committed
;
182 extent_node_achunk_set(extent_node_t
*node
, bool achunk
)
185 node
->en_achunk
= achunk
;
189 extent_node_prof_tctx_set(extent_node_t
*node
, prof_tctx_t
*tctx
)
192 node
->en_prof_tctx
= tctx
;
196 extent_node_init(extent_node_t
*node
, arena_t
*arena
, void *addr
, size_t size
,
197 bool zeroed
, bool committed
)
200 extent_node_arena_set(node
, arena
);
201 extent_node_addr_set(node
, addr
);
202 extent_node_size_set(node
, size
);
203 extent_node_zeroed_set(node
, zeroed
);
204 extent_node_committed_set(node
, committed
);
205 extent_node_achunk_set(node
, false);
207 extent_node_prof_tctx_set(node
, NULL
);
211 extent_node_dirty_linkage_init(extent_node_t
*node
)
214 qr_new(&node
->rd
, rd_link
);
215 qr_new(node
, cc_link
);
219 extent_node_dirty_insert(extent_node_t
*node
,
220 arena_runs_dirty_link_t
*runs_dirty
, extent_node_t
*chunks_dirty
)
223 qr_meld(runs_dirty
, &node
->rd
, rd_link
);
224 qr_meld(chunks_dirty
, node
, cc_link
);
228 extent_node_dirty_remove(extent_node_t
*node
)
231 qr_remove(&node
->rd
, rd_link
);
232 qr_remove(node
, cc_link
);
237 #endif /* JEMALLOC_H_INLINES */
238 /******************************************************************************/