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); int memkind_arena_create_map(struct  memkind  *kind,
14       extent_hooks_t   *hooks);   int   memkind_arena_destroy(struct  memkind
15       *kind); void *memkind_arena_malloc(struct memkind *kind, size_t  size);
16       void  *memkind_arena_calloc(struct  memkind  *kind,  size_t num, size_t
17       size);  int  memkind_arena_posix_memalign(struct  memkind  *kind,  void
18       **memptr,  size_t  alignment,  size_t  size); void *memkind_arena_real‐
19       loc(struct   memkind   *kind,   void   *ptr,   size_t    size);    void
20       *memkind_arena_realloc_with_kind_detect(void  *ptr,  size_t  size); int
21       memkind_thread_get_arena(struct memkind  *kind,  unsigned  int  *arena,
22       size_t size); int memkind_bijective_get_arena(struct memkind *kind, un‐
23       signed int *arena, size_t size); struct memkind  *get_kind_by_arena(un‐
24       signed   arena_ind);   struct  memkind  *memkind_arena_detect_kind(void
25       *ptr);   int   memkind_arena_finalize(struct   memkind   *kind);   void
26       memkind_arena_init(struct          memkind         *kind);         void
27       memkind_arena_free(struct   memkind    *kind,    void    *ptr);    void
28       memkind_arena_free_with_kind_detect(void          *ptr);         size_t
29       memkind_arena_malloc_usable_size(void  *ptr);   int   memkind_arena_up‐
30       date_memory_usage_policy(struct memkind *kind, memkind_mem_usage_policy
31       policy);       int       memkind_arena_enable_background_threads(size_t
32       threads_limit);
33

DESCRIPTION

35       This  header  file is a collection of functions can be used to populate
36       the memkind operations structure for memory kinds that use jemalloc.
37
38       memkind_arena_create() is an implementation of the memkind "create" op‐
39       eration  for  memory  kinds  that use jemalloc.  This calls memkind_de‐
40       fault_create() (see memkind_default(3)) followed by  memkind_arena_cre‐
41       ate_map() described below.
42
43       memkind_arena_create_map()  creates the arena_map array for the memkind
44       structure  pointed  to  by  kind  which   can   be   indexed   by   the
45       ops.get_arena()  function  from  the  kind's  operations.  If get_arena
46       points memkind_thread_get_arena() then there will be four  arenas  cre‐
47       ated  for  each  processor,  and  if get_arena points to memkind_bijec‐
48       tive_get_arena() then just one arena is created.
49
50       memkind_arena_destroy() is an implementation of the  memkind  "destroy"
51       operation for memory kinds that use jemalloc.  This releases all of the
52       resources allocated by memkind_arena_create().
53
54       memkind_arena_malloc() is an implementation of the memkind "malloc" op‐
55       eration  for memory kinds that use jemalloc.  This allocates memory us‐
56       ing the arenas created by memkind_arena_create() through the jemalloc's
57       mallocx()  interface.  It uses the memkind "get_arena" operation to se‐
58       lect the arena.
59
60       memkind_arena_calloc() is an implementation of the memkind "calloc" op‐
61       eration  for memory kinds that use jemalloc.  This allocates memory us‐
62       ing the arenas created by memkind_arena_create() through the jemalloc's
63       mallocx()  interface.  It uses the memkind "get_arena" operation to se‐
64       lect the arena.
65
66       memkind_arena_posix_memalign() is  an  implementation  of  the  memkind
67       "posix_memalign"  operation  for  memory kinds that use jemalloc.  This
68       allocates memory using the  arenas  created  by  memkind_arena_create()
69       through  the  jemalloc's  mallocx()  interface.   It  uses  the memkind
70       "get_arena" operation to select the arena.  The POSIX standard requires
71       that  posix_memalign(3)  may  not set errno however the jemalloc's mal‐
72       locx() routine may.  In an attempt to abide by the  standard  errno  is
73       recorded  before  calling jemalloc's mallocx() and then reset after the
74       call.
75
76       memkind_arena_realloc() is an implementation of the  memkind  "realloc"
77       operation  for  memory  kinds that use jemalloc.  This allocates memory
78       using the arenas created by memkind_arena_create() through  the  jemal‐
79       loc's  mallocx()  interface.  It uses the memkind "get_arena" operation
80       to select the arena.
81
82       memkind_arena_realloc_with_kind_detect() function will look up for kind
83       associated  to the allocated memory referenced by ptr and call (depend‐
84       ing on kind  value)  memkind_arena_realloc()  or  memkind_default_real‐
85       loc().
86
87       memkind_thread_get_arena()  retrieves  the arena index that is bound to
88       to the calling thread based on a hash of its thread ID.  The arena  in‐
89       dex  can  be  used with the MALLOCX_ARENA macro to set flags for jemal‐
90       loc's mallocx().
91
92       memkind_bijective_arena_get_arena() retrieves the  arena  index  to  be
93       used  with  the  MALLOCX_ARENA  macro  to set flags for jemalloc's mal‐
94       locx().  Use of this operation implies that only one arena is used  for
95       the kind.
96
97       memkind_arena_free()  is an implementation of the memkind "free" opera‐
98       tion for memory kinds that use jemalloc.  It causes the allocated  mem‐
99       ory referenced by ptr, which must have been returned by a previous call
100       to memkind_arena_malloc(), memkind_arena_calloc() or  memkind_arena_re‐
101       alloc()  to  be  made  available  for  future allocations.  It uses the
102       memkind "get_arena" operation to select the arena.
103
104       memkind_arena_free_with_kind_detect() function will look  up  for  kind
105       associated   to  the  allocated  memory  referenced  by  ptr  and  call
106       memkind_arena_free().
107
108       memkind_arena_detect_kind() returns pointer to  memory  kind  structure
109       associated with given allocated memory referenced by ptr.
110
111       get_kind_by_arena() returns pointer to memory kind structure associated
112       with given arena.
113
114       memkind_arena_malloc_usable_size() is an implementation of the  memkind
115       "usable_size" operation for memory kinds that use jemalloc.
116
117       memkind_arena_finalize() is an implementation of the memkind "finalize"
118       operation for memory kinds that use jemalloc.  This  function  releases
119       all  resources allocated by memkind_arena_create() and it's called when
120       main() finishes or after calling exit() function.
121
122       memkind_arena_init() creates arena map with proper hooks per  specified
123       kind.
124
125       memkind_arena_update_memory_usage_policy() function changes time, which
126       determine how fast jemalloc returns unused pages back to the  operating
127       system, in other words how fast it deallocates file space.
128
129       memkind_arena_enable_background_threads()  enables  internal background
130       worker threads in jemalloc.  The threads_limit specify limit  of  back‐
131       ground threads which will be enabled ( 0 means no limit).
132
134       Copyright (C) 2014 - 2020 Intel Corporation. All rights reserved.
135

SEE ALSO

137       memkind(3),   memkind_default(3),  memkind_hbw(3),  memkind_hugetlb(3),
138       memkind_pmem(3), jemalloc(3), mbind(2), mmap(2)
139
140
141
142Intel Corporation                 2015-04-21                  MEMKIND_ARENA(3)
Impressum