If a system has memcg disabled and no numa node, like a embedded system, there is no needs to do the pagevec sort, since only just one lruvec in system. In this situation, we could skip the pagevec sorting. Signed-off-by: Alex Shi <alex.shi@xxxxxxxxxxxxxxxxx> Cc: Konstantin Khlebnikov <koct9i@xxxxxxxxx> Cc: Hugh Dickins <hughd@xxxxxxxxxx> Cc: Yu Zhao <yuzhao@xxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Cc: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Cc: linux-mm@xxxxxxxxx Cc: linux-kernel@xxxxxxxxxxxxxxx --- mm/swap.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/mm/swap.c b/mm/swap.c index 17d8990e5ca7..814809845700 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -264,12 +264,17 @@ static void pagevec_lru_move_fn(struct pagevec *pvec, unsigned long flags = 0; unsigned long lvaddr[PAGEVEC_SIZE]; struct pagevec isopv; + struct pagevec *pv; - pagevec_init(&isopv); - - sort_isopv(pvec, &isopv, lvaddr); + if (!mem_cgroup_disabled() || num_online_nodes() > 1) { + pagevec_init(&isopv); + sort_isopv(pvec, &isopv, lvaddr); + pv = &isopv; + } else { + pv = pvec; + } - n = pagevec_count(&isopv); + n = pagevec_count(pv); if (!n) return; @@ -284,12 +289,12 @@ static void pagevec_lru_move_fn(struct pagevec *pvec, spin_lock_irqsave(&lruvec->lru_lock, flags); } - (*move_fn)(isopv.pages[i], lruvec); + (*move_fn)(pv->pages[i], lruvec); - SetPageLRU(isopv.pages[i]); + SetPageLRU(pv->pages[i]); } spin_unlock_irqrestore(&lruvec->lru_lock, flags); - release_pages(isopv.pages, isopv.nr); + release_pages(pv->pages, pv->nr); } static void pagevec_move_tail_fn(struct page *page, struct lruvec *lruvec) -- 2.29.GIT