1MEMKIND_DEFAULT(3) MEMKIND_DEFAULT MEMKIND_DEFAULT(3)
2
3
4
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
12 int memkind_default_create(struct memkind *kind, struct memkind_ops
13 *ops, const char *name);
14 int memkind_default_destroy(struct memkind *kind);
15 void *memkind_default_malloc(struct memkind *kind, size_t size);
16 void *memkind_default_calloc(struct memkind *kind, size_t num, size_t
17 size);
18 int memkind_default_posix_memalign(struct memkind *kind, void **memptr,
19 size_t alignment, size_t size);
20 void *memkind_default_realloc(struct memkind *kind, void *ptr, size_t
21 size);
22 void memkind_default_free(struct memkind *kind, void *ptr);
23 void *memkind_default_mmap(struct memkind *kind, void *addr, size_t
24 size);
25 int memkind_default_mbind(struct memkind *kind, void *ptr, size_t len);
26 int memkind_default_get_mmap_flags(struct memkind *kind, int *flags);
27 int memkind_default_get_mbind_mode(struct memkind *kind, int *mode);
28 size_t memkind_default_malloc_usable_size(struct memkind *kind, void
29 *ptr);
30 int memkind_preferred_get_mbind_mode(struct memkind *kind, int *mode);
31 int memkind_interleave_get_mbind_mode(struct memkind *kind, int *mode);
32 int memkind_nohugepage_madvise(struct memkind *kind, void *addr, size_t
33 size);
34 int memkind_posix_check_alignment(struct memkind *kind, size_t align‐
35 ment);
36 int memkind_default_get_mbind_nodemask(struct memkind *kind, unsigned
37 long *nodemask, unsigned long maxnode);
38 void memkind_default_init_once(void);
39 bool size_out_of_bounds(size_t size);
40
42 Default implementations for memkind operations which include a several
43 useful methods that are not part of the MEMKIND_DEFAULT kind which is a
44 fall through to the jemalloc implementation.
45
46 memkind_default_create() implements the required start up for every
47 kind. If a kind does not point to this function directly for its
48 ops.create() operation, then the function that it points to must call
49 memkind_default_create() at its start.
50
51 memkind_default_destroy() implements the required shutdown for every
52 kind. If a kind does not point to this function directly for its
53 ops.destroy() operation, then the function that it points to must call
54 memkind_default_destroy() at its end.
55
56 memkind_default_malloc() is a direct call through the jemalloc's mal‐
57 loc().
58
59 memkind_default_calloc() is a direct call through the jemalloc's cal‐
60 loc().
61
62 memkind_default_posix_memalign() is a direct call through the jemal‐
63 loc's posix_memalign().
64
65 memkind_default_realloc() is a direct call through the jemalloc's real‐
66 loc().
67
68 memkind_default_free() is a direct call through the jemalloc's free().
69 Note that this method can be called on any pointer returned by a jemal‐
70 loc allocation, and in particular, all of the arena allocations
71 described in memkind_arena(3) can use this function for freeing.
72
73 memkind_default_mmap() This calls the ops->get_mmap_flags() operations
74 for the kind, or falls back on the default implementations if the func‐
75 tion pointers are NULL. The results of these calls are passed to the
76 mmap(2) call to allocate pages from the operating system. The addr is
77 the hint passed through to mmap(2) and size is the size of the buffer
78 to be allocated. The return value is the allocated buffer or
79 MAP_FAILED in the case of an error.
80
81 memkind_default_mbind() makes calls the kind's ops.get_mbind_nodemask()
82 and ops.get_mbind_mode() operations to gather inputs and then calls the
83 mbind(2) system call using the results along with and user input ptr
84 and len.
85
86 memkind_default_get_mmap_flags() sets flags to MAP_PRIVATE | MAP_ANONY‐
87 MOUS. See mmap(2) for more information about these flags.
88
89 memkind_default_get_mbind_mode() sets mode to MPOL_BIND. See mbind(2)
90 for more information about this flag.
91
92 memkind_default_malloc_usable_size() is a direct call through the
93 jemalloc's malloc_usable_size().
94
95 memkind_preferred_get_mbind_mode() sets mode to MPOL_PREFERRED. See
96 mbind(2) for more information about this flag.
97
98 memkind_interleave_get_mbind_mode() sets mode to MPOL_INTERLEAVE. See
99 mbind(2) for more information about this flag.
100
101 memkind_nohugepage_madvise() calls madvise(2) with the MADV_NOHUGEPAGE
102 advice. See madvise(2) for more information about this option.
103
104 memkind_posix_check_alignment() can be used to check the alignment
105 value for memkind_posix_memalign() to ensure that is abides by the
106 POSIX requirements: alignment must be a power of 2 at least as large as
107 sizeof(void*).
108
109 memkind_default_get_mbind_nodemask() wraps jemalloc's copy_bit‐
110 mask_to_bitmask. This function copies body of the bitmask structure
111 into passed pointer.
112
113 memkind_default_init_once() initializes heap manager.
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
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)