Skip to content
Commit 61fa2b6e authored by Ryan Roberts's avatar Ryan Roberts
Browse files

mm: Batch-copy PTE ranges during fork()



Convert copy_pte_range() to copy a set of ptes that map a physically
contiguous block of memory in a batch. This will likely improve
performance by a tiny amount due to batching the folio reference count
management and calling set_ptes() rather than making individual calls to
set_pte_at().

However, the primary motivation for this change is to reduce the number
of tlb maintenance operations that the arm64 backend has to perform
during fork, now that it transparently supports the "contiguous bit" in
its ptes. By write-protecting the parent using the new
ptep_set_wrprotects() (note the 's' at the end) function, the backend
can avoid having to unfold contig ranges of PTEs, which is expensive,
when all ptes in the range are being write-protected. Similarly, by
using set_ptes() rather than set_pte_at() to set up ptes in the child,
the backend does not need to fold a contiguous range once they are all
populated - they can be initially populated as a contiguous range in the
first place.

This change addresses the core-mm refactoring only, and introduces
ptep_set_wrprotects() with a default implementation that calls
ptep_set_wrprotect() for each pte in the range. A separate change will
implement ptep_set_wrprotects() in the arm64 backend to realize the
performance improvement.

Signed-off-by: Ryan Roberts's avatarRyan Roberts <ryan.roberts@arm.com>
parent 2e6f08c8
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment