Commit 79ad784
mm/khugepaged: fix GUP-fast interaction by sending IPI
commit 2ba99c5 upstream.
Since commit 70cbc3c ("mm: gup: fix the fast GUP race against THP
collapse"), the lockless_pages_from_mm() fastpath rechecks the pmd_t to
ensure that the page table was not removed by khugepaged in between.
However, lockless_pages_from_mm() still requires that the page table is
not concurrently freed. Fix it by sending IPIs (if the architecture uses
semi-RCU-style page table freeing) before freeing/reusing page tables.
Link: https://lkml.kernel.org/r/[email protected]
Link: https://lkml.kernel.org/r/[email protected]
Link: https://lkml.kernel.org/r/[email protected]
Fixes: ba76149 ("thp: khugepaged")
Signed-off-by: Jann Horn <[email protected]>
Reviewed-by: Yang Shi <[email protected]>
Acked-by: David Hildenbrand <[email protected]>
Cc: John Hubbard <[email protected]>
Cc: Peter Xu <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
[manual backport: two of the three places in khugepaged that can free
ptes were refactored into a common helper between 5.15 and 6.0]
Signed-off-by: Jann Horn <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>1 parent d15cd6d commit 79ad784
3 files changed
+8
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
| 210 | + | |
| 211 | + | |
210 | 212 | | |
211 | 213 | | |
212 | 214 | | |
213 | 215 | | |
214 | 216 | | |
215 | 217 | | |
| 218 | + | |
| 219 | + | |
216 | 220 | | |
217 | 221 | | |
218 | 222 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1156 | 1156 | | |
1157 | 1157 | | |
1158 | 1158 | | |
| 1159 | + | |
1159 | 1160 | | |
1160 | 1161 | | |
1161 | 1162 | | |
| |||
1537 | 1538 | | |
1538 | 1539 | | |
1539 | 1540 | | |
| 1541 | + | |
1540 | 1542 | | |
1541 | 1543 | | |
1542 | 1544 | | |
| |||
1623 | 1625 | | |
1624 | 1626 | | |
1625 | 1627 | | |
| 1628 | + | |
1626 | 1629 | | |
1627 | 1630 | | |
1628 | 1631 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
| 142 | + | |
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
166 | | - | |
167 | | - | |
168 | 166 | | |
169 | 167 | | |
170 | 168 | | |
| |||
0 commit comments