Commit e9c2dbc8 authored by Yang Yang's avatar Yang Yang Committed by Andrew Morton

mm/vmscan: define macros for refaults in struct lruvec

The magic number 0 and 1 are used in several places in vmscan.c.
Define macros for them to improve code readability.

Link: https://lkml.kernel.org/r/20220808005644.1721066-1-yang.yang29@zte.com.cnSigned-off-by: default avatarYang Yang <yang.yang29@zte.com.cn>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 4a7e9225
...@@ -306,6 +306,8 @@ static inline bool is_active_lru(enum lru_list lru) ...@@ -306,6 +306,8 @@ static inline bool is_active_lru(enum lru_list lru)
return (lru == LRU_ACTIVE_ANON || lru == LRU_ACTIVE_FILE); return (lru == LRU_ACTIVE_ANON || lru == LRU_ACTIVE_FILE);
} }
#define WORKINGSET_ANON 0
#define WORKINGSET_FILE 1
#define ANON_AND_FILE 2 #define ANON_AND_FILE 2
enum lruvec_flags { enum lruvec_flags {
......
...@@ -3230,7 +3230,7 @@ static void shrink_node(pg_data_t *pgdat, struct scan_control *sc) ...@@ -3230,7 +3230,7 @@ static void shrink_node(pg_data_t *pgdat, struct scan_control *sc)
refaults = lruvec_page_state(target_lruvec, refaults = lruvec_page_state(target_lruvec,
WORKINGSET_ACTIVATE_ANON); WORKINGSET_ACTIVATE_ANON);
if (refaults != target_lruvec->refaults[0] || if (refaults != target_lruvec->refaults[WORKINGSET_ANON] ||
inactive_is_low(target_lruvec, LRU_INACTIVE_ANON)) inactive_is_low(target_lruvec, LRU_INACTIVE_ANON))
sc->may_deactivate |= DEACTIVATE_ANON; sc->may_deactivate |= DEACTIVATE_ANON;
else else
...@@ -3243,7 +3243,7 @@ static void shrink_node(pg_data_t *pgdat, struct scan_control *sc) ...@@ -3243,7 +3243,7 @@ static void shrink_node(pg_data_t *pgdat, struct scan_control *sc)
*/ */
refaults = lruvec_page_state(target_lruvec, refaults = lruvec_page_state(target_lruvec,
WORKINGSET_ACTIVATE_FILE); WORKINGSET_ACTIVATE_FILE);
if (refaults != target_lruvec->refaults[1] || if (refaults != target_lruvec->refaults[WORKINGSET_FILE] ||
inactive_is_low(target_lruvec, LRU_INACTIVE_FILE)) inactive_is_low(target_lruvec, LRU_INACTIVE_FILE))
sc->may_deactivate |= DEACTIVATE_FILE; sc->may_deactivate |= DEACTIVATE_FILE;
else else
...@@ -3559,9 +3559,9 @@ static void snapshot_refaults(struct mem_cgroup *target_memcg, pg_data_t *pgdat) ...@@ -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); target_lruvec = mem_cgroup_lruvec(target_memcg, pgdat);
refaults = lruvec_page_state(target_lruvec, WORKINGSET_ACTIVATE_ANON); refaults = lruvec_page_state(target_lruvec, WORKINGSET_ACTIVATE_ANON);
target_lruvec->refaults[0] = refaults; target_lruvec->refaults[WORKINGSET_ANON] = refaults;
refaults = lruvec_page_state(target_lruvec, WORKINGSET_ACTIVATE_FILE); refaults = lruvec_page_state(target_lruvec, WORKINGSET_ACTIVATE_FILE);
target_lruvec->refaults[1] = refaults; target_lruvec->refaults[WORKINGSET_FILE] = refaults;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment