1MEMKIND_ARENA(3)                 MEMKIND_ARENA                MEMKIND_ARENA(3)
2
3
4

NAME

6       memkind_arena - jemalloc arena allocation memkind operations.
7       Note:  This  is EXPERIMENTAL API. The functionality and the header file
8       itself can be changed (including non-backward  compatible  changes)  or
9       removed.
10

SYNOPSIS

12       int memkind_arena_create(struct memkind *kind, struct memkind_ops *ops,
13       const char *name);
14       int  memkind_arena_create_map(struct  memkind   *kind,   extent_hooks_t
15       *hooks);
16       int memkind_arena_destroy(struct memkind *kind);
17       void *memkind_arena_malloc(struct memkind *kind, size_t size);
18       void  *memkind_arena_calloc(struct  memkind  *kind,  size_t num, size_t
19       size);
20       int memkind_arena_posix_memalign(struct memkind *kind,  void  **memptr,
21       size_t alignment, size_t size);
22       void  *memkind_arena_realloc(struct  memkind  *kind,  void *ptr, size_t
23       size);
24       void *memkind_arena_realloc_with_kind_detect(void *ptr, size_t size);
25       int memkind_thread_get_arena(struct memkind *kind, unsigned int *arena,
26       size_t size);
27       int  memkind_bijective_get_arena(struct  memkind  *kind,  unsigned  int
28       *arena, size_t size);
29       struct memkind *get_kind_by_arena(unsigned arena_ind);
30       struct memkind *memkind_arena_detect_kind(void *ptr);
31       int memkind_arena_finalize(struct memkind *kind);
32       void memkind_arena_init(struct memkind *kind);
33       void memkind_arena_free(struct memkind *kind, void *ptr);
34       void memkind_arena_free_with_kind_detect(void *ptr);
35       int  memkind_arena_update_memory_usage_policy(struct   memkind   *kind,
36       memkind_mem_usage_policy policy);
37       int memkind_arena_set_max_bg_threads(size_t threads_limit);
38       int memkind_arena_set_bg_threads(bool state);
39       int  memkind_arena_stats_print(void (*write_cb) (void *, const char *),
40       void *cbopaque, memkind_stat_print_opt opts);
41

DESCRIPTION

43       This header file is a collection of functions can be used  to  populate
44       the memkind operations structure for memory kinds that use jemalloc.
45
46       memkind_arena_create() is an implementation of the memkind "create" op‐
47       eration for memory kinds that use  jemalloc.   This  calls  memkind_de‐
48       fault_create()  (see memkind_default(3)) followed by memkind_arena_cre‐
49       ate_map() described below.
50
51       memkind_arena_create_map() creates the arena_map array for the  memkind
52       structure   pointed   to   by   kind   which  can  be  indexed  by  the
53       ops.get_arena() function from  the  kind's  operations.   If  get_arena
54       points  memkind_thread_get_arena()  then there will be four arenas cre‐
55       ated for each processor, and  if  get_arena  points  to  memkind_bijec‐
56       tive_get_arena() then just one arena is created.
57
58       memkind_arena_destroy()  is  an implementation of the memkind "destroy"
59       operation for memory kinds that use jemalloc.  This releases all of the
60       resources allocated by memkind_arena_create().
61
62       memkind_arena_malloc() is an implementation of the memkind "malloc" op‐
63       eration for memory kinds that use jemalloc.  This allocates memory  us‐
64       ing the arenas created by memkind_arena_create() through the jemalloc's
65       mallocx() interface.  It uses the memkind "get_arena" operation to  se‐
66       lect the arena.
67
68       memkind_arena_calloc() is an implementation of the memkind "calloc" op‐
69       eration for memory kinds that use jemalloc.  This allocates memory  us‐
70       ing the arenas created by memkind_arena_create() through the jemalloc's
71       mallocx() interface.  It uses the memkind "get_arena" operation to  se‐
72       lect the arena.
73
74       memkind_arena_posix_memalign()  is  an  implementation  of  the memkind
75       "posix_memalign" operation for memory kinds that  use  jemalloc.   This
76       allocates  memory  using  the  arenas created by memkind_arena_create()
77       through the  jemalloc's  mallocx()  interface.   It  uses  the  memkind
78       "get_arena" operation to select the arena.  The POSIX standard requires
79       that posix_memalign(3) may not set errno however  the  jemalloc's  mal‐
80       locx()  routine  may.   In an attempt to abide by the standard errno is
81       recorded before calling jemalloc's mallocx() and then reset  after  the
82       call.
83
84       memkind_arena_realloc()  is  an implementation of the memkind "realloc"
85       operation for memory kinds that use jemalloc.   This  allocates  memory
86       using  the  arenas created by memkind_arena_create() through the jemal‐
87       loc's mallocx() interface.  It uses the memkind  "get_arena"  operation
88       to select the arena.
89
90       memkind_arena_realloc_with_kind_detect() function will look up for kind
91       associated to the allocated memory referenced by ptr and call  (depend‐
92       ing  on  kind  value)  memkind_arena_realloc() or memkind_default_real‐
93       loc().
94
95       memkind_thread_get_arena() retrieves the arena index that is  bound  to
96       to  the calling thread based on a hash of its thread ID.  The arena in‐
97       dex can be used with the MALLOCX_ARENA macro to set  flags  for  jemal‐
98       loc's mallocx().
99
100       memkind_bijective_arena_get_arena()  retrieves  the  arena  index to be
101       used with the MALLOCX_ARENA macro to  set  flags  for  jemalloc's  mal‐
102       locx().   Use of this operation implies that only one arena is used for
103       the kind.
104
105       memkind_arena_free() is an implementation of the memkind "free"  opera‐
106       tion  for memory kinds that use jemalloc.  It causes the allocated mem‐
107       ory referenced by ptr, which must have been returned by a previous call
108       to  memkind_arena_malloc(), memkind_arena_calloc() or memkind_arena_re‐
109       alloc() to be made available  for  future  allocations.   It  uses  the
110       memkind "get_arena" operation to select the arena.
111
112       memkind_arena_free_with_kind_detect()  function  will  look up for kind
113       associated  to  the  allocated  memory  referenced  by  ptr  and   call
114       memkind_arena_free().
115
116       memkind_arena_detect_kind()  returns  pointer  to memory kind structure
117       associated with given allocated memory referenced by ptr.
118
119       get_kind_by_arena() returns pointer to memory kind structure associated
120       with given arena.
121
122       memkind_arena_finalize() is an implementation of the memkind "finalize"
123       operation for memory kinds that use jemalloc.  This  function  releases
124       all  resources allocated by memkind_arena_create() and it's called when
125       main() finishes or after calling exit() function.
126
127       memkind_arena_init() creates arena map with proper hooks per  specified
128       kind.
129
130       memkind_arena_update_memory_usage_policy() function changes time, which
131       determine how fast jemalloc returns unused pages back to the  operating
132       system, in other words how fast it deallocates file space.
133
134       memkind_arena_set_max_bg_threads()  sets the maximum number of internal
135       background worker threads in jemalloc.  The threads_limit specify limit
136       of background threads which can be enabled ( 0 means no limit).
137
138       memkind_arena_set_bg_threads()   enables/disables  internal  background
139       worker threads in jemalloc.
140
141       memkind_arena_stats_print() prints summary  statistics.  This  function
142       wraps jemalloc's function je_malloc_stats_print().  Uses write_cb func‐
143       tion to print the output. While providing custom writer  function,  use
144       syscall(2)  rather  than write(2) Pass NULL in order to use the default
145       write_cb function which prints the output to the stderr.  Use  cbopaque
146       parameter  in  order  to pass some data to your write_cb function. Pass
147       additional options using opts.  For more details on opts see the MEMORY
148       STATISTICS  PRINT OPTIONS section below.  Returns MEMKIND_ERROR_INVALID
149       when failed to parse options string, MEMKIND_SUCCESS on success.
150

MEMORY STATISTICS PRINT OPTIONS

152       The available options for printing statistics:
153
154       MEMKIND_STAT_PRINT_ALL
155              Print all statistics.
156
157       MEMKIND_STAT_PRINT_JSON_FORMAT
158              Print statistics in JSON format.
159
160       MEMKIND_STAT_PRINT_OMIT_GENERAL
161              Omit general information that never changes during execution.
162
163       MEMKIND_STAT_PRINT_OMIT_MERGED_ARENA
164              Omit merged arena statistics.
165
166       MEMKIND_STAT_PRINT_OMIT_DESTROYED_MERGED_ARENA
167              Omit destroyed merged arena statistics.
168
169       MEMKIND_STAT_PRINT_OMIT_PER_ARENA
170              Omit per arena statistics.
171
172       MEMKIND_STAT_PRINT_OMIT_PER_SIZE_CLASS_BINS
173              Omit per size class statistics for bins.
174
175       MEMKIND_STAT_PRINT_OMIT_PER_SIZE_CLASS_LARGE
176              Omit per size class statistics for large objects.
177
178       MEMKIND_STAT_PRINT_OMIT_MUTEX
179              Omit all mutex statistics.
180
181       MEMKIND_STAT_PRINT_OMIT_EXTENT
182              Omit extent statistics.
183
185       Copyright (C) 2014 - 2021 Intel Corporation. All rights reserved.
186

SEE ALSO

188       memkind(3),  memkind_default(3),  memkind_hbw(3),   memkind_hugetlb(3),
189       memkind_pmem(3), jemalloc(3), mbind(2), mmap(2), syscall(2), write(2)
190
191
192
193Intel Corporation                 2015-04-21                  MEMKIND_ARENA(3)
Impressum