* [PATCHv2] mm: migrate LRU_REFS_MASK bits in folio_migrate_flags
@ 2024-09-26 5:06 zhaoyang.huang
2024-09-26 8:27 ` David Hildenbrand
0 siblings, 1 reply; 2+ messages in thread
From: zhaoyang.huang @ 2024-09-26 5:06 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Matthew Wilcox, Yu Zhao,
linux-mm, linux-kernel, Zhaoyang Huang, steve.kang
From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
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.
Suggested-by: Yu Zhao <yuzhao@google.com>
Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
---
v2: modification as Yu Zhao suggested
---
---
include/linux/mm_inline.h | 10 ++++++++++
mm/migrate.c | 1 +
2 files changed, 11 insertions(+)
diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h
index f4fe593c1400..6f801c7b36e2 100644
--- a/include/linux/mm_inline.h
+++ b/include/linux/mm_inline.h
@@ -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
diff --git a/mm/migrate.c b/mm/migrate.c
index 923ea80ba744..60c97e235ae7 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -618,6 +618,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.
--
2.25.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCHv2] mm: migrate LRU_REFS_MASK bits in folio_migrate_flags
2024-09-26 5:06 [PATCHv2] mm: migrate LRU_REFS_MASK bits in folio_migrate_flags zhaoyang.huang
@ 2024-09-26 8:27 ` David Hildenbrand
0 siblings, 0 replies; 2+ messages in thread
From: David Hildenbrand @ 2024-09-26 8:27 UTC (permalink / raw)
To: zhaoyang.huang, Andrew Morton, Matthew Wilcox, Yu Zhao, linux-mm,
linux-kernel, Zhaoyang Huang, steve.kang
On 26.09.24 07:06, zhaoyang.huang wrote:
> From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
>
> 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.
>
> Suggested-by: Yu Zhao <yuzhao@google.com>
> Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
> ---
> v2: modification as Yu Zhao suggested
Looks reasonable to me
Acked-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-09-26 8:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-26 5:06 [PATCHv2] mm: migrate LRU_REFS_MASK bits in folio_migrate_flags zhaoyang.huang
2024-09-26 8:27 ` David Hildenbrand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox