[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220802071012.1648335-1-yang.yang29@zte.com.cn>
Date: Tue, 2 Aug 2022 07:10:13 +0000
From: cgel.zte@...il.com
To: akpm@...ux-foundation.org, hannes@...xchg.org
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org,
Yang Yang <yang.yang29@....com.cn>,
CGEL ZTE <cgel.zte@...il.com>
Subject: [PATCH] mm/vmscan: define macros for refaults in struct lruvec
From: Yang Yang <yang.yang29@....com.cn>
The magic number 0 and 1 are used in several places in vmscan.c.
Define macros for them to improve code readability.
Signed-off-by: Yang Yang <yang.yang29@....com.cn>
Signed-off-by: CGEL ZTE <cgel.zte@...il.com>
---
include/linux/mmzone.h | 2 ++
mm/vmscan.c | 8 ++++----
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index e24b40c52468..795076c33163 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -306,6 +306,8 @@ static inline bool is_active_lru(enum lru_list lru)
return (lru == LRU_ACTIVE_ANON || lru == LRU_ACTIVE_FILE);
}
+#define ANON 0
+#define FILE 1
#define ANON_AND_FILE 2
enum lruvec_flags {
diff --git a/mm/vmscan.c b/mm/vmscan.c
index b2b1431352dc..f6a54c25ac7d 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -3230,7 +3230,7 @@ static void shrink_node(pg_data_t *pgdat, struct scan_control *sc)
refaults = lruvec_page_state(target_lruvec,
WORKINGSET_ACTIVATE_ANON);
- if (refaults != target_lruvec->refaults[0] ||
+ if (refaults != target_lruvec->refaults[ANON] ||
inactive_is_low(target_lruvec, LRU_INACTIVE_ANON))
sc->may_deactivate |= DEACTIVATE_ANON;
else
@@ -3243,7 +3243,7 @@ static void shrink_node(pg_data_t *pgdat, struct scan_control *sc)
*/
refaults = lruvec_page_state(target_lruvec,
WORKINGSET_ACTIVATE_FILE);
- if (refaults != target_lruvec->refaults[1] ||
+ if (refaults != target_lruvec->refaults[FILE] ||
inactive_is_low(target_lruvec, LRU_INACTIVE_FILE))
sc->may_deactivate |= DEACTIVATE_FILE;
else
@@ -3559,9 +3559,9 @@ static void snapshot_refaults(struct mem_cgroup *target_memcg, pg_data_t *pgdat)
target_lruvec = mem_cgroup_lruvec(target_memcg, pgdat);
refaults = lruvec_page_state(target_lruvec, WORKINGSET_ACTIVATE_ANON);
- target_lruvec->refaults[0] = refaults;
+ target_lruvec->refaults[ANON] = refaults;
refaults = lruvec_page_state(target_lruvec, WORKINGSET_ACTIVATE_FILE);
- target_lruvec->refaults[1] = refaults;
+ target_lruvec->refaults[FILE] = refaults;
}
/*
--
2.25.1
Powered by blists - more mailing lists