blob: 9ee1b445069e937f6ef9e96258bc4c14b7b81203 [file] [log] [blame]
Jason Evanse476f8a2010-01-16 09:53:50 -08001/******************************************************************************/
2#ifdef JEMALLOC_H_TYPES
3
4typedef struct extent_node_s extent_node_t;
5
6#endif /* JEMALLOC_H_TYPES */
7/******************************************************************************/
8#ifdef JEMALLOC_H_STRUCTS
9
Jason Evansee41ad42015-02-15 18:04:46 -080010/* Tree of extents. Use accessor functions for en_* fields. */
Jason Evanse476f8a2010-01-16 09:53:50 -080011struct extent_node_s {
Jason Evanscbf3a6d2015-02-11 12:24:27 -080012 /* Arena from which this extent came, if any. */
Jason Evansee41ad42015-02-15 18:04:46 -080013 arena_t *en_arena;
Jason Evans6109fe02010-02-10 10:37:56 -080014
Jason Evanse476f8a2010-01-16 09:53:50 -080015 /* Pointer to the extent that this tree node is responsible for. */
Jason Evansee41ad42015-02-15 18:04:46 -080016 void *en_addr;
17
18 /* Total region size. */
19 size_t en_size;
Jason Evanse476f8a2010-01-16 09:53:50 -080020
Jason Evanscbf3a6d2015-02-11 12:24:27 -080021 /*
Jason Evansee41ad42015-02-15 18:04:46 -080022 * The zeroed flag is used by chunk recycling code to track whether
23 * memory is zero-filled.
Jason Evanscbf3a6d2015-02-11 12:24:27 -080024 */
Jason Evansee41ad42015-02-15 18:04:46 -080025 bool en_zeroed;
Jason Evans7de92762012-10-08 17:56:11 -070026
Jason Evans918a1a52015-01-30 21:21:16 -080027 /*
Jason Evansee41ad42015-02-15 18:04:46 -080028 * The achunk flag is used to validate that huge allocation lookups
29 * don't return arena chunks.
Jason Evans918a1a52015-01-30 21:21:16 -080030 */
Jason Evansee41ad42015-02-15 18:04:46 -080031 bool en_achunk;
32
Jason Evansa4e18882015-02-17 15:13:52 -080033 /* Profile counters, used for huge objects. */
34 prof_tctx_t *en_prof_tctx;
Jason Evans918a1a52015-01-30 21:21:16 -080035
Jason Evansa4e18882015-02-17 15:13:52 -080036 /* Linkage for arena's runs_dirty and chunks_dirty rings. */
37 qr(extent_node_t) cd_link;
38 arena_chunk_map_misc_t runs_dirty;
Jason Evanscbf3a6d2015-02-11 12:24:27 -080039
40 union {
41 /* Linkage for the size/address-ordered tree. */
Jason Evans2195ba42015-02-15 16:43:52 -080042 rb_node(extent_node_t) szad_link;
Jason Evanscbf3a6d2015-02-11 12:24:27 -080043
Jason Evansee41ad42015-02-15 18:04:46 -080044 /* Linkage for arena's huge and node_cache lists. */
Jason Evans2195ba42015-02-15 16:43:52 -080045 ql_elm(extent_node_t) ql_link;
Jason Evanscbf3a6d2015-02-11 12:24:27 -080046 };
47
48 /* Linkage for the address-ordered tree. */
Jason Evans2195ba42015-02-15 16:43:52 -080049 rb_node(extent_node_t) ad_link;
Jason Evanse476f8a2010-01-16 09:53:50 -080050};
51typedef rb_tree(extent_node_t) extent_tree_t;
52
53#endif /* JEMALLOC_H_STRUCTS */
54/******************************************************************************/
55#ifdef JEMALLOC_H_EXTERNS
56
Jason Evanse476f8a2010-01-16 09:53:50 -080057rb_proto(, extent_tree_szad_, extent_tree_t, extent_node_t)
Jason Evanse476f8a2010-01-16 09:53:50 -080058
59rb_proto(, extent_tree_ad_, extent_tree_t, extent_node_t)
60
61#endif /* JEMALLOC_H_EXTERNS */
62/******************************************************************************/
63#ifdef JEMALLOC_H_INLINES
64
Jason Evansee41ad42015-02-15 18:04:46 -080065#ifndef JEMALLOC_ENABLE_INLINE
66arena_t *extent_node_arena_get(const extent_node_t *node);
67void *extent_node_addr_get(const extent_node_t *node);
68size_t extent_node_size_get(const extent_node_t *node);
69bool extent_node_zeroed_get(const extent_node_t *node);
70bool extent_node_achunk_get(const extent_node_t *node);
71prof_tctx_t *extent_node_prof_tctx_get(const extent_node_t *node);
72void extent_node_arena_set(extent_node_t *node, arena_t *arena);
73void extent_node_addr_set(extent_node_t *node, void *addr);
74void extent_node_size_set(extent_node_t *node, size_t size);
75void extent_node_zeroed_set(extent_node_t *node, bool zeroed);
76void extent_node_achunk_set(extent_node_t *node, bool achunk);
77void extent_node_prof_tctx_set(extent_node_t *node, prof_tctx_t *tctx);
Jason Evansa4e18882015-02-17 15:13:52 -080078void extent_node_init(extent_node_t *node, arena_t *arena, void *addr,
79 size_t size, bool zeroed);
Jason Evansee41ad42015-02-15 18:04:46 -080080#endif
81
82#if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_EXTENT_C_))
83JEMALLOC_INLINE arena_t *
84extent_node_arena_get(const extent_node_t *node)
85{
86
87 return (node->en_arena);
88}
89
90JEMALLOC_INLINE void *
91extent_node_addr_get(const extent_node_t *node)
92{
93
94 return (node->en_addr);
95}
96
97JEMALLOC_INLINE size_t
98extent_node_size_get(const extent_node_t *node)
99{
100
101 return (node->en_size);
102}
103
104JEMALLOC_INLINE bool
105extent_node_zeroed_get(const extent_node_t *node)
106{
107
108 return (node->en_zeroed);
109}
110
111JEMALLOC_INLINE bool
112extent_node_achunk_get(const extent_node_t *node)
113{
114
115 return (node->en_achunk);
116}
117
118JEMALLOC_INLINE prof_tctx_t *
119extent_node_prof_tctx_get(const extent_node_t *node)
120{
121
122 return (node->en_prof_tctx);
123}
124
125JEMALLOC_INLINE void
126extent_node_arena_set(extent_node_t *node, arena_t *arena)
127{
128
129 node->en_arena = arena;
130}
131
132JEMALLOC_INLINE void
133extent_node_addr_set(extent_node_t *node, void *addr)
134{
135
136 node->en_addr = addr;
137}
138
139JEMALLOC_INLINE void
140extent_node_size_set(extent_node_t *node, size_t size)
141{
142
143 node->en_size = size;
144}
145
146JEMALLOC_INLINE void
147extent_node_zeroed_set(extent_node_t *node, bool zeroed)
148{
149
150 node->en_zeroed = zeroed;
151}
152
153JEMALLOC_INLINE void
154extent_node_achunk_set(extent_node_t *node, bool achunk)
155{
156
157 node->en_achunk = achunk;
158}
159
160JEMALLOC_INLINE void
161extent_node_prof_tctx_set(extent_node_t *node, prof_tctx_t *tctx)
162{
163
164 node->en_prof_tctx = tctx;
165}
Jason Evansa4e18882015-02-17 15:13:52 -0800166
167JEMALLOC_INLINE void
168extent_node_init(extent_node_t *node, arena_t *arena, void *addr, size_t size,
169 bool zeroed)
170{
171
172 extent_node_arena_set(node, arena);
173 extent_node_addr_set(node, addr);
174 extent_node_size_set(node, size);
175 extent_node_zeroed_set(node, zeroed);
176 extent_node_achunk_set(node, false);
177 if (config_prof)
178 extent_node_prof_tctx_set(node, NULL);
179}
Jason Evansee41ad42015-02-15 18:04:46 -0800180#endif
181
Jason Evanse476f8a2010-01-16 09:53:50 -0800182#endif /* JEMALLOC_H_INLINES */
183/******************************************************************************/
184