From patchwork Thu Aug 27 23:42:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhao X-Patchwork-Id: 11741983 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 8AF3F109B for ; Thu, 27 Aug 2020 23:42:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5818420872 for ; Thu, 27 Aug 2020 23:42:11 +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="iCkxPIo1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5818420872 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 650266B0002; Thu, 27 Aug 2020 19:42:10 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5FFB86B0003; Thu, 27 Aug 2020 19:42:10 -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 4EFB86B0006; Thu, 27 Aug 2020 19:42:10 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0088.hostedemail.com [216.40.44.88]) by kanga.kvack.org (Postfix) with ESMTP id 38A0C6B0002 for ; Thu, 27 Aug 2020 19:42:10 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id DF0C13642 for ; Thu, 27 Aug 2020 23:42:09 +0000 (UTC) X-FDA: 77197974378.14.cork87_45015f027071 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id 9AAEA18229835 for ; Thu, 27 Aug 2020 23:42:09 +0000 (UTC) X-Spam-Summary: 1,0,0,08c73a8a58ae947c,d41d8cd98f00b204,30erixwykchsxtygznfnnfkd.bnlkhmtw-lljuzbj.nqf@flex--yuzhao.bounces.google.com,,RULES_HIT:41:69:152:355:379:541:800:960:966:973:988:989:1260:1277:1313:1314:1345: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: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:21080:21444:21611:21627:21740:30054,0,RBL:209.85.219.202:@flex--yuzhao.bounces.google.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100;04y8jof48omumzof64idxf69cfwb1ycgm3znqes3k9pd8xs1o9sepiamtfhkoxn.xp66hqgeh65g8g9tgwctke4oj6htbbgymqc6ec3hbkdmj8h7kbsp8detfxpa1jp.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:25,LUA_SUMMARY:none X-HE-Tag: cork87_45015f027071 X-Filterd-Recvd-Size: 5294 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Thu, 27 Aug 2020 23:42:09 +0000 (UTC) Received: by mail-yb1-f202.google.com with SMTP id b127so9526921ybh.21 for ; Thu, 27 Aug 2020 16:42:08 -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=uX2C0brQgg3f8KYRiompEJ5CYWD+yHko0WX19R75qh8=; b=iCkxPIo12K6HRayC/lbc1sUHAkytPkhbNtKmEcONs+Z3rnesvOYfbff1WkffIQP/kl QHaXLH9YqCygDflVvqUyqRq3ZJQ9vWfwR6pZ/sSrXKzwcg4jpJtyEU4vXUHnap6tMb+Q RI0Q0d7cQOMA9T4enLSsBrfbo+F43F2Ze5qYoNJR0sHESGhJDXQ3BKVEhvgEq/Hj6r8p 2tx8hknDosNfzWbosydyH1bDlEZhgMaJKjQcSKuVDCpkLg9CwnuCYcsKMXVvHZkpJQyT cOeD0y654fMR7YVn2VhPimn3LDfFaEF6V0/TgaAPtctzNlUF4pESeMYN65saopPFYcVD dhNQ== 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=uX2C0brQgg3f8KYRiompEJ5CYWD+yHko0WX19R75qh8=; b=nKY2jq3gBPM5gCxFqZOiFWyVLsBMLdm+McEN4+I59GFxjlntnWxaBc0/nTUqF00H7+ pcjqy2zgZF0GDw/U1avCofgyoWlKN2uazYrCRKOtRjbYNXtlifQKq89iN27MCzuRl+AF tt2e0GRYlhUAiG91+vO/poQTLWUxRVzU6N7oAkO0BvxLlXaY8wd8gTslhqcXdKm+XDfa mrffUpXJTEyWkqVuluJ4/j9neotJAq/6ohg77y9I4yFceRTt5Urcf0bu8dwTFThE1AJv qbNEswGobs92NsRPI59qypNJWAdwUlSZR5sXN05orZA3w6snheSYF1EQWCCsL0ms8wRa QE/Q== X-Gm-Message-State: AOAM532WYEQDte7J5fcKpVQ5TbcoTAvx/zIjzhYwhJnpKJzSaSBIvH8+ /4+D52MmdrYgH9toWm0iiroUWW3L0RA= X-Google-Smtp-Source: ABdhPJwr1O7Q0pzaHP/0dpJxBxlOQE337tFMlssyqq7bHrG5DkLvoMIjZO33y8/dm4RBOB2hEALMCyEuOgA= X-Received: from yuzhao.bld.corp.google.com ([2620:15c:183:200:7220:84ff:fe09:2d90]) (user=yuzhao job=sendgmr) by 2002:a25:dc85:: with SMTP id y127mr32591366ybe.462.1598571728326; Thu, 27 Aug 2020 16:42:08 -0700 (PDT) Date: Thu, 27 Aug 2020 17:42:01 -0600 Message-Id: <20200827234202.4027996-1-yuzhao@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog Subject: [PATCH 1/2] mm: use add_page_to_lru_list()/page_lru()/page_off_lru() From: Yu Zhao To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yu Zhao X-Rspamd-Queue-Id: 9AAEA18229835 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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). Signed-off-by: Yu Zhao --- mm/swap.c | 4 +--- mm/vmscan.c | 14 ++++---------- 2 files changed, 5 insertions(+), 13 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..b479ced26cd3 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,10 @@ 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 +1871,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);