mem: support unmapping pages at runtime
[dpdk.git] / lib / librte_eal / common / eal_memalloc.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017-2018 Intel Corporation
3  */
4
5 #ifndef EAL_MEMALLOC_H
6 #define EAL_MEMALLOC_H
7
8 #include <stdbool.h>
9
10 #include <rte_memory.h>
11
12 /*
13  * Allocate segment of specified page size.
14  */
15 struct rte_memseg *
16 eal_memalloc_alloc_seg(size_t page_sz, int socket);
17
18 /*
19  * Allocate `n_segs` segments.
20  *
21  * Note: `ms` can be NULL.
22  *
23  * Note: it is possible to request best-effort allocation by setting `exact` to
24  * `false`, in which case allocator will return however many pages it managed to
25  * allocate successfully.
26  */
27 int
28 eal_memalloc_alloc_seg_bulk(struct rte_memseg **ms, int n_segs, size_t page_sz,
29                 int socket, bool exact);
30
31 /*
32  * Deallocate segment
33  */
34 int
35 eal_memalloc_free_seg(struct rte_memseg *ms);
36
37 /*
38  * Deallocate `n_segs` segments. Returns 0 on successful deallocation of all
39  * segments, returns -1 on error. Any segments that could have been deallocated,
40  * will be deallocated even in case of error.
41  */
42 int
43 eal_memalloc_free_seg_bulk(struct rte_memseg **ms, int n_segs);
44
45 #endif /* EAL_MEMALLOC_H */