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