-
Notifications
You must be signed in to change notification settings - Fork 60
/
0151-mm-Export-do_madvise.patch-
84 lines (76 loc) · 3.06 KB
/
0151-mm-Export-do_madvise.patch-
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
From fc4ee73f68d0e9da4ba61112416849c18d933882 Mon Sep 17 00:00:00 2001
From: Sebastien Boeuf <sebastien.boeuf@intel.com>
Date: Mon, 23 Jan 2017 15:03:52 -0800
Subject: [PATCH 151/154] mm: Export do_madvise()
Combined with some interesting flags madvise() system call
allows to free memory more smartly and more efficiently than
we could do with a simple free(). The issue is that is not
available for kernel modules that could need it.
In order to solve this lack of support, this patch exports
do_madvise() so as to make it available to the entire kernel.
The already existing madvise() system call is unchanged and
now relies on this new do_madvise() function.
Suggested-by: Arjan van de Ven <arjan.van.de.ven@intel.com>
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
---
include/linux/mm.h | 2 ++
mm/madvise.c | 25 +++++++++++++++++++++----
2 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 43edf659453b..c3153e9ee7ea 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2603,5 +2603,7 @@ void __init setup_nr_node_ids(void);
static inline void setup_nr_node_ids(void) {}
#endif
+extern int do_madvise(unsigned long start, size_t len_in, int behavior);
+
#endif /* __KERNEL__ */
#endif /* _LINUX_MM_H */
diff --git a/mm/madvise.c b/mm/madvise.c
index 375cf32087e4..3798dd68692e 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -730,9 +730,7 @@ madvise_behavior_valid(int behavior)
}
/*
- * The madvise(2) system call.
- *
- * Applications can use madvise() to advise the kernel how it should
+ * Kernel modules can use do_madvise() to advise the kernel how it should
* handle paging I/O in this VM area. The idea is to help the kernel
* use appropriate read-ahead and caching techniques. The information
* provided is advisory only, and can be safely disregarded by the
@@ -790,7 +788,7 @@ madvise_behavior_valid(int behavior)
* -EBADF - map exists, but area maps something that isn't a file.
* -EAGAIN - a kernel resource was temporarily unavailable.
*/
-SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
+int do_madvise(unsigned long start, size_t len_in, int behavior)
{
unsigned long end, tmp;
struct vm_area_struct *vma, *prev;
@@ -885,3 +883,22 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
return error;
}
+EXPORT_SYMBOL_GPL(do_madvise);
+
+/*
+ * The madvise(2) system call.
+ *
+ * Applications can use madvise() system call to advise the kernel how
+ * it should handle paging I/O in this VM area. The idea is to help
+ * the kernel use appropriate read-ahead and caching techniques. The
+ * information provided is advisory only, and can be safely disregarded
+ * by the kernel without affecting the correct operation of the application.
+ *
+ * behavior values are the same than the ones defined in madvise()
+ *
+ * return values are the same than the ones defined in madvise()
+ */
+SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
+{
+ return do_madvise(start, len_in, behavior);
+}
--
2.15.0