Commit | Line | Data |
---|---|---|
b7cdc182 | 1 | /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) |
7502f47a FD |
2 | * |
3 | * wrapper/mm.h | |
4 | * | |
5 | * Copyright (C) 2018 Francis Deslauriers <francis.deslauriers@efficios.com> | |
6 | */ | |
7 | ||
8 | #ifndef _LTTNG_WRAPPER_MM_H | |
9 | #define _LTTNG_WRAPPER_MM_H | |
10 | ||
11 | #include <linux/mm.h> | |
12 | #include <linux/oom.h> | |
13 | ||
2df37e95 | 14 | #include <lttng/kernel-version.h> |
7502f47a | 15 | |
939200ef MJ |
16 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,3,0)) |
17 | static inline | |
18 | void wrapper_vm_flags_set(struct vm_area_struct *vma, | |
19 | vm_flags_t flags) | |
20 | { | |
21 | vm_flags_set(vma, flags); | |
22 | } | |
23 | #else | |
24 | static inline | |
25 | void wrapper_vm_flags_set(struct vm_area_struct *vma, | |
26 | vm_flags_t flags) | |
27 | { | |
28 | vma->vm_flags |= flags; | |
29 | } | |
30 | #endif | |
31 | ||
5f4c791e | 32 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,6,0) \ |
7502f47a FD |
33 | || LTTNG_UBUNTU_KERNEL_RANGE(4,4,25,44, 4,5,0,0)) |
34 | ||
35 | /* | |
36 | * Returns true if the current estimation of the number of page available is | |
37 | * larger than the number of pages passed as parameter. | |
38 | */ | |
39 | static inline | |
40 | bool wrapper_check_enough_free_pages(unsigned long num_pages) | |
41 | { | |
42 | return num_pages < si_mem_available(); | |
43 | } | |
44 | ||
45 | #else | |
46 | ||
47 | static inline | |
48 | bool wrapper_check_enough_free_pages(unsigned long num_pages) | |
49 | { | |
50 | /* | |
51 | * The si_mem_available function is not available on this kernel. Since | |
52 | * we can't reliably know if there is enough memory available, so we | |
53 | * return true. | |
54 | */ | |
55 | return true; | |
56 | } | |
57 | #endif | |
58 | ||
5f4c791e | 59 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0)) |
7502f47a FD |
60 | static inline |
61 | void wrapper_set_current_oom_origin(void) | |
62 | { | |
63 | return set_current_oom_origin(); | |
64 | } | |
65 | ||
66 | static inline | |
67 | void wrapper_clear_current_oom_origin(void) | |
68 | { | |
69 | return clear_current_oom_origin(); | |
70 | } | |
71 | ||
5f4c791e | 72 | #else /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0)) */ |
7502f47a FD |
73 | |
74 | static inline | |
75 | void wrapper_set_current_oom_origin(void) | |
76 | { | |
77 | return; | |
78 | } | |
79 | ||
80 | static inline | |
9ca756f5 | 81 | void wrapper_clear_current_oom_origin(void) |
7502f47a FD |
82 | { |
83 | return; | |
84 | } | |
5f4c791e | 85 | #endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0)) */ |
7502f47a | 86 | #endif /* _LTTNG_WRAPPER_MM_H */ |