diff options
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.patch | 84 |
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 @@ | |||
1 | From 99b4cdcce43ad0f706120bef26fef8c628c572cf Mon Sep 17 00:00:00 2001 | ||
2 | From: Sebastien Boeuf <sebastien.boeuf@intel.com> | ||
3 | Date: Mon, 23 Jan 2017 15:03:52 -0800 | ||
4 | Subject: [PATCH 151/154] mm: Export do_madvise() | ||
5 | |||
6 | Combined with some interesting flags madvise() system call | ||
7 | allows to free memory more smartly and more efficiently than | ||
8 | we could do with a simple free(). The issue is that is not | ||
9 | available for kernel modules that could need it. | ||
10 | |||
11 | In order to solve this lack of support, this patch exports | ||
12 | do_madvise() so as to make it available to the entire kernel. | ||
13 | The already existing madvise() system call is unchanged and | ||
14 | now relies on this new do_madvise() function. | ||
15 | |||
16 | Suggested-by: Arjan van de Ven <arjan.van.de.ven@intel.com> | ||
17 | Signed-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 | |||
23 | diff --git a/include/linux/mm.h b/include/linux/mm.h | ||
24 | index 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 */ | ||
35 | diff --git a/mm/madvise.c b/mm/madvise.c | ||
36 | index 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 | -- | ||
83 | 2.12.1 | ||
84 | |||