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); From patchwork Mon Aug 31 17:50:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhao X-Patchwork-Id: 11746795 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 8632D13A4 for ; Mon, 31 Aug 2020 17:50:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 531EB20767 for ; Mon, 31 Aug 2020 17:50:55 +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="HW8I1YgZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 531EB20767 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 9E4C38E0001; Mon, 31 Aug 2020 13:50:53 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 94A406B005A; Mon, 31 Aug 2020 13:50:53 -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 7734E8E0001; Mon, 31 Aug 2020 13:50:53 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0047.hostedemail.com [216.40.44.47]) by kanga.kvack.org (Postfix) with ESMTP id 5369B6B0055 for ; Mon, 31 Aug 2020 13:50:53 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 13EB6824556B for ; Mon, 31 Aug 2020 17:50:53 +0000 (UTC) X-FDA: 77211604386.06.cars31_021157027091 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id E16E21003E0C9 for ; Mon, 31 Aug 2020 17:50:52 +0000 (UTC) X-Spam-Summary: 1,0,0,57756a6ee6078b73,d41d8cd98f00b204,3ezhnxwykcciwsxf8memmejc.amkjglsv-kkit8ai.mpe@flex--yuzhao.bounces.google.com,,RULES_HIT:41:152:355:379:541:800:960:966:973:988:989:1260:1277:1313:1314:1345:1359:1437:1516:1518:1535:1542:1593:1594:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2559:2562:3138:3139:3140:3141:3142:3152:3354:3865:3866:3868:3871:3872:4250:4321:4385:4605:5007:6117:6119:6261:6653:7903:9969:10004:10400:10450:10455:11026:11473:11658:11914:12043:12296:12297:12438:12555:12895:14181:14394:14659:14721:19904:19999:21080:21444:21451:21611:21627:21990:30004:30045:30054,0,RBL:209.85.166.74:@flex--yuzhao.bounces.google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100;04yffnpe857yp1chgmbg7eyqr6apryczch4b3rqomz37u54fwi6t3zy8mdsk7ew.deqoio4gm8i9dekmqq14npb6wud4mbb8toc7q1jsjy8zqdyn4dcooa19qhoek7t.o-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,L Ftime:24 X-HE-Tag: cars31_021157027091 X-Filterd-Recvd-Size: 5637 Received: from mail-io1-f74.google.com (mail-io1-f74.google.com [209.85.166.74]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Mon, 31 Aug 2020 17:50:52 +0000 (UTC) Received: by mail-io1-f74.google.com with SMTP id l22so1284899iol.0 for ; Mon, 31 Aug 2020 10:50:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=WJ86J1Rh/9a+OExkI0rJlOFHOUeu/5tIWacuz+P7JAc=; b=HW8I1YgZCnmOLwNMaMPR8Sc9pNUApCmj+dz2XsrVb+X/SNyph/zuGantqb4pgta39U KQGbOfOjQGNePPnYLR/r429Li0FzwweyZvT5M1Sa1B+9AbEtJB5h5ZgK2Rxw+tDUs811 LRSEOdNQyFkBN0CFGhpsfHaFZvif/OtBteR3Zn8ydBzMdEWLEZMvMk/Mm9bu9Om3s6LC k08kYtCBseeOND4PalCgqnwuU3h36DkgbnC6GK7p7jLKda1YL1EkO3iWVnQoUoA4Fl2r PNzBxiLUIfpFOyLhfFyDZQFX17fBelHRHsTiPW0TBMxp3Ge3zXPAbNLMiA2rNLA8Nylv UWxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=WJ86J1Rh/9a+OExkI0rJlOFHOUeu/5tIWacuz+P7JAc=; b=LC9I+vXN3QyNFOvWcd+YW7KIk1/i93CsRmsl0h7Ff/u1AdG9PAI/x79THFV44nC4Bt kPIGLeLDEqWN2hHYHkALcbi5ILpgmUq8Wwxh4ANPeOTM4T8K1VezzCoeS0abYNBolcxW F4xzF+gkkhGbJxWbyMrmjUIL3WmJo/kCBgbkYJoq2KZQyB9OxVYij3tBjgpgdyf9FaGa c2lfAY3TuCtMPPSoezJzu/aPw5FuZvphX4XqISDZ8xxnxHliCch2TMgMNWZPmEfBi5KI MLr8PWdP202xwNnmfZ6wtMTCHu91hkmnrYGuJsNwrJUtxsz9umA/cXyzG3NCmWUK1YOe UQCQ== X-Gm-Message-State: AOAM533ocKef6YT/IGeT/fOeZYwH4yS67t4UeNgDT4u4nUtvFiudK9QQ vcchohaC58wTOiNUrUeCZtlkV+yjFFY= X-Google-Smtp-Source: ABdhPJyEmB54MPwn+rzZUmhXVP5xIYQCPFUTfjuW/TXcdPEGT6mWsUn1s2ENBY0cwGSp4EbLtkPuNTkDlXQ= X-Received: from yuzhao.bld.corp.google.com ([2620:15c:183:200:7220:84ff:fe09:2d90]) (user=yuzhao job=sendgmr) by 2002:a92:7a0a:: with SMTP id v10mr2027625ilc.99.1598896251830; Mon, 31 Aug 2020 10:50:51 -0700 (PDT) Date: Mon, 31 Aug 2020 11:50:42 -0600 In-Reply-To: <20200831175042.3527153-1-yuzhao@google.com> Message-Id: <20200831175042.3527153-2-yuzhao@google.com> Mime-Version: 1.0 References: <20200831175042.3527153-1-yuzhao@google.com> X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog Subject: [PATCH v2 2/2] mm: use self-explanatory macros rather than "2" From: Yu Zhao To: Andrew Morton Cc: Alex Shi , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yu Zhao X-Rspamd-Queue-Id: E16E21003E0C9 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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 clean-up patch. Take it or leave it. Signed-off-by: Yu Zhao --- include/linux/mmzone.h | 12 ++++++++---- include/linux/vmstat.h | 2 +- mm/vmscan.c | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 8379432f4f2f..be1cdbf8317f 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -266,6 +266,8 @@ static inline bool is_active_lru(enum lru_list lru) return (lru == LRU_ACTIVE_ANON || lru == LRU_ACTIVE_FILE); } +#define ANON_AND_FILE 2 + enum lruvec_flags { LRUVEC_CONGESTED, /* lruvec has many dirty pages * backed by a congested BDI @@ -283,8 +285,8 @@ struct lruvec { unsigned long file_cost; /* Non-resident age, driven by LRU movement */ atomic_long_t nonresident_age; - /* Refaults at the time of last reclaim cycle, anon=0, file=1 */ - unsigned long refaults[2]; + /* Refaults at the time of last reclaim cycle */ + unsigned long refaults[ANON_AND_FILE]; /* Various lruvec state flags (enum lruvec_flags) */ unsigned long flags; #ifdef CONFIG_MEMCG @@ -406,6 +408,8 @@ enum zone_type { #ifndef __GENERATING_BOUNDS_H +#define ASYNC_AND_SYNC 2 + struct zone { /* Read-mostly fields */ @@ -525,8 +529,8 @@ struct zone { #if defined CONFIG_COMPACTION || defined CONFIG_CMA /* pfn where compaction free scanner should start */ unsigned long compact_cached_free_pfn; - /* pfn where async and sync compaction migration scanner should start */ - unsigned long compact_cached_migrate_pfn[2]; + /* pfn where compaction migration scanner should start */ + unsigned long compact_cached_migrate_pfn[ASYNC_AND_SYNC]; unsigned long compact_init_migrate_pfn; unsigned long compact_init_free_pfn; #endif diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index 91220ace31da..d5431c1bf6e5 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h @@ -28,7 +28,7 @@ struct reclaim_stat { unsigned nr_writeback; unsigned nr_immediate; unsigned nr_pageout; - unsigned nr_activate[2]; + unsigned nr_activate[ANON_AND_FILE]; unsigned nr_ref_keep; unsigned nr_unmap_fail; unsigned nr_lazyfree_fail; diff --git a/mm/vmscan.c b/mm/vmscan.c index 1b871c3987e7..b454cc17e5a3 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2232,7 +2232,7 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc, struct mem_cgroup *memcg = lruvec_memcg(lruvec); unsigned long anon_cost, file_cost, total_cost; int swappiness = mem_cgroup_swappiness(memcg); - u64 fraction[2]; + u64 fraction[ANON_AND_FILE]; u64 denominator = 0; /* gcc */ enum scan_balance scan_balance; unsigned long ap, fp;