diff mbox series

[2/4] mm: multi-gen LRU: MGLRU unbalance reclaim

Message ID 20231108065818.19932-3-link@vivo.com (mailing list archive)
State New
Headers show
Series Introduce unbalance proactive reclaim | expand

Commit Message

Huan Yang Nov. 8, 2023, 6:58 a.m. UTC
This patch apply unbalance reclaim into MGLRU, if unbalance reclaim,
will not scan other type folios.

Signed-off-by: Huan Yang <link@vivo.com>
---
 mm/vmscan.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

kernel test robot Nov. 8, 2023, 12:34 p.m. UTC | #1
Hi Huan,

kernel test robot noticed the following build warnings:

[auto build test WARNING on akpm-mm/mm-everything]
[also build test WARNING on tj-cgroup/for-next linus/master v6.6 next-20231108]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Huan-Yang/mm-vmscan-LRU-unbalance-cgroup-reclaim/20231108-151757
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20231108065818.19932-3-link%40vivo.com
patch subject: [PATCH 2/4] mm: multi-gen LRU: MGLRU unbalance reclaim
config: x86_64-randconfig-011-20231108 (https://download.01.org/0day-ci/archive/20231108/202311082048.zacOzITP-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231108/202311082048.zacOzITP-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311082048.zacOzITP-lkp@intel.com/

All warnings (new ones prefixed by >>):

   mm/vmscan.c: In function 'isolate_folios':
>> mm/vmscan.c:4518:29: warning: 'unbalance' is used uninitialized [-Wuninitialized]
    4518 |                 if (scanned || unbalance)
         |                     ~~~~~~~~^~~~~~~~~~~~
   mm/vmscan.c:4488:14: note: 'unbalance' was declared here
    4488 |         bool unbalance;
         |              ^~~~~~~~~


vim +/unbalance +4518 mm/vmscan.c

  4480	
  4481	static int isolate_folios(struct lruvec *lruvec, struct scan_control *sc, int swappiness,
  4482				  int *type_scanned, struct list_head *list)
  4483	{
  4484		int i;
  4485		int type;
  4486		int scanned;
  4487		int tier = -1;
  4488		bool unbalance;
  4489		DEFINE_MIN_SEQ(lruvec);
  4490	
  4491		/*
  4492		 * Try to make the obvious choice first. When anon and file are both
  4493		 * available from the same generation, interpret swappiness 1 as file
  4494		 * first and 200 as anon first.
  4495		 */
  4496		if (unlikely(unbalance_file_reclaim(sc, swappiness))) {
  4497			unbalance = true;
  4498			type = LRU_GEN_FILE;
  4499		} else if (unlikely(unbalance_anon_reclaim(sc, swappiness))) {
  4500			unbalance = true;
  4501			type = LRU_GEN_ANON;
  4502		} else if (!swappiness)
  4503			type = LRU_GEN_FILE;
  4504		else if (min_seq[LRU_GEN_ANON] < min_seq[LRU_GEN_FILE])
  4505			type = LRU_GEN_ANON;
  4506		else if (swappiness == 1)
  4507			type = LRU_GEN_FILE;
  4508		else if (swappiness == 200)
  4509			type = LRU_GEN_ANON;
  4510		else
  4511			type = get_type_to_scan(lruvec, swappiness, &tier);
  4512	
  4513		for (i = !swappiness; i < ANON_AND_FILE; i++) {
  4514			if (tier < 0)
  4515				tier = get_tier_idx(lruvec, type);
  4516	
  4517			scanned = scan_folios(lruvec, sc, type, tier, list);
> 4518			if (scanned || unbalance)
  4519				break;
  4520	
  4521			type = !type;
  4522			tier = -1;
  4523		}
  4524	
  4525		*type_scanned = type;
  4526	
  4527		return scanned;
  4528	}
  4529
kernel test robot Nov. 9, 2023, 11:08 a.m. UTC | #2
Hi Huan,

kernel test robot noticed the following build warnings:

[auto build test WARNING on akpm-mm/mm-everything]
[also build test WARNING on tj-cgroup/for-next linus/master v6.6 next-20231109]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Huan-Yang/mm-vmscan-LRU-unbalance-cgroup-reclaim/20231108-151757
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20231108065818.19932-3-link%40vivo.com
patch subject: [PATCH 2/4] mm: multi-gen LRU: MGLRU unbalance reclaim
config: x86_64-randconfig-013-20231108 (https://download.01.org/0day-ci/archive/20231109/202311091842.AqdVBQwL-lkp@intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231109/202311091842.AqdVBQwL-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311091842.AqdVBQwL-lkp@intel.com/

All warnings (new ones prefixed by >>):

   mm/vmscan.c: In function 'isolate_folios':
>> mm/vmscan.c:4518:15: warning: 'unbalance' is used uninitialized in this function [-Wuninitialized]
    4518 |   if (scanned || unbalance)
         |       ~~~~~~~~^~~~~~~~~~~~


vim +/unbalance +4518 mm/vmscan.c

  4480	
  4481	static int isolate_folios(struct lruvec *lruvec, struct scan_control *sc, int swappiness,
  4482				  int *type_scanned, struct list_head *list)
  4483	{
  4484		int i;
  4485		int type;
  4486		int scanned;
  4487		int tier = -1;
  4488		bool unbalance;
  4489		DEFINE_MIN_SEQ(lruvec);
  4490	
  4491		/*
  4492		 * Try to make the obvious choice first. When anon and file are both
  4493		 * available from the same generation, interpret swappiness 1 as file
  4494		 * first and 200 as anon first.
  4495		 */
  4496		if (unlikely(unbalance_file_reclaim(sc, swappiness))) {
  4497			unbalance = true;
  4498			type = LRU_GEN_FILE;
  4499		} else if (unlikely(unbalance_anon_reclaim(sc, swappiness))) {
  4500			unbalance = true;
  4501			type = LRU_GEN_ANON;
  4502		} else if (!swappiness)
  4503			type = LRU_GEN_FILE;
  4504		else if (min_seq[LRU_GEN_ANON] < min_seq[LRU_GEN_FILE])
  4505			type = LRU_GEN_ANON;
  4506		else if (swappiness == 1)
  4507			type = LRU_GEN_FILE;
  4508		else if (swappiness == 200)
  4509			type = LRU_GEN_ANON;
  4510		else
  4511			type = get_type_to_scan(lruvec, swappiness, &tier);
  4512	
  4513		for (i = !swappiness; i < ANON_AND_FILE; i++) {
  4514			if (tier < 0)
  4515				tier = get_tier_idx(lruvec, type);
  4516	
  4517			scanned = scan_folios(lruvec, sc, type, tier, list);
> 4518			if (scanned || unbalance)
  4519				break;
  4520	
  4521			type = !type;
  4522			tier = -1;
  4523		}
  4524	
  4525		*type_scanned = type;
  4526	
  4527		return scanned;
  4528	}
  4529
Dan Carpenter Dec. 4, 2023, 6:53 a.m. UTC | #3
Hi Huan,

kernel test robot noticed the following build warnings:

https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Huan-Yang/mm-vmscan-LRU-unbalance-cgroup-reclaim/20231108-151757
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20231108065818.19932-3-link%40vivo.com
patch subject: [PATCH 2/4] mm: multi-gen LRU: MGLRU unbalance reclaim
config: x86_64-randconfig-161-20231108 (https://download.01.org/0day-ci/archive/20231204/202312040256.guajrRNm-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce: (https://download.01.org/0day-ci/archive/20231204/202312040256.guajrRNm-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202312040256.guajrRNm-lkp@intel.com/

smatch warnings:
mm/vmscan.c:4518 isolate_folios() error: uninitialized symbol 'unbalance'.

vim +/unbalance +4518 mm/vmscan.c

ac35a490237446 Yu Zhao   2022-09-18  4481  static int isolate_folios(struct lruvec *lruvec, struct scan_control *sc, int swappiness,
ac35a490237446 Yu Zhao   2022-09-18  4482  			  int *type_scanned, struct list_head *list)
ac35a490237446 Yu Zhao   2022-09-18  4483  {
ac35a490237446 Yu Zhao   2022-09-18  4484  	int i;
ac35a490237446 Yu Zhao   2022-09-18  4485  	int type;
ac35a490237446 Yu Zhao   2022-09-18  4486  	int scanned;
ac35a490237446 Yu Zhao   2022-09-18  4487  	int tier = -1;
9da842af0b17c7 Huan Yang 2023-11-08  4488  	bool unbalance;

unbalance is never set to false.  Only to true.

ac35a490237446 Yu Zhao   2022-09-18  4489  	DEFINE_MIN_SEQ(lruvec);
ac35a490237446 Yu Zhao   2022-09-18  4490  
ac35a490237446 Yu Zhao   2022-09-18  4491  	/*
ac35a490237446 Yu Zhao   2022-09-18  4492  	 * Try to make the obvious choice first. When anon and file are both
ac35a490237446 Yu Zhao   2022-09-18  4493  	 * available from the same generation, interpret swappiness 1 as file
ac35a490237446 Yu Zhao   2022-09-18  4494  	 * first and 200 as anon first.
ac35a490237446 Yu Zhao   2022-09-18  4495  	 */
9da842af0b17c7 Huan Yang 2023-11-08  4496  	if (unlikely(unbalance_file_reclaim(sc, swappiness))) {
9da842af0b17c7 Huan Yang 2023-11-08  4497  		unbalance = true;
9da842af0b17c7 Huan Yang 2023-11-08  4498  		type = LRU_GEN_FILE;
9da842af0b17c7 Huan Yang 2023-11-08  4499  	} else if (unlikely(unbalance_anon_reclaim(sc, swappiness))) {
9da842af0b17c7 Huan Yang 2023-11-08  4500  		unbalance = true;
9da842af0b17c7 Huan Yang 2023-11-08  4501  		type = LRU_GEN_ANON;
9da842af0b17c7 Huan Yang 2023-11-08  4502  	} else if (!swappiness)
ac35a490237446 Yu Zhao   2022-09-18  4503  		type = LRU_GEN_FILE;
ac35a490237446 Yu Zhao   2022-09-18  4504  	else if (min_seq[LRU_GEN_ANON] < min_seq[LRU_GEN_FILE])
ac35a490237446 Yu Zhao   2022-09-18  4505  		type = LRU_GEN_ANON;
ac35a490237446 Yu Zhao   2022-09-18  4506  	else if (swappiness == 1)
ac35a490237446 Yu Zhao   2022-09-18  4507  		type = LRU_GEN_FILE;
ac35a490237446 Yu Zhao   2022-09-18  4508  	else if (swappiness == 200)
ac35a490237446 Yu Zhao   2022-09-18  4509  		type = LRU_GEN_ANON;
ac35a490237446 Yu Zhao   2022-09-18  4510  	else
ac35a490237446 Yu Zhao   2022-09-18  4511  		type = get_type_to_scan(lruvec, swappiness, &tier);
ac35a490237446 Yu Zhao   2022-09-18  4512  
ac35a490237446 Yu Zhao   2022-09-18  4513  	for (i = !swappiness; i < ANON_AND_FILE; i++) {
ac35a490237446 Yu Zhao   2022-09-18  4514  		if (tier < 0)
ac35a490237446 Yu Zhao   2022-09-18  4515  			tier = get_tier_idx(lruvec, type);
ac35a490237446 Yu Zhao   2022-09-18  4516  
ac35a490237446 Yu Zhao   2022-09-18  4517  		scanned = scan_folios(lruvec, sc, type, tier, list);
9da842af0b17c7 Huan Yang 2023-11-08 @4518  		if (scanned || unbalance)
                                                                       ^^^^^^^^^

ac35a490237446 Yu Zhao   2022-09-18  4519  			break;
ac35a490237446 Yu Zhao   2022-09-18  4520  
ac35a490237446 Yu Zhao   2022-09-18  4521  		type = !type;
ac35a490237446 Yu Zhao   2022-09-18  4522  		tier = -1;
ac35a490237446 Yu Zhao   2022-09-18  4523  	}
ac35a490237446 Yu Zhao   2022-09-18  4524  
ac35a490237446 Yu Zhao   2022-09-18  4525  	*type_scanned = type;
ac35a490237446 Yu Zhao   2022-09-18  4526  
ac35a490237446 Yu Zhao   2022-09-18  4527  	return scanned;
ac35a490237446 Yu Zhao   2022-09-18  4528  }
diff mbox series

Patch

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 6ed06e73143a..9243a1f0d606 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -4481,6 +4481,7 @@  static int isolate_folios(struct lruvec *lruvec, struct scan_control *sc, int sw
 	int type;
 	int scanned;
 	int tier = -1;
+	bool unbalance;
 	DEFINE_MIN_SEQ(lruvec);
 
 	/*
@@ -4488,7 +4489,13 @@  static int isolate_folios(struct lruvec *lruvec, struct scan_control *sc, int sw
 	 * available from the same generation, interpret swappiness 1 as file
 	 * first and 200 as anon first.
 	 */
-	if (!swappiness)
+	if (unlikely(unbalance_file_reclaim(sc, swappiness))) {
+		unbalance = true;
+		type = LRU_GEN_FILE;
+	} else if (unlikely(unbalance_anon_reclaim(sc, swappiness))) {
+		unbalance = true;
+		type = LRU_GEN_ANON;
+	} else if (!swappiness)
 		type = LRU_GEN_FILE;
 	else if (min_seq[LRU_GEN_ANON] < min_seq[LRU_GEN_FILE])
 		type = LRU_GEN_ANON;
@@ -4504,7 +4511,7 @@  static int isolate_folios(struct lruvec *lruvec, struct scan_control *sc, int sw
 			tier = get_tier_idx(lruvec, type);
 
 		scanned = scan_folios(lruvec, sc, type, tier, list);
-		if (scanned)
+		if (scanned || unbalance)
 			break;
 
 		type = !type;