1MEMKIND_DEFAULT(3)              MEMKIND_DEFAULT             MEMKIND_DEFAULT(3)
2
3
4

NAME

6       memkind_default - default implementations for 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       #include <memkind/internal/memkind_default.h>
13
14       Link with -lmemkind
15
16       int memkind_default_create(struct memkind *kind, struct memkind_ops *ops, const char *name);
17       int memkind_default_destroy(struct memkind *kind);
18       void *memkind_default_malloc(struct memkind *kind, size_t size);
19       void *memkind_default_calloc(struct memkind *kind, size_t num, size_t size);
20       int memkind_default_posix_memalign(struct memkind *kind, void **memptr, size_t alignment, size_t size);
21       void *memkind_default_realloc(struct memkind *kind, void *ptr, size_t size);
22       void memkind_default_free(struct memkind *kind, void *ptr);
23       void *memkind_default_mmap(struct memkind *kind, void *addr, size_t size);
24       int memkind_default_mbind(struct memkind *kind, void *ptr, size_t len);
25       int memkind_default_get_mmap_flags(struct memkind *kind, int *flags);
26       int memkind_default_get_mbind_mode(struct memkind *kind, int *mode);
27       size_t memkind_default_malloc_usable_size(struct memkind *kind, void *ptr);
28       int memkind_preferred_get_mbind_mode(struct memkind *kind, int *mode);
29       int memkind_interleave_get_mbind_mode(struct memkind *kind, int *mode);
30       int memkind_nohugepage_madvise(struct memkind *kind, void *addr, size_t size);
31       int memkind_posix_check_alignment(struct memkind *kind, size_t alignment);
32       int memkind_default_get_mbind_nodemask(struct memkind *kind, unsigned long *nodemask, unsigned long maxnode);
33       void memkind_default_init_once(void);
34       int memkind_default_get_defrag_hint(void *ptr, int *bin_util, int *run_util);
35       bool size_out_of_bounds(size_t size);
36

DESCRIPTION

38       Default  implementations for memkind operations which include a several
39       useful methods that are not part of the MEMKIND_DEFAULT kind which is a
40       fall through to the jemalloc implementation.
41
42       memkind_default_create()  implements  the  required  start up for every
43       kind. If a kind does not  point  to  this  function  directly  for  its
44       ops.create()  operation,  then the function that it points to must call
45       memkind_default_create() at its start.
46
47       memkind_default_destroy() implements the required  shutdown  for  every
48       kind.  If  a  kind  does  not  point  to this function directly for its
49       ops.destroy() operation, then the function that it points to must  call
50       memkind_default_destroy() at its end.
51
52       memkind_default_malloc()  is  a direct call through the jemalloc's mal‐
53       loc().
54
55       memkind_default_calloc() is a direct call through the  jemalloc's  cal‐
56       loc().
57
58       memkind_default_posix_memalign()  is  a  direct call through the jemal‐
59       loc's posix_memalign().
60
61       memkind_default_realloc() is a direct call through the jemalloc's real‐
62       loc().
63
64       memkind_default_free()  is a direct call through the jemalloc's free().
65       Note that this method can be called on any pointer returned by a jemal‐
66       loc  allocation,  and  in  particular,  all  of  the  arena allocations
67       described in memkind_arena(3) can use this function for freeing.
68
69       memkind_default_mmap() This calls the ops->get_mmap_flags()  operations
70       for the kind, or falls back on the default implementations if the func‐
71       tion pointers are NULL.  The results of these calls are passed  to  the
72       mmap(2)  call to allocate pages from the operating system.  The addr is
73       the hint passed through to mmap(2) and size is the size of  the  buffer
74       to  be  allocated.   The  return  value  is  the  allocated  buffer  or
75       MAP_FAILED in the case of an error.
76
77       memkind_default_mbind() makes calls the kind's ops.get_mbind_nodemask()
78       and ops.get_mbind_mode() operations to gather inputs and then calls the
79       mbind(2) system call using the results along with and  user  input  ptr
80       and len.
81
82       memkind_default_get_mmap_flags() sets flags to MAP_PRIVATE | MAP_ANONY‐
83       MOUS.  See mmap(2) for more information about these flags.
84
85       memkind_default_get_mbind_mode() sets mode to MPOL_BIND.  See  mbind(2)
86       for more information about this flag.
87
88       memkind_default_malloc_usable_size()  is  a  direct  call  through  the
89       jemalloc's malloc_usable_size().
90
91       memkind_preferred_get_mbind_mode() sets mode  to  MPOL_PREFERRED.   See
92       mbind(2) for more information about this flag.
93
94       memkind_interleave_get_mbind_mode()  sets mode to MPOL_INTERLEAVE.  See
95       mbind(2) for more information about this flag.
96
97       memkind_nohugepage_madvise() calls madvise(2) with the  MADV_NOHUGEPAGE
98       advice.  See madvise(2) for more information about this option.
99
100       memkind_posix_check_alignment()  can  be  used  to  check the alignment
101       value for memkind_posix_memalign() to ensure  that  is  abides  by  the
102       POSIX requirements: alignment must be a power of 2 at least as large as
103       sizeof(void*).
104
105       memkind_default_get_mbind_nodemask()   wraps    jemalloc's    copy_bit‐
106       mask_to_bitmask.   This  function  copies body of the bitmask structure
107       into passed pointer.
108
109       memkind_default_init_once() initializes heap manager.
110
111       memkind_default_get_defrag_hint() is a direct call through  the  jemal‐
112       loc's  get_defrag_hint().   If get_defrag_hint() is not supported func‐
113       tion returns -1.
114
115       size_out_of_bounds() returns true if given size is out of bounds,  oth‐
116       erwise will return false.
117
119       Copyright (C) 2014 - 2019 Intel Corporation. All rights reserved.
120

SEE ALSO

122       memkind(3),   memkind_arena(3),   memkind_hbw(3),   memkind_hugetlb(3),
123       memkind_pmem(3), jemalloc(3), mbind(2), mmap(2)
124
125
126
127Intel Corporation                 2015-04-21                MEMKIND_DEFAULT(3)
Impressum