Skip to contentSkip to conversation

mm/vmscan: check the return value of migrate_pages()

PATCH In review Li Zhong 3 participants 4 messages Sep 17, 2022 – Sep 21, 2022

Subsystems (3)
lore
Share & tools
lore

Li Zhong

author
#0 lore raw

PATCH 1/1 mm/vmscan: check the return value of migrate_pages()

Check the return value of migrate_pages() to check error exeuction.

---
 mm/vmscan.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
mm/vmscan.c +5 -1
index b2b1431352dc..50aaaa9377e2 100644
@@ -1547,6 +1547,7 @@ static unsigned int demote_page_list(struct list_head *demote_pages,
 {
 	int target_nid = next_demotion_node(pgdat->node_id);
 	unsigned int nr_succeeded;
+	int ret;
 
 	if (list_empty(demote_pages))
 		return 0;
@@ -1555,10 +1556,13 @@ static unsigned int demote_page_list(struct list_head *demote_pages,
 		return 0;
 
 	/* Demotion ignores all cpuset and mempolicy settings */
-	migrate_pages(demote_pages, alloc_demote_page, NULL,
+	ret = migrate_pages(demote_pages, alloc_demote_page, NULL,
 			    target_nid, MIGRATE_ASYNC, MR_DEMOTION,
 			    &nr_succeeded);
 
+	if (ret)
+		putback_movable_pages(&pagelist);
+
 	if (current_is_kswapd())
 		__count_vm_events(PGDEMOTE_KSWAPD, nr_succeeded);
 	else
Signature · 1 line
2.25.1
#1 lore raw
Thank you for the patch! Yet something to improve:

Hi Li,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v6.0-rc5]
[cannot apply to akpm-mm/mm-everything next-20220916]
[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/Li-Zhong/mm-vmscan-check-the-return-value-of-migrate_pages/20220917-101433
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git a335366bad1364a07f49df9da1fdfa6d411a5f39
config: hexagon-randconfig-r041-20220916 (https://download.01.org/0day-ci/archive/20220917/[email protected]/config)
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 791a7ae1ba3efd6bca96338e10ffde557ba83920)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/0ea516d584bd904c43954e312ac42fced822dcf7
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Li-Zhong/mm-vmscan-check-the-return-value-of-migrate_pages/20220917-101433 git checkout 0ea516d584bd904c43954e312ac42fced822dcf7
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable

All errors (new ones prefixed by >>):

>> mm/vmscan.c:1564:26: error: use of undeclared identifier 'pagelist'; did you mean 'pageout'?
                   putback_movable_pages(&pagelist);
                                          ^~~~~~~~
                                          pageout
   mm/vmscan.c:1215:18: note: 'pageout' declared here
   static pageout_t pageout(struct folio *folio, struct address_space *mapping,
                    ^

1 error generated.

vim +1564 mm/vmscan.c

1539
1540 /*
1541 * Take pages on @demote_list and attempt to demote them to
1542 * another node. Pages which are not demoted are left on
1543 * @demote_pages.
1544 */
1545 static unsigned int demote_page_list(struct list_head *demote_pages,
1546 struct pglist_data *pgdat)
1547 {
1548 int target_nid = next_demotion_node(pgdat->node_id);
1549 unsigned int nr_succeeded;
1550 int ret;
1551
1552 if (list_empty(demote_pages))
1553 return 0;
1554
1555 if (target_nid == NUMA_NO_NODE)
1556 return 0;
1557
1558 /* Demotion ignores all cpuset and mempolicy settings */
1559 ret = migrate_pages(demote_pages, alloc_demote_page, NULL,
1560 target_nid, MIGRATE_ASYNC, MR_DEMOTION,
1561 &nr_succeeded);
1562
1563 if (ret)

> 1564			putback_movable_pages(&pagelist);

1565
1566 if (current_is_kswapd())
1567 __count_vm_events(PGDEMOTE_KSWAPD, nr_succeeded);
1568 else
1569 __count_vm_events(PGDEMOTE_DIRECT, nr_succeeded);
1570
1571 return nr_succeeded;
1572 }
1573

Signature · 2 lines
0-DAY CI Kernel Test Service
https://01.org/lkp
#2 lore raw
In reply to Li Zhong
Thank you for the patch! Yet something to improve:

Hi Li,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v6.0-rc5]
[cannot apply to akpm-mm/mm-everything next-20220916]
[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/Li-Zhong/mm-vmscan-check-the-return-value-of-migrate_pages/20220917-101433
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git a335366bad1364a07f49df9da1fdfa6d411a5f39
config: arc-randconfig-r043-20220916 (https://download.01.org/0day-ci/archive/20220917/[email protected]/config)
compiler: arceb-elf-gcc (GCC) 12.1.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/0ea516d584bd904c43954e312ac42fced822dcf7
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Li-Zhong/mm-vmscan-check-the-return-value-of-migrate_pages/20220917-101433 git checkout 0ea516d584bd904c43954e312ac42fced822dcf7
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arc SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable

All errors (new ones prefixed by >>):

mm/vmscan.c: In function 'demote_page_list':

>> mm/vmscan.c:1564:40: error: 'pagelist' undeclared (first use in this function)
    1564 |                 putback_movable_pages(&pagelist);
         |                                        ^~~~~~~~

mm/vmscan.c:1564:40: note: each undeclared identifier is reported only once for each function it appears in

vim +/pagelist +1564 mm/vmscan.c

1539
1540 /*
1541 * Take pages on @demote_list and attempt to demote them to
1542 * another node. Pages which are not demoted are left on
1543 * @demote_pages.
1544 */
1545 static unsigned int demote_page_list(struct list_head *demote_pages,
1546 struct pglist_data *pgdat)
1547 {
1548 int target_nid = next_demotion_node(pgdat->node_id);
1549 unsigned int nr_succeeded;
1550 int ret;
1551
1552 if (list_empty(demote_pages))
1553 return 0;
1554
1555 if (target_nid == NUMA_NO_NODE)
1556 return 0;
1557
1558 /* Demotion ignores all cpuset and mempolicy settings */
1559 ret = migrate_pages(demote_pages, alloc_demote_page, NULL,
1560 target_nid, MIGRATE_ASYNC, MR_DEMOTION,
1561 &nr_succeeded);
1562
1563 if (ret)

> 1564			putback_movable_pages(&pagelist);

1565
1566 if (current_is_kswapd())
1567 __count_vm_events(PGDEMOTE_KSWAPD, nr_succeeded);
1568 else
1569 __count_vm_events(PGDEMOTE_DIRECT, nr_succeeded);
1570
1571 return nr_succeeded;
1572 }
1573

Signature · 2 lines
0-DAY CI Kernel Test Service
https://01.org/lkp
reviewer
#3 lore raw
In reply to Li Zhong

Hi,

Quoted 20 lines · Li Zhong

Check the return value of migrate_pages() to check error exeuction.

---
  mm/vmscan.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
mm/vmscan.c +1 -0
index b2b1431352dc..50aaaa9377e2 100644
@@ -1547,6 +1547,7 @@ static unsigned int demote_page_list(struct list_head *demote_pages,
  {
  	int target_nid = next_demotion_node(pgdat->node_id);
  	unsigned int nr_succeeded;
+	int ret;
 
  	if (list_empty(demote_pages))
  		return 0;

mm/vmscan.c static unsigned int demote_page_list(struct list_head *demote_pages, · line 1564

Quoted 10 lines
mm/vmscan.c +3 -1
@@ -1555,10 +1556,13 @@ static unsigned int demote_page_list(struct list_head *demote_pages,
  		return 0;
 
  	/* Demotion ignores all cpuset and mempolicy settings */
-	migrate_pages(demote_pages, alloc_demote_page, NULL,
+	ret = migrate_pages(demote_pages, alloc_demote_page, NULL,
  			    target_nid, MIGRATE_ASYNC, MR_DEMOTION,
  			    &nr_succeeded);
 
+	if (ret)
+		putback_movable_pages(&pagelist);

You can not just put them back into the original lru list, instead the caller has handled the failed-to-demote pages, which will try to reclaim them.

In addition, the code cannot even be built successfully.