* [PATCH 1/3] mm/vmscan: not necessary to re-init the list for each iteration @ 2022-04-26 2:17 Wei Yang 2022-04-26 2:17 ` [PATCH 2/3] mm/vmscan: filter empty page_list at the beginning Wei Yang 2022-04-26 2:17 ` [PATCH 3/3] mm/vmscan: not use NUMA_NO_NODE as indicator of page on different node Wei Yang 0 siblings, 2 replies; 6+ messages in thread From: Wei Yang @ 2022-04-26 2:17 UTC (permalink / raw) To: akpm; +Cc: linux-mm, Wei Yang node_page_list is defined with LIST_HEAD and be cleaned until list_empty. So it is not necessary to re-init it again. Signed-off-by: Wei Yang <richard.weiyang@gmail.com> --- mm/vmscan.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 0b7cc9309e70..9b5ce5778e9b 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2539,7 +2539,6 @@ unsigned long reclaim_pages(struct list_head *page_list) page = lru_to_page(page_list); if (nid == NUMA_NO_NODE) { nid = page_to_nid(page); - INIT_LIST_HEAD(&node_page_list); } if (nid == page_to_nid(page)) { -- 2.33.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/3] mm/vmscan: filter empty page_list at the beginning 2022-04-26 2:17 [PATCH 1/3] mm/vmscan: not necessary to re-init the list for each iteration Wei Yang @ 2022-04-26 2:17 ` Wei Yang 2022-04-26 21:47 ` Andrew Morton 2022-04-26 2:17 ` [PATCH 3/3] mm/vmscan: not use NUMA_NO_NODE as indicator of page on different node Wei Yang 1 sibling, 1 reply; 6+ messages in thread From: Wei Yang @ 2022-04-26 2:17 UTC (permalink / raw) To: akpm; +Cc: linux-mm, Wei Yang node_page_list would always be !empty on finishing the loop, except page_list is empty. Let's handle empty page_list before doing any real work including touching PF_MEMALLOC flag. Signed-off-by: Wei Yang <richard.weiyang@gmail.com> --- mm/vmscan.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 9b5ce5778e9b..3a36ebd6295d 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2533,9 +2533,12 @@ unsigned long reclaim_pages(struct list_head *page_list) .no_demotion = 1, }; + if (list_empty(page_list)) + return nr_reclaimed; + noreclaim_flag = memalloc_noreclaim_save(); - while (!list_empty(page_list)) { + do { page = lru_to_page(page_list); if (nid == NUMA_NO_NODE) { nid = page_to_nid(page); @@ -2557,17 +2560,15 @@ unsigned long reclaim_pages(struct list_head *page_list) } nid = NUMA_NO_NODE; - } + } while (!list_empty(page_list)); - if (!list_empty(&node_page_list)) { - nr_reclaimed += shrink_page_list(&node_page_list, - NODE_DATA(nid), - &sc, &dummy_stat, false); - while (!list_empty(&node_page_list)) { - page = lru_to_page(&node_page_list); - list_del(&page->lru); - putback_lru_page(page); - } + nr_reclaimed += shrink_page_list(&node_page_list, + NODE_DATA(nid), + &sc, &dummy_stat, false); + while (!list_empty(&node_page_list)) { + page = lru_to_page(&node_page_list); + list_del(&page->lru); + putback_lru_page(page); } memalloc_noreclaim_restore(noreclaim_flag); -- 2.33.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/3] mm/vmscan: filter empty page_list at the beginning 2022-04-26 2:17 ` [PATCH 2/3] mm/vmscan: filter empty page_list at the beginning Wei Yang @ 2022-04-26 21:47 ` Andrew Morton 2022-04-27 23:25 ` Wei Yang 0 siblings, 1 reply; 6+ messages in thread From: Andrew Morton @ 2022-04-26 21:47 UTC (permalink / raw) To: Wei Yang; +Cc: linux-mm On Tue, 26 Apr 2022 02:17:42 +0000 Wei Yang <richard.weiyang@gmail.com> wrote: > node_page_list would always be !empty on finishing the loop, except > page_list is empty. > > Let's handle empty page_list before doing any real work including > touching PF_MEMALLOC flag. Please see https://lkml.kernel.org/r/20220425111232.23182-3-linmiaohe@huawei.com I'll skip this patch. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/3] mm/vmscan: filter empty page_list at the beginning 2022-04-26 21:47 ` Andrew Morton @ 2022-04-27 23:25 ` Wei Yang 2022-04-27 23:29 ` Andrew Morton 0 siblings, 1 reply; 6+ messages in thread From: Wei Yang @ 2022-04-27 23:25 UTC (permalink / raw) To: Andrew Morton; +Cc: Wei Yang, linux-mm On Tue, Apr 26, 2022 at 02:47:25PM -0700, Andrew Morton wrote: >On Tue, 26 Apr 2022 02:17:42 +0000 Wei Yang <richard.weiyang@gmail.com> wrote: > >> node_page_list would always be !empty on finishing the loop, except >> page_list is empty. >> >> Let's handle empty page_list before doing any real work including >> touching PF_MEMALLOC flag. > >Please see >https://lkml.kernel.org/r/20220425111232.23182-3-linmiaohe@huawei.com Aha, I have thought about this. The following change is still valid, could I rebase on top of this? > >I'll skip this patch. -- Wei Yang Help you, Help me ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/3] mm/vmscan: filter empty page_list at the beginning 2022-04-27 23:25 ` Wei Yang @ 2022-04-27 23:29 ` Andrew Morton 0 siblings, 0 replies; 6+ messages in thread From: Andrew Morton @ 2022-04-27 23:29 UTC (permalink / raw) To: Wei Yang; +Cc: linux-mm On Wed, 27 Apr 2022 23:25:31 +0000 Wei Yang <richard.weiyang@gmail.com> wrote: > On Tue, Apr 26, 2022 at 02:47:25PM -0700, Andrew Morton wrote: > >On Tue, 26 Apr 2022 02:17:42 +0000 Wei Yang <richard.weiyang@gmail.com> wrote: > > > >> node_page_list would always be !empty on finishing the loop, except > >> page_list is empty. > >> > >> Let's handle empty page_list before doing any real work including > >> touching PF_MEMALLOC flag. > > > >Please see > >https://lkml.kernel.org/r/20220425111232.23182-3-linmiaohe@huawei.com > > Aha, I have thought about this. > > The following change is still valid, could I rebase on top of this? > Sure, please do. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/3] mm/vmscan: not use NUMA_NO_NODE as indicator of page on different node 2022-04-26 2:17 [PATCH 1/3] mm/vmscan: not necessary to re-init the list for each iteration Wei Yang 2022-04-26 2:17 ` [PATCH 2/3] mm/vmscan: filter empty page_list at the beginning Wei Yang @ 2022-04-26 2:17 ` Wei Yang 1 sibling, 0 replies; 6+ messages in thread From: Wei Yang @ 2022-04-26 2:17 UTC (permalink / raw) To: akpm; +Cc: linux-mm, Wei Yang Now we are sure there is at lease one page on page_list, so it is safe to get the nid of it. This means it is not necessary to use NUMA_NO_NODE as an indicator for the beginning of iteration or a page on different node. Signed-off-by: Wei Yang <richard.weiyang@gmail.com> --- mm/vmscan.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 3a36ebd6295d..f9998cba236f 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2519,7 +2519,7 @@ static void shrink_active_list(unsigned long nr_to_scan, unsigned long reclaim_pages(struct list_head *page_list) { - int nid = NUMA_NO_NODE; + int nid; unsigned int nr_reclaimed = 0; LIST_HEAD(node_page_list); struct reclaim_stat dummy_stat; @@ -2538,11 +2538,9 @@ unsigned long reclaim_pages(struct list_head *page_list) noreclaim_flag = memalloc_noreclaim_save(); + nid = page_to_nid(lru_to_page(page_list)); do { page = lru_to_page(page_list); - if (nid == NUMA_NO_NODE) { - nid = page_to_nid(page); - } if (nid == page_to_nid(page)) { ClearPageActive(page); @@ -2559,7 +2557,7 @@ unsigned long reclaim_pages(struct list_head *page_list) putback_lru_page(page); } - nid = NUMA_NO_NODE; + nid = page_to_nid(lru_to_page(page_list)); } while (!list_empty(page_list)); nr_reclaimed += shrink_page_list(&node_page_list, -- 2.33.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-04-27 23:29 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-04-26 2:17 [PATCH 1/3] mm/vmscan: not necessary to re-init the list for each iteration Wei Yang 2022-04-26 2:17 ` [PATCH 2/3] mm/vmscan: filter empty page_list at the beginning Wei Yang 2022-04-26 21:47 ` Andrew Morton 2022-04-27 23:25 ` Wei Yang 2022-04-27 23:29 ` Andrew Morton 2022-04-26 2:17 ` [PATCH 3/3] mm/vmscan: not use NUMA_NO_NODE as indicator of page on different node Wei Yang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox