Commit f822a9a
mm: optimize mremap() by PTE batching
Use folio_pte_batch() to optimize move_ptes(). On arm64, if the ptes are
painted with the contig bit, then ptep_get() will iterate through all 16
entries to collect a/d bits. Hence this optimization will result in a 16x
reduction in the number of ptep_get() calls. Next, ptep_get_and_clear()
will eventually call contpte_try_unfold() on every contig block, thus
flushing the TLB for the complete large folio range. Instead, use
get_and_clear_full_ptes() so as to elide TLBIs on each contig block, and
only do them on the starting and ending contig block.
For split folios, there will be no pte batching; nr_ptes will be 1. For
pagetable splitting, the ptes will still point to the same large folio;
for arm64, this results in the optimization described above, and for other
arches (including the general case), a minor improvement is expected due
to a reduction in the number of function calls.
Link: https://lkml.kernel.org/r/20250610035043.75448-3-dev.jain@arm.com
Signed-off-by: Dev Jain <dev.jain@arm.com>
Reviewed-by: Barry Song <baohua@kernel.org>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Reviewed-by: Pedro Falcato <pfalcato@suse.de>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Bang Li <libang.li@antgroup.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: bibo mao <maobibo@loongson.cn>
Cc: David Hildenbrand <david@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jann Horn <jannh@google.com>
Cc: Lance Yang <ioworker0@gmail.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Peter Xu <peterx@redhat.com>
Cc: Qi Zheng <zhengqi.arch@bytedance.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Yang Shi <yang@os.amperecomputing.com>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>1 parent 94dab12 commit f822a9a
1 file changed
+32
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
173 | 190 | | |
174 | 191 | | |
175 | 192 | | |
176 | 193 | | |
177 | 194 | | |
178 | 195 | | |
179 | 196 | | |
180 | | - | |
| 197 | + | |
181 | 198 | | |
182 | 199 | | |
183 | 200 | | |
184 | 201 | | |
185 | 202 | | |
186 | 203 | | |
187 | 204 | | |
| 205 | + | |
| 206 | + | |
188 | 207 | | |
189 | 208 | | |
190 | 209 | | |
| |||
236 | 255 | | |
237 | 256 | | |
238 | 257 | | |
239 | | - | |
240 | | - | |
| 258 | + | |
| 259 | + | |
241 | 260 | | |
242 | 261 | | |
243 | | - | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
244 | 266 | | |
245 | 267 | | |
246 | | - | |
247 | 268 | | |
248 | 269 | | |
249 | 270 | | |
| |||
255 | 276 | | |
256 | 277 | | |
257 | 278 | | |
258 | | - | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
259 | 282 | | |
| 283 | + | |
| 284 | + | |
260 | 285 | | |
261 | 286 | | |
262 | 287 | | |
| |||
269 | 294 | | |
270 | 295 | | |
271 | 296 | | |
272 | | - | |
| 297 | + | |
273 | 298 | | |
274 | 299 | | |
275 | 300 | | |
| |||
0 commit comments