Fix: Build on CentOS 9 Stream 2024-06
[lttng-modules.git] / include / wrapper / mm.h
1 /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
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
14 #include <lttng/kernel-version.h>
15
16 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,3,0) || \
17 LTTNG_RHEL_KERNEL_RANGE(5,14,0,452,0,0, 5,15,0,0,0,0))
18 static inline
19 void wrapper_vm_flags_set(struct vm_area_struct *vma,
20 vm_flags_t flags)
21 {
22 vm_flags_set(vma, flags);
23 }
24 #else
25 static inline
26 void wrapper_vm_flags_set(struct vm_area_struct *vma,
27 vm_flags_t flags)
28 {
29 vma->vm_flags |= flags;
30 }
31 #endif
32
33 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,6,0) \
34 || LTTNG_UBUNTU_KERNEL_RANGE(4,4,25,44, 4,5,0,0))
35
36 /*
37 * Returns true if the current estimation of the number of page available is
38 * larger than the number of pages passed as parameter.
39 */
40 static inline
41 bool wrapper_check_enough_free_pages(unsigned long num_pages)
42 {
43 return num_pages < si_mem_available();
44 }
45
46 #else
47
48 static inline
49 bool wrapper_check_enough_free_pages(unsigned long num_pages)
50 {
51 /*
52 * The si_mem_available function is not available on this kernel. Since
53 * we can't reliably know if there is enough memory available, so we
54 * return true.
55 */
56 return true;
57 }
58 #endif
59
60 #endif /* _LTTNG_WRAPPER_MM_H */
This page took 0.032753 seconds and 5 git commands to generate.