[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240930063912.196526-1-zhaoyang.huang@unisoc.com>
Date: Mon, 30 Sep 2024 14:39:12 +0800
From: "zhaoyang.huang" <zhaoyang.huang@...soc.com>
To: Andrew Morton <akpm@...ux-foundation.org>,
David Hildenbrand
<david@...hat.com>,
Matthew Wilcox <willy@...radead.org>, Yu Zhao
<yuzhao@...gle.com>,
<linux-mm@...ck.org>, <linux-kernel@...r.kernel.org>,
Zhaoyang Huang <huangzhaoyang@...il.com>, <steve.kang@...soc.com>
Subject: [PATCH] mm: deal with active/inactive inversion in lru_gen_is_active
From: Zhaoyang Huang <zhaoyang.huang@...soc.com>
All gens will be deemed as active by lru_gen_is_active when there are
only two generations within the node, which could have the folios
to be active in the belowing scenarios. This commit would like to
solve this by judging if numbers of file type gens greater than two
since anon gens could be remains as 3 when swap is constrained and file
type seq advanced by 1.
1. New folios after migration done.
2. Dropped folios from none-reclaiming context(drop_cache, madvise)
when they are failed of being reclaimed and go back to lru.
Signed-off-by: Zhaoyang Huang <zhaoyang.huang@...soc.com>
---
include/linux/mm_inline.h | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h
index 6f801c7b36e2..5e4017dbec96 100644
--- a/include/linux/mm_inline.h
+++ b/include/linux/mm_inline.h
@@ -165,11 +165,16 @@ static inline int folio_lru_gen(struct folio *folio)
static inline bool lru_gen_is_active(struct lruvec *lruvec, int gen)
{
unsigned long max_seq = lruvec->lrugen.max_seq;
+ unsigned long min_seq = lruvec->lrugen.min_seq[LRU_GEN_FILE];
VM_WARN_ON_ONCE(gen >= MAX_NR_GENS);
- /* see the comment on MIN_NR_GENS */
- return gen == lru_gen_from_seq(max_seq) || gen == lru_gen_from_seq(max_seq - 1);
+ /* see the comment on MIN_NR_GENS
+ * judge if there is active/inactive inversion by the number of file
+ * type gens.
+ */
+ return gen == lru_gen_from_seq(max_seq) ||
+ max_seq - min_seq >= 2 ? gen == lru_gen_from_seq(max_seq - 1) : 0;
}
static inline void lru_gen_update_size(struct lruvec *lruvec, struct folio *folio,
--
2.25.1
Powered by blists - more mailing lists