]>
Commit | Line | Data |
---|---|---|
1d545142 JR |
1 | From 6fe0c6bd4b3bbac5cf868b927973255961b28ff4 Mon Sep 17 00:00:00 2001 |
2 | From: Paolo Pisati <paolo.pisati@canonical.com> | |
3 | Date: Tue, 18 Jul 2023 12:14:47 +0000 | |
4 | Subject: [PATCH 1/2] Linux 6.5: garbage collect all references to | |
5 | get_user_pages_remote() | |
6 | ||
7 | Upstream commit ca5e863233e8f6acd1792fd85d6bc2729a1b2c10 "mm/gup: remove | |
8 | vmas parameter from get_user_pages_remote()" changed the API: since we | |
9 | reference get_user_pages_remote() (but don't use it anywhere), garbage | |
10 | collect all reference. | |
11 | ||
12 | Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com> | |
13 | --- | |
14 | common/inc/nv-mm.h | 99 ------------- | |
15 | conftest.sh | 130 ------------------ | |
16 | 2 files changed, 229 deletions(-) | |
17 | ||
18 | diff --git a/kernel/common/inc/nv-mm.h b/kernel/common/inc/nv-mm.h | |
19 | index aec55b0b..51d0df4a 100644 | |
20 | --- a/kernel/common/inc/nv-mm.h | |
21 | +++ b/kernel/common/inc/nv-mm.h | |
22 | @@ -98,105 +98,6 @@ typedef int vm_fault_t; | |
23 | #endif | |
24 | #endif | |
25 | ||
26 | -/* | |
27 | - * get_user_pages_remote() was added by commit 1e9877902dc7 | |
28 | - * ("mm/gup: Introduce get_user_pages_remote()") in v4.6 (2016-02-12). | |
29 | - * | |
30 | - * The very next commit cde70140fed8 ("mm/gup: Overload get_user_pages() | |
31 | - * functions") deprecated the 8-argument version of get_user_pages for the | |
32 | - * non-remote case (calling get_user_pages with current and current->mm). | |
33 | - * | |
34 | - * The guidelines are: call NV_GET_USER_PAGES_REMOTE if you need the 8-argument | |
35 | - * version that uses something other than current and current->mm. Use | |
36 | - * NV_GET_USER_PAGES if you are refering to current and current->mm. | |
37 | - * | |
38 | - * Note that get_user_pages_remote() requires the caller to hold a reference on | |
39 | - * the task_struct (if non-NULL and if this API has tsk argument) and the mm_struct. | |
40 | - * This will always be true when using current and current->mm. If the kernel passes | |
41 | - * the driver a vma via driver callback, the kernel holds a reference on vma->vm_mm | |
42 | - * over that callback. | |
43 | - * | |
44 | - * get_user_pages_remote() write/force parameters were replaced | |
45 | - * with gup_flags by commit 9beae1ea8930 ("mm: replace get_user_pages_remote() | |
46 | - * write/force parameters with gup_flags") in v4.9 (2016-10-13). | |
47 | - * | |
48 | - * get_user_pages_remote() added 'locked' parameter by commit 5b56d49fc31d | |
49 | - * ("mm: add locked parameter to get_user_pages_remote()") in | |
50 | - * v4.10 (2016-12-14). | |
51 | - * | |
52 | - * get_user_pages_remote() removed 'tsk' parameter by | |
53 | - * commit 64019a2e467a ("mm/gup: remove task_struct pointer for | |
54 | - * all gup code") in v5.9-rc1 (2020-08-11). | |
55 | - * | |
56 | - */ | |
57 | - | |
58 | -#if defined(NV_GET_USER_PAGES_REMOTE_PRESENT) | |
59 | - #if defined(NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS) | |
60 | - #define NV_GET_USER_PAGES_REMOTE get_user_pages_remote | |
61 | - #else | |
62 | - static inline long NV_GET_USER_PAGES_REMOTE(struct task_struct *tsk, | |
63 | - struct mm_struct *mm, | |
64 | - unsigned long start, | |
65 | - unsigned long nr_pages, | |
66 | - int write, | |
67 | - int force, | |
68 | - struct page **pages, | |
69 | - struct vm_area_struct **vmas) | |
70 | - { | |
71 | - unsigned int flags = 0; | |
72 | - | |
73 | - if (write) | |
74 | - flags |= FOLL_WRITE; | |
75 | - if (force) | |
76 | - flags |= FOLL_FORCE; | |
77 | - | |
78 | - #if defined(NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG) | |
79 | - #if defined (NV_GET_USER_PAGES_REMOTE_HAS_TSK_ARG) | |
80 | - return get_user_pages_remote(tsk, mm, start, nr_pages, flags, | |
81 | - pages, vmas, NULL); | |
82 | - #else | |
83 | - return get_user_pages_remote(mm, start, nr_pages, flags, | |
84 | - pages, vmas, NULL); | |
85 | - #endif | |
86 | - | |
87 | - #else | |
88 | - | |
89 | - return get_user_pages_remote(tsk, mm, start, nr_pages, flags, | |
90 | - pages, vmas); | |
91 | - | |
92 | - #endif | |
93 | - | |
94 | - } | |
95 | - #endif | |
96 | -#else | |
97 | - #if defined(NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS) | |
98 | - #define NV_GET_USER_PAGES_REMOTE NV_GET_USER_PAGES | |
99 | - #else | |
100 | - #include <linux/mm.h> | |
101 | - #include <linux/sched.h> | |
102 | - | |
103 | - static inline long NV_GET_USER_PAGES_REMOTE(struct task_struct *tsk, | |
104 | - struct mm_struct *mm, | |
105 | - unsigned long start, | |
106 | - unsigned long nr_pages, | |
107 | - int write, | |
108 | - int force, | |
109 | - struct page **pages, | |
110 | - struct vm_area_struct **vmas) | |
111 | - { | |
112 | - unsigned int flags = 0; | |
113 | - | |
114 | - if (write) | |
115 | - flags |= FOLL_WRITE; | |
116 | - if (force) | |
117 | - flags |= FOLL_FORCE; | |
118 | - | |
119 | - return get_user_pages(tsk, mm, start, nr_pages, flags, pages, vmas); | |
120 | - } | |
121 | - #endif | |
122 | -#endif | |
123 | - | |
124 | - | |
125 | /* | |
126 | * The .virtual_address field was effectively renamed to .address, by these | |
127 | * two commits: | |
128 | diff --git a/kernel/conftest.sh b/kernel/conftest.sh | |
129 | index 24daa850..abe435ff 100755 | |
130 | --- a/kernel/conftest.sh | |
131 | +++ b/kernel/conftest.sh | |
132 | @@ -3081,136 +3081,6 @@ compile_test() { | |
133 | return | |
134 | ;; | |
135 | ||
136 | - get_user_pages_remote) | |
137 | - # | |
138 | - # Determine if the function get_user_pages_remote() is | |
139 | - # present and has write/force/locked/tsk parameters. | |
140 | - # | |
141 | - # get_user_pages_remote() was added by: | |
142 | - # 2016 Feb 12: 1e9877902dc7e11d2be038371c6fbf2dfcd469d7 | |
143 | - # | |
144 | - # get_user_pages[_remote]() write/force parameters | |
145 | - # replaced with gup_flags: | |
146 | - # 2016 Oct 12: 768ae309a96103ed02eb1e111e838c87854d8b51 | |
147 | - # 2016 Oct 12: 9beae1ea89305a9667ceaab6d0bf46a045ad71e7 | |
148 | - # | |
149 | - # get_user_pages_remote() added 'locked' parameter | |
150 | - # 2016 Dec 14:5b56d49fc31dbb0487e14ead790fc81ca9fb2c99 | |
151 | - # | |
152 | - # get_user_pages_remote() removed 'tsk' parameter by | |
153 | - # commit 64019a2e467a ("mm/gup: remove task_struct pointer for | |
154 | - # all gup code") in v5.9-rc1 (2020-08-11). | |
155 | - # | |
156 | - # conftest #1: check if get_user_pages_remote() is available | |
157 | - # return if not available. | |
158 | - # Fall through to conftest #2 if it is present | |
159 | - | |
160 | - echo "$CONFTEST_PREAMBLE | |
161 | - #include <linux/mm.h> | |
162 | - void conftest_get_user_pages_remote(void) { | |
163 | - get_user_pages_remote(); | |
164 | - }" > conftest$$.c | |
165 | - | |
166 | - $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1 | |
167 | - rm -f conftest$$.c | |
168 | - | |
169 | - if [ -f conftest$$.o ]; then | |
170 | - echo "#undef NV_GET_USER_PAGES_REMOTE_PRESENT" | append_conftest "functions" | |
171 | - echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_TSK_ARG" | append_conftest "functions" | |
172 | - echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions" | |
173 | - echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions" | |
174 | - rm -f conftest$$.o | |
175 | - return | |
176 | - fi | |
177 | - | |
178 | - # conftest #2: check if get_user_pages_remote() has write and | |
179 | - # force arguments. Return if these arguments are present | |
180 | - # Fall through to conftest #3 if these args are absent. | |
181 | - echo "#define NV_GET_USER_PAGES_REMOTE_PRESENT" | append_conftest "functions" | |
182 | - echo "$CONFTEST_PREAMBLE | |
183 | - #include <linux/mm.h> | |
184 | - long get_user_pages_remote(struct task_struct *tsk, | |
185 | - struct mm_struct *mm, | |
186 | - unsigned long start, | |
187 | - unsigned long nr_pages, | |
188 | - int write, | |
189 | - int force, | |
190 | - struct page **pages, | |
191 | - struct vm_area_struct **vmas) { | |
192 | - return 0; | |
193 | - }" > conftest$$.c | |
194 | - | |
195 | - $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1 | |
196 | - rm -f conftest$$.c | |
197 | - | |
198 | - if [ -f conftest$$.o ]; then | |
199 | - echo "#define NV_GET_USER_PAGES_REMOTE_HAS_TSK_ARG" | append_conftest "functions" | |
200 | - echo "#define NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions" | |
201 | - echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions" | |
202 | - rm -f conftest$$.o | |
203 | - return | |
204 | - fi | |
205 | - | |
206 | - echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions" | |
207 | - | |
208 | - # | |
209 | - # conftest #3: check if get_user_pages_remote() has locked argument | |
210 | - # Return if these arguments are present. Fall through to conftest #4 | |
211 | - # if these args are absent. | |
212 | - # | |
213 | - echo "$CONFTEST_PREAMBLE | |
214 | - #include <linux/mm.h> | |
215 | - long get_user_pages_remote(struct task_struct *tsk, | |
216 | - struct mm_struct *mm, | |
217 | - unsigned long start, | |
218 | - unsigned long nr_pages, | |
219 | - unsigned int gup_flags, | |
220 | - struct page **pages, | |
221 | - struct vm_area_struct **vmas, | |
222 | - int *locked) { | |
223 | - return 0; | |
224 | - }" > conftest$$.c | |
225 | - | |
226 | - $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1 | |
227 | - rm -f conftest$$.c | |
228 | - | |
229 | - if [ -f conftest$$.o ]; then | |
230 | - echo "#define NV_GET_USER_PAGES_REMOTE_HAS_TSK_ARG" | append_conftest "functions" | |
231 | - echo "#define NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions" | |
232 | - rm -f conftest$$.o | |
233 | - return | |
234 | - fi | |
235 | - | |
236 | - # | |
237 | - # conftest #4: check if get_user_pages_remote() does not take | |
238 | - # tsk argument. | |
239 | - # | |
240 | - echo "$CONFTEST_PREAMBLE | |
241 | - #include <linux/mm.h> | |
242 | - long get_user_pages_remote(struct mm_struct *mm, | |
243 | - unsigned long start, | |
244 | - unsigned long nr_pages, | |
245 | - unsigned int gup_flags, | |
246 | - struct page **pages, | |
247 | - struct vm_area_struct **vmas, | |
248 | - int *locked) { | |
249 | - return 0; | |
250 | - }" > conftest$$.c | |
251 | - | |
252 | - $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1 | |
253 | - rm -f conftest$$.c | |
254 | - | |
255 | - if [ -f conftest$$.o ]; then | |
256 | - echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_TSK_ARG" | append_conftest "functions" | |
257 | - echo "#define NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions" | |
258 | - rm -f conftest$$.o | |
259 | - else | |
260 | - | |
261 | - echo "#define NV_GET_USER_PAGES_REMOTE_HAS_TSK_ARG" | append_conftest "functions" | |
262 | - echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions" | |
263 | - fi | |
264 | - ;; | |
265 | - | |
266 | usleep_range) | |
267 | # | |
268 | # Determine if the function usleep_range() is present. | |
269 | -- | |
270 | 2.40.1 | |
271 |