]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
mm: migrate LRU_REFS_MASK bits in folio_migrate_flags
authorZhaoyang Huang <zhaoyang.huang@unisoc.com>
Thu, 26 Sep 2024 05:06:47 +0000 (13:06 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 6 Nov 2024 00:56:29 +0000 (16:56 -0800)
Bits of LRU_REFS_MASK are not inherited during migration which lead to new
folio start from tier0 when MGLRU enabled.  Try to bring as much bits of
folio->flags as possible since compaction and alloc_contig_range which
introduce migration do happen at times.

Link: https://lkml.kernel.org/r/20240926050647.5653-1-zhaoyang.huang@unisoc.com
Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
Suggested-by: Yu Zhao <yuzhao@google.com>
Acked-by: David Hildenbrand <david@redhat.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Yu Zhao <yuzhao@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/mm_inline.h
mm/migrate.c

index f4fe593c1400e662add6d60baa0cd794e78a172b..6f801c7b36e2fa84e8cafaeb8682d16c46d80ac9 100644 (file)
@@ -291,6 +291,12 @@ static inline bool lru_gen_del_folio(struct lruvec *lruvec, struct folio *folio,
        return true;
 }
 
+static inline void folio_migrate_refs(struct folio *new, struct folio *old)
+{
+       unsigned long refs = READ_ONCE(old->flags) & LRU_REFS_MASK;
+
+       set_mask_bits(&new->flags, LRU_REFS_MASK, refs);
+}
 #else /* !CONFIG_LRU_GEN */
 
 static inline bool lru_gen_enabled(void)
@@ -313,6 +319,10 @@ static inline bool lru_gen_del_folio(struct lruvec *lruvec, struct folio *folio,
        return false;
 }
 
+static inline void folio_migrate_refs(struct folio *new, struct folio *old)
+{
+
+}
 #endif /* CONFIG_LRU_GEN */
 
 static __always_inline
index dfa24e41e8f9565f5434222ed73a8496e3e8430d..72c6657f4f72ca67c9f2bd4fd9c1c668188e1570 100644 (file)
@@ -695,6 +695,7 @@ void folio_migrate_flags(struct folio *newfolio, struct folio *folio)
        if (folio_test_idle(folio))
                folio_set_idle(newfolio);
 
+       folio_migrate_refs(newfolio, folio);
        /*
         * Copy NUMA information to the new page, to prevent over-eager
         * future migrations of this same page.