On Thu, Apr 23, 2020 at 12:16:02PM +0900, Jaewon Kim wrote: > > > On 2020년 04월 22일 22:07, Johannes Weiner wrote: > > On Wed, Apr 22, 2020 at 05:48:15PM +0900, Jaewon Kim wrote: > >> @@ -1295,11 +1295,15 @@ static unsigned long shrink_page_list(struct list_head *page_list, > >> */ > >> if (page_mapped(page)) { > >> enum ttu_flags flags = ttu_flags | TTU_BATCH_FLUSH; > >> + bool lazyfree = PageAnon(page) && !PageSwapBacked(page); > >> > >> if (unlikely(PageTransHuge(page))) > >> flags |= TTU_SPLIT_HUGE_PMD; > >> + > >> if (!try_to_unmap(page, flags)) { > >> stat->nr_unmap_fail += nr_pages; > >> + if (lazyfree && PageSwapBacked(page)) > > This looks pretty strange, until you remember that try_to_unmap() > > could SetPageSwapbacked again. > > > > This might be more obvious? > > > > was_swapbacked = PageSwapBacked(page); > > if (!try_to_unmap(page, flags)) { > > stat->nr_unmap_fail += nr_pages; > > if (!was_swapbacked && PageSwapBacked(page)) > Hello Johannes, thank you for your comment. > > The name can changed from layzyfree to was_swapbacked. > By the way, did you mean removing PageAnon(page), too? It seems to be OK, though. I can't decide whether PageAnon() makes it clearer or not. But it's not really needed for correctness. So feel free to keep what you had. I would really just at least change bool lazyfree to was_lazyfree, otherwise it seems a bit confusing. was_lazyfree makes it a bit clearer that we expect try_to_unmap() might change the state. > >> + stat->nr_lazyfree_fail += nr_pages; > >> goto activate_locked; > > Or at least was_lazyfree. > Sorry but I'm confused. > I think you meant additional comment to previous your comment > rather than you wanted to rename stat->nr_lazyfree_fail to stat->was_lazyfree. No just the bool variable, the stat one seems fine to me. > >> @@ -1491,8 +1495,8 @@ unsigned long reclaim_clean_pages_from_list(struct zone *zone, > >> .priority = DEF_PRIORITY, > >> .may_unmap = 1, > >> }; > >> - struct reclaim_stat dummy_stat; > >> - unsigned long ret; > >> + struct reclaim_stat stat; > >> + unsigned long reclaimed; > > nr_reclaimed would be better. > I will add nr_ prefix on next patch. Thanks! > > I also prefer keeping dummy_stat, since that's still what it is. > This patch uses stat.nr_lazyfree_fail, I do not understand why it is still dummy_stat. > If you want, I will keep dummy_stat, though. My bad, I just misread this. 'stat' makes more sense then.