From patchwork Fri Sep 18 03:00:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhao X-Patchwork-Id: 11783917 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 12C8559D for ; Fri, 18 Sep 2020 03:01:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A156F2395B for ; Fri, 18 Sep 2020 03:01:03 +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="lqyqyA8B" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A156F2395B 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 1300D6B0071; Thu, 17 Sep 2020 23:01:02 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0E2F16B0072; Thu, 17 Sep 2020 23:01:02 -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 EEC6D8E0001; Thu, 17 Sep 2020 23:01:01 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0041.hostedemail.com [216.40.44.41]) by kanga.kvack.org (Postfix) with ESMTP id CADFE6B0071 for ; Thu, 17 Sep 2020 23:01:01 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 8F11D3629 for ; Fri, 18 Sep 2020 03:01:01 +0000 (UTC) X-FDA: 77274680322.28.drop76_3c0042227127 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id 701576C04 for ; Fri, 18 Sep 2020 03:01:01 +0000 (UTC) X-Spam-Summary: 1,0,0,f631789aa90eac1c,d41d8cd98f00b204,37cjkxwykcmm738qjxpxxpun.lxvurw36-vvt4jlt.x0p@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:1541:1593:1594:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:3138:3139:3140:3141:3142:3152:3352:3865:3871:3874:4321:4385:5007:6261:6653:6742:8957:9010:9969:10004:10400:11026:11473:11658:11914:12043:12114:12297:12438:12555:12895:13069:13161:13229:13311:13357:14181:14394:14659:14721:21080:21444:21451:21627:21740:30054,0,RBL:209.85.219.201:@flex--yuzhao.bounces.google.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100;04yr75f3z97y8dx9hy76r4om1pfd4opqxsuuxnxdf5dmiufeuqoxru1hnxrxsi8.3cmuwuhiyfdmgsfdppz1h9sof4jo18cg9hrwdw51rfbaetzjuqbh5wnoc4di1uq.k-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:23,LUA_SUMMARY:none X-HE-Tag: drop76_3c0042227127 X-Filterd-Recvd-Size: 5227 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf32.hostedemail.com (Postfix) with ESMTP for ; Fri, 18 Sep 2020 03:01:00 +0000 (UTC) Received: by mail-yb1-f201.google.com with SMTP id 141so4032644ybe.15 for ; Thu, 17 Sep 2020 20:01:00 -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=qvnHHsvBI3sH+b5g6Iv8RJ5s4+ZnaHU0vmrrO4o5gi4=; b=lqyqyA8BFWcwFuv/9+MGNQiOru0sKjIbm0eSJ1ByXF6JVc9vr8FDv47rnqSsdyTs7t S3NxZnk+2iO6CRHdaA4UalB3w3yZF3qC28jCD2uRk5cxex4zVBD5qDQbnTRcrAf07Nsc ygcQl37PtmLBFqLAL8rbF46ASLQ1gAydzClOP5DevnlAsHwK/PfIrGSFDMam+ySaujJT hanmi+54Txv+6VjCu9U3o7d4IJIv2iwSEqK4D9aDrbo1zTg7iqka8SpMD+NpS6lHugQs AtUjhjYt1eOv7g1ZT8k0bRjvxL28/U/JID1UhXh/ggjhBucFBF095ClBMUlEnjXVJwfd 7itA== 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=qvnHHsvBI3sH+b5g6Iv8RJ5s4+ZnaHU0vmrrO4o5gi4=; b=PPAHLOg7fZc9cvJZnskw15o8tDYe8PJ3fR5B217kKXzMk8WWn23TgIzlTLszFUn1k9 hAfbxzLJqopNs9Q8xrC6bk0c14wKfeQ/YBpK/o1pd13rjFLqVLW/EarO3o+9PCuZtvRY H4Aclcxgpsx9SbHaXY5iNcmMh7psyQtHxj51UkIzjXUgYC690kCYEwkhuj7o7gCB+Skm cAjrBcZ4lgHz/TMYKhdJ6C9N4aav5BgNE4q2+6WhlJh+QCqWPD1LDZGLs0jl9DcbwfPF 6WPtOU4RrFcplDMs9HuxTqQiGlBBI3v4TmFDmTjJFsGjKW/LCBSZpUpcRjhnRKwcwc54 J76g== X-Gm-Message-State: AOAM530xY5movEMh7vHXGkavRHEYIjchmmeoYdgO7BbM7dikBly8GcVC 3hdFJWBUxT8m8VgR8n4KH+Nrcqu4qAw= X-Google-Smtp-Source: ABdhPJyA4fGWHBfcQZD/N2EVVdQdNHe3Em/oy/TsXnSZ8yngh1zsEqbYH+EijegunexsuYkqKBR265IH8Wg= X-Received: from yuzhao.bld.corp.google.com ([2620:15c:183:200:7220:84ff:fe09:2d90]) (user=yuzhao job=sendgmr) by 2002:a25:ad16:: with SMTP id y22mr6703066ybi.331.1600398060014; Thu, 17 Sep 2020 20:01:00 -0700 (PDT) Date: Thu, 17 Sep 2020 21:00:39 -0600 In-Reply-To: <20200918030051.650890-1-yuzhao@google.com> Message-Id: <20200918030051.650890-2-yuzhao@google.com> Mime-Version: 1.0 References: <20200918030051.650890-1-yuzhao@google.com> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH 01/13] mm: use add_page_to_lru_list() From: Yu Zhao To: Andrew Morton , Michal Hocko Cc: Alex Shi , Steven Rostedt , Ingo Molnar , Johannes Weiner , Vladimir Davydov , Roman Gushchin , Shakeel Butt , Chris Down , Yafang Shao , Vlastimil Babka , Huang Ying , Pankaj Gupta , Matthew Wilcox , Konstantin Khlebnikov , Minchan Kim , Jaewon Kim , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yu Zhao 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 patch replaces the only open-coded lru list addition with add_page_to_lru_list(). Before this patch, we have: update_lru_size() list_move() After this patch, we have: list_del() add_page_to_lru_list() update_lru_size() list_add() The only side effect is that page->lru is temporarily poisoned after a page is deleted from its old list, which shouldn't be a problem. Signed-off-by: Yu Zhao --- mm/vmscan.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 9727dd8e2581..503fc5e1fe32 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1850,8 +1850,8 @@ static unsigned noinline_for_stack move_pages_to_lru(struct lruvec *lruvec, 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); @@ -1862,9 +1862,7 @@ static unsigned noinline_for_stack move_pages_to_lru(struct lruvec *lruvec, 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, lru); if (put_page_testzero(page)) { __ClearPageLRU(page); @@ -1878,6 +1876,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);