Skip to content

Commit 20dfa5b

Browse files
Barry Songakpm00
authored andcommitted
mm: set pte writable while pte_soft_dirty() is true in do_swap_page()
This patch leverages the new pte_needs_soft_dirty_wp() helper to optimize a scenario where softdirty is enabled, but the softdirty flag has already been set in do_swap_page(). In this situation, we can use pte_mkwrite instead of applying write-protection since we don't depend on write faults. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Barry Song <[email protected]> Suggested-by: David Hildenbrand <[email protected]> Acked-by: David Hildenbrand <[email protected]> Cc: Chris Li <[email protected]> Cc: Kairui Song <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Minchan Kim <[email protected]> Cc: Ryan Roberts <[email protected]> Cc: Suren Baghdasaryan <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent f38ee28 commit 20dfa5b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mm/memory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4324,7 +4324,7 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)
43244324
if (!folio_test_ksm(folio) &&
43254325
(exclusive || folio_ref_count(folio) == 1)) {
43264326
if ((vma->vm_flags & VM_WRITE) && !userfaultfd_pte_wp(vma, pte) &&
4327-
!vma_soft_dirty_enabled(vma)) {
4327+
!pte_needs_soft_dirty_wp(vma, pte)) {
43284328
pte = pte_mkwrite(pte, vma);
43294329
if (vmf->flags & FAULT_FLAG_WRITE) {
43304330
pte = pte_mkdirty(pte);

0 commit comments

Comments
 (0)