1MEMKIND_DEFAULT(3) MEMKIND_DEFAULT MEMKIND_DEFAULT(3)
2
3
4
6 memkind_default.h - default implementations for memkind operations.
7 Note: This is EXEPRIMENTAL API. The functionality and the header file
8 itself can be changed (including non-backward compatible changes), or
9 remove.
10
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 int memkind_preferred_get_mbind_mode(struct memkind *kind, int *mode);
28 int memkind_interleave_get_mbind_mode(struct memkind *kind, int *mode);
29 int memkind_nohugepage_madvise(struct memkind *kind, void *addr, size_t size);
30 int memkind_posix_check_alignment(struct memkind *kind, size_t alignment);
31
33 Default implementations for memkind operations which include a several
34 useful methods that are not part of the MEMKIND_DEFAULT kind which is a
35 fall through to the jemalloc implementation.
36
37 memkind_default_create() implements the required start up for every
38 kind. If a kind does not point to this function directly for its
39 ops.create() operation, then the function that it points to must call
40 memkind_default_create() at its start.
41
42 memkind_default_destroy() implements the required shutdown for every
43 kind. If a kind does not point to this function directly for its
44 ops.destroy() operation, then the function that it points to must call
45 memkind_default_destroy() at its end.
46
47 memkind_default_malloc() is a direct call through to jemalloc's mal‐
48 loc().
49
50 memkind_default_calloc() is a direct call through to jemalloc's cal‐
51 loc().
52
53 memkind_default_posix_memalign() is a direct call through to jemalloc's
54 posix_memalign().
55
56 memkind_default_realloc() is a direct call through to jemalloc's real‐
57 loc().
58
59 memkind_default_free(). is a direct call through to jemalloc's free().
60 Note that this method can be called on any pointer returned by a jemal‐
61 loc allocation, and in particular, all of the arena allocations
62 described in memkind_arena(3) can use this function for freeing.
63
64 memkind_default_mmap() This calls the ops->get_mmap_flags() operations
65 for the kind, or falls back on the default implementations if the func‐
66 tion pointers are NULL. The results of these calls are passed to the
67 mmap(2) call to allocate pages from the operating system. The addr is
68 the hint passed through to mmap(2) and size is the size of the buffer
69 to be allocated. The return value is the allocated buffer or
70 MAP_FAILED in the case of an error.
71
72 memkind_default_mbind() makes calls the kind's ops.get_mbind_nodemask()
73 and ops.get_mbind_mode() operations to gather inputs and then calls the
74 mbind(2) system call using the results along with and user input ptr
75 and len.
76
77 memkind_default_get_mmap_flags() sets flags to MAP_PRIVATE | MAP_ANONY‐
78 MOUS. See mmap(2) for more information about these flags.
79
80 memkind_default_get_mbind_mode() sets mode to MPOL_BIND. See mbind(2)
81 for more information about this flag.
82
83 memkind_preferred_get_mbind_mode() sets mode to MPOL_PREFERRED. See
84 mbind(2) for more information about this flag.
85
86 memkind_interleave_get_mbind_mode() sets mode to MPOL_INTERLEAVE. See
87 mbind(2) for more information about this flag.
88
89 memkind_nohugepage_madvise() calls madvise(2) with the MADV_NOHUGEPAGE
90 advice. See madvise(2) for more information about this option.
91
92 memkind_posix_check_alignment() can be used to check the alignment
93 value for memkind_posix_memalign() to ensure that is abides by the
94 POSIX requirements: alignment must be a power of 2 at least as large as
95 sizeof(void *).
96
98 Copyright (C) 2014 - 2017 Intel Corporation. All rights reserved.
99
101 memkind(3), memkind_arena(3), memkind_hbw(3), memkind_hugetlb(3),
102 memkind_pmem(3), jemalloc(3), mbind(2), mmap(2)
103
104
105
106Intel Corporation 2015-04-21 MEMKIND_DEFAULT(3)