From d5c04fec663a386885c3fdccbc8c8aeffbb422b4 Mon Sep 17 00:00:00 2001 From: Yu Zhao Date: Thu, 15 Oct 2020 20:09:55 -0700 Subject: [PATCH] BACKPORT: mm: use self-explanatory macros rather than "2" Moto-CRs-Fixed:(CR) Change-Id: I4bb60eb4191c2a378c3d7c5a8c8170eb72d598ae Signed-off-by: Yu Zhao Signed-off-by: Andrew Morton Cc: Alex Shi Link: http://lkml.kernel.org/r/20200831175042.3527153-2-yuzhao@google.com Signed-off-by: Linus Torvalds (cherry picked from commit ed0173733dd468883198c3136284394320b8fad6) Bug: 261052246 Signed-off-by: Kalesh Singh Reviewed-on: https://gerrit.mot.com/2491788 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Xiangpo Zhao Submit-Approved: Jira Key --- include/linux/mmzone.h | 12 ++++++++---- mm/vmscan.c | 4 +--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 6f2a15015435..97f9d4576d2e 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -293,6 +293,8 @@ static inline int is_active_lru(enum lru_list lru) return (lru == LRU_ACTIVE_ANON || lru == LRU_ACTIVE_FILE); } +#define ANON_AND_FILE 2 + struct zone_reclaim_stat { /* * The pageout code in vmscan.c keeps track of how many of the @@ -302,8 +304,8 @@ struct zone_reclaim_stat { * * The anon LRU stats live in [0], file LRU stats in [1] */ - unsigned long recent_rotated[2]; - unsigned long recent_scanned[2]; + unsigned long recent_rotated[ANON_AND_FILE]; + unsigned long recent_scanned[ANON_AND_FILE]; }; struct lruvec { @@ -425,6 +427,8 @@ enum zone_type { #ifndef __GENERATING_BOUNDS_H +#define ASYNC_AND_SYNC 2 + struct zone { /* Read-mostly fields */ @@ -548,8 +552,8 @@ struct zone { #if defined CONFIG_COMPACTION || defined CONFIG_CMA /* pfn where compaction free scanner should start */ unsigned long compact_cached_free_pfn; - /* pfn where async and sync compaction migration scanner should start */ - unsigned long compact_cached_migrate_pfn[2]; + /* pfn where compaction migration scanner should start */ + unsigned long compact_cached_migrate_pfn[ASYNC_AND_SYNC]; unsigned long compact_init_migrate_pfn; unsigned long compact_init_free_pfn; #endif diff --git a/mm/vmscan.c b/mm/vmscan.c index 46261548525b..cc14927c44ee 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2375,7 +2375,7 @@ static void get_scan_count(struct lruvec *lruvec, struct mem_cgroup *memcg, { int swappiness = mem_cgroup_swappiness(memcg); struct zone_reclaim_stat *reclaim_stat = &lruvec->reclaim_stat; - u64 fraction[2]; + u64 fraction[ANON_AND_FILE]; u64 denominator = 0; /* gcc */ struct pglist_data *pgdat = lruvec_pgdat(lruvec); unsigned long anon_prio, file_prio; @@ -2487,8 +2487,6 @@ static void get_scan_count(struct lruvec *lruvec, struct mem_cgroup *memcg, * Because workloads change over time (and to avoid overflow) * we keep these statistics as a floating average, which ends * up weighing recent references more than old ones. - * - * anon in [0], file in [1] */ anon = lruvec_lru_size(lruvec, LRU_ACTIVE_ANON, MAX_NR_ZONES) +