From patchwork Mon Aug 31 17:50:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhao X-Patchwork-Id: 11746793 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BC71F1709 for ; Mon, 31 Aug 2020 17:50:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7896820639 for ; Mon, 31 Aug 2020 17:50:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="knBREK3D" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7896820639 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9958E6B0003; Mon, 31 Aug 2020 13:50:52 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 91E6B6B0037; Mon, 31 Aug 2020 13:50:52 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 80D5F6B0055; Mon, 31 Aug 2020 13:50:52 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0057.hostedemail.com [216.40.44.57]) by kanga.kvack.org (Postfix) with ESMTP id 2B6476B0003 for ; Mon, 31 Aug 2020 13:50:52 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id E7AFA181AEF09 for ; Mon, 31 Aug 2020 17:50:51 +0000 (UTC) X-FDA: 77211604302.08.son66_0b04a0c27091 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin08.hostedemail.com (Postfix) with ESMTP id C070F1819E773 for ; Mon, 31 Aug 2020 17:50:51 +0000 (UTC) X-Spam-Summary: 1,0,0,1593fb23e6716b88,d41d8cd98f00b204,3ejhnxwykccevrwe7ldlldib.9ljifkru-jjhs79h.lod@flex--yuzhao.bounces.google.com,,RULES_HIT:41:152:355:379:541:800:960:966:973:988:989:1260:1277:1313:1314:1345:1431:1437:1516:1518:1535:1542:1593:1594:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:3138:3139:3140:3141:3142:3152:3353:3865:3867:3870:3871:3872:3874:4321:4385:4605:5007:6261:6653:8957:9010:9592:9969:10004:10400:11026:11233:11473:11658:11914:12043:12114:12296:12297:12438:12555:12895:12986:14181:14394:14659:14721:21060:21080:21444:21611:21627:21740:30054,0,RBL:209.85.219.202:@flex--yuzhao.bounces.google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100;04y8qi76n86zbg6w5djycomwiw5inoc7mu61zhio49pd8xs1o9x11yg6whwsoxn.xp66hqgeh65g8g9tgwctke4oj6htbbgymqca6d6h8o7t6azybzw4csatfxpa1jp.n-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: son66_0b04a0c27091 X-Filterd-Recvd-Size: 5500 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Mon, 31 Aug 2020 17:50:51 +0000 (UTC) Received: by mail-yb1-f202.google.com with SMTP id v11so9925523ybm.22 for ; Mon, 31 Aug 2020 10:50:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=JpWL57E/IIAL9R1H0roONADTldmwz1McUqD3J7o9bl0=; b=knBREK3DrTQlkiin5j15dgIYsIECOHJXCsck6vGRe6vUS6N6qDIc6aVfoMM+0UuMGj 7aofl7ZzlV+/ybYpNv+MLmlskZ4gAOWUuW3HIBnO5Xy+L24sKJYvl5n2Fc/Xo7CN9l6I mktKoBS61HT19+MddqdZ9ZBOx9O7RhhsXkkUQiaSerge46HDozxhXGCKfwH2B4dy9rm0 y8ZFDWvg9hwAwujA/Sr50czu7FPPu6Iw50LK7583+8+buvvJOjP5l4DZnVJ0NwYz99Np /Y8Ls/MJgIp4Ic98iDLIVvT0etqPSzpPGNm69iUY3G0clpmIWs2g7hN95jWQFX0LTEjU wj6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=JpWL57E/IIAL9R1H0roONADTldmwz1McUqD3J7o9bl0=; b=X6iGhx5hfQLyLtasiHAcfruZkKiukGVRJbWvMvlSWTf0w6fSDLHswnnbNFLbor6uoq kTHppyzKJ/Z+/WEZBfwC4Yf60V0T1xPIC56WyD+FnGlV/tJnWr0i+zn0oBLLZt+cX2C+ oV59Ecpi0qOeHUvWA4j78NVfK4YmqGDqAGzELDKrUW6qU0UE7yJdDDlI1PPrbejRtxgY ceQbKO4CBain2cBeUPkstqBJ71bbQfXrjqqlj04U+XEeLbImlMZEZK26htm4ByIFePsk ZOrTNAIC2bqVuba7jEKN44PoHX9d4j3DQIKw7JXAvT0byEt3zybTmAprUzLtv8o2VahQ D2BA== X-Gm-Message-State: AOAM533ir3SidrJcsJqxL0OqwefYufrIwohnUPQ+OGaTOYr6DSeQRVY7 ut07jA3fA3ne+0zryaiO3j051zyJXI0= X-Google-Smtp-Source: ABdhPJx9rXxD1uqCrBCzxGHI+Q0iPaRack91VwRf10zVbssXVm/L8ws1r6QoHwp4qni6pMnDnPx7YLRzNRc= X-Received: from yuzhao.bld.corp.google.com ([2620:15c:183:200:7220:84ff:fe09:2d90]) (user=yuzhao job=sendgmr) by 2002:a5b:d0a:: with SMTP id y10mr4071246ybp.128.1598896250522; Mon, 31 Aug 2020 10:50:50 -0700 (PDT) Date: Mon, 31 Aug 2020 11:50:41 -0600 Message-Id: <20200831175042.3527153-1-yuzhao@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog Subject: [PATCH v2 1/2] mm: use add_page_to_lru_list()/page_lru()/page_off_lru() From: Yu Zhao To: Andrew Morton Cc: Alex Shi , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yu Zhao X-Rspamd-Queue-Id: C070F1819E773 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This is a trivial but worth having clean-up patch. There should be no side effects except page->lru is temporarily poisoned after it's deleted but before it's added to the new list in move_pages_to_lru() (which is not a problem). [ I was under false impression that page_off_lru() clears PG_lru; Alex Shi pointed that out. So in v2, we keep __ClearPageLRU(). ] Signed-off-by: Yu Zhao --- mm/swap.c | 4 +--- mm/vmscan.c | 13 ++++--------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/mm/swap.c b/mm/swap.c index 40bf20a75278..2735ecf0f566 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -597,11 +597,9 @@ static void lru_lazyfree_fn(struct page *page, struct lruvec *lruvec, { if (PageLRU(page) && PageAnon(page) && PageSwapBacked(page) && !PageSwapCache(page) && !PageUnevictable(page)) { - bool active = PageActive(page); int nr_pages = thp_nr_pages(page); - del_page_from_lru_list(page, lruvec, - LRU_INACTIVE_ANON + active); + del_page_from_lru_list(page, lruvec, page_lru(page)); ClearPageActive(page); ClearPageReferenced(page); /* diff --git a/mm/vmscan.c b/mm/vmscan.c index 99e1796eb833..1b871c3987e7 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1845,13 +1845,12 @@ static unsigned noinline_for_stack move_pages_to_lru(struct lruvec *lruvec, int nr_pages, nr_moved = 0; LIST_HEAD(pages_to_free); struct page *page; - enum lru_list lru; while (!list_empty(list)) { page = lru_to_page(list); VM_BUG_ON_PAGE(PageLRU(page), page); + list_del(&page->lru); if (unlikely(!page_evictable(page))) { - list_del(&page->lru); spin_unlock_irq(&pgdat->lru_lock); putback_lru_page(page); spin_lock_irq(&pgdat->lru_lock); @@ -1860,16 +1859,11 @@ static unsigned noinline_for_stack move_pages_to_lru(struct lruvec *lruvec, lruvec = mem_cgroup_page_lruvec(page, pgdat); SetPageLRU(page); - lru = page_lru(page); - - nr_pages = thp_nr_pages(page); - update_lru_size(lruvec, lru, page_zonenum(page), nr_pages); - list_move(&page->lru, &lruvec->lists[lru]); + add_page_to_lru_list(page, lruvec, page_lru(page)); if (put_page_testzero(page)) { __ClearPageLRU(page); - __ClearPageActive(page); - del_page_from_lru_list(page, lruvec, lru); + del_page_from_lru_list(page, lruvec, page_off_lru(page)); if (unlikely(PageCompound(page))) { spin_unlock_irq(&pgdat->lru_lock); @@ -1878,6 +1872,7 @@ static unsigned noinline_for_stack move_pages_to_lru(struct lruvec *lruvec, } else list_add(&page->lru, &pages_to_free); } else { + nr_pages = thp_nr_pages(page); nr_moved += nr_pages; if (PageActive(page)) workingset_age_nonresident(lruvec, nr_pages);