Skip to contentSkip to conversation

mm-madvise-introduce-clear_young_dirty_ptes-batch-helper.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message May 6, 2024

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm/madvise: introduce clear_young_dirty_ptes() batch helper
has been removed from the -mm tree. Its filename was
mm-madvise-introduce-clear_young_dirty_ptes-batch-helper.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Lance Yang <[email protected]>
Subject: mm/madvise: introduce clear_young_dirty_ptes() batch helper
Date: Thu, 18 Apr 2024 21:44:32 +0800

Patch series "mm/madvise: enhance lazyfreeing with mTHP in madvise_free", v10.

This patchset adds support for lazyfreeing multi-size THP (mTHP) without needing to first split the large folio via split_folio(). However, we still need to split a large folio that is not fully mapped within the target range.

If a large folio is locked or shared, or if we fail to split it, we just leave it in place and advance to the next PTE in the range. But note that the behavior is changed; previously, any failure of this sort would cause the entire operation to give up. As large folios become more common, sticking to the old way could result in wasted opportunities.

Performance Testing
===================

On an Intel I5 CPU, lazyfreeing a 1GiB VMA backed by PTE-mapped folios of the same size results in the following runtimes for madvise(MADV_FREE) in seconds (shorter is better):

Folio Size | Old | New | Change
------------------------------------------

      4KiB | 0.590251 | 0.590259 |    0%
     16KiB | 2.990447 | 0.185655 |  -94%
     32KiB | 2.547831 | 0.104870 |  -95%
     64KiB | 2.457796 | 0.052812 |  -97%
    128KiB | 2.281034 | 0.032777 |  -99%
    256KiB | 2.230387 | 0.017496 |  -99%
    512KiB | 2.189106 | 0.010781 |  -99%
   1024KiB | 2.183949 | 0.007753 |  -99%
   2048KiB | 0.002799 | 0.002804 |    0%

This patch (of 4):

This commit introduces clear_young_dirty_ptes() to replace mkold_ptes(). By doing so, we can use the same function for both use cases (madvise_pageout and madvise_free), and it also provides the flexibility to only clear the dirty flag in the future if needed.

---

 include/linux/mm_types.h |    9 ++++
 include/linux/pgtable.h  |   74 ++++++++++++++++++++++---------------
 mm/madvise.c             |    3 +
 3 files changed, 55 insertions(+), 31 deletions(-)
include/linux/mm_types.h renamed from include/linux/mm_types.h~mm-madvise-introduce-clear_young_dirty_ptes-batch-helper +9 -0
@@ -1368,6 +1368,15 @@ enum fault_flag {
 
 typedef unsigned int __bitwise zap_flags_t;
 
+/* Flags for clear_young_dirty_ptes(). */
+typedef int __bitwise cydp_t;
+
+/* Clear the access bit */
+#define CYDP_CLEAR_YOUNG		((__force cydp_t)BIT(0))
+
+/* Clear the dirty bit */
+#define CYDP_CLEAR_DIRTY		((__force cydp_t)BIT(1))
+
 /*
  * FOLL_PIN and FOLL_LONGTERM may be used in various combinations with each
  * other. Here is what they mean, and how to use them:
include/linux/pgtable.h renamed from include/linux/pgtable.h~mm-madvise-introduce-clear_young_dirty_ptes-batch-helper +44 -30

86 lines not on this page · raw message

mm/madvise.c renamed from mm/madvise.c~mm-madvise-introduce-clear_young_dirty_ptes-batch-helper +2 -1
@@ -507,7 +507,8 @@ restart:
 			continue;
 
 		if (!pageout && pte_young(ptent)) {
-			mkold_ptes(vma, addr, pte, nr);
+			clear_young_dirty_ptes(vma, addr, pte, nr,
+					       CYDP_CLEAR_YOUNG);
 			tlb_remove_tlb_entries(tlb, pte, nr, addr);
 		}
 

_

Patches currently in -mm which might be from [email protected] are