Message ID | 20220426021743.21007-2-richard.weiyang@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [1/3] mm/vmscan: not necessary to re-init the list for each iteration | expand |
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.
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.
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.
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);
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(-)