From patchwork Sat Apr 11 10:11:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenqiwu X-Patchwork-Id: 11484065 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 B8B4481 for ; Sat, 11 Apr 2020 10:12:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7B77520709 for ; Sat, 11 Apr 2020 10:12:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Pf0JEOs4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7B77520709 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 88B778E00A9; Sat, 11 Apr 2020 06:12:12 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 83CC68E0007; Sat, 11 Apr 2020 06:12:12 -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 752748E00A9; Sat, 11 Apr 2020 06:12:12 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0028.hostedemail.com [216.40.44.28]) by kanga.kvack.org (Postfix) with ESMTP id 5C78B8E0007 for ; Sat, 11 Apr 2020 06:12:12 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 1E9B98245571 for ; Sat, 11 Apr 2020 10:12:12 +0000 (UTC) X-FDA: 76695158904.04.mask89_8795360fa6b53 X-Spam-Summary: 2,0,0,ee40108c18437d99,d41d8cd98f00b204,qiwuchen55@gmail.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1359:1437:1534:1542:1711:1730:1747:1777:1792:2393:2559:2562:2898:3138:3139:3140:3141:3142:3353:3865:3866:3867:4250:4321:5007:6119:6261:6653:7576:9413:10004:11026:11473:11658:11914:12043:12048:12296:12297:12438:12517:12519:12555:12679:12895:13255:14181:14394:14721:21080:21444:21451:21627:21666:30012:30054:30070,0,RBL:209.85.216.66:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.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: mask89_8795360fa6b53 X-Filterd-Recvd-Size: 5000 Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Sat, 11 Apr 2020 10:12:11 +0000 (UTC) Received: by mail-pj1-f66.google.com with SMTP id t40so1667383pjb.3 for ; Sat, 11 Apr 2020 03:12:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7s8+SiauSEv/YpKtd1pikErl5fNcXJDNTR96pshyq6o=; b=Pf0JEOs43MUlug9jc3fYtUZdvGWmMCgRI4gIdk4Bn3/f27seTwOurFVJ/uZK6Q3t+q e9/IPnqz2r+8wCcB4MVKdsGd/OvV+Orn1QIYofh185hZrlDpT0qXJYOZ0ArieFQcOcuW FaFkpVULTZTWhKxt+U5NtHYgVtT5a1O9Jq63htoZifVxM0Dati2xu+3y+3bJjEZFmAcG sA7AnOTUkeQfgeXIoEBbwTwatAhorzp9ahNSn9F4ZDFEBaBBe3ggZawYk/taT6naoEfa YvxebllJDbr8eZJHn3PK8UBK5BKMbvryzrElrhzdt34b7JjQPqb++/12EKu5DGw1cD2s 97BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7s8+SiauSEv/YpKtd1pikErl5fNcXJDNTR96pshyq6o=; b=aC4a0WYwO6dTV0WlsYXpurTmOnwR0I4EjHJAT+hAOl0D5IMQTdnTQCkH9QLJXy1Rxo 2Fp2fHi1FCwSWsWvDQr9sPl4T98VgTlzd2Xbk2BIiG3Lu03qYG4zW7rI5bPBKbo2xSzv 3SL4XWXmyBcwTA4z+C1WWYgbJctUN3neatn/NYXtLtYaD1hGC38Y3WIdI9muaiNlXsX5 0qBa1xk9OLWJS6eB5yWjuDn0c73/QKK2LACrYVxvqrRKjkcn3mOc71s0RxXA1nTAxCaw QStF7a2nPIVglbUnN6RCDtEa+gQbEpOcVNmvNl+E7/yQI4ExuidNYlIHOkzn9Ym4Yzut jKvg== X-Gm-Message-State: AGi0PuaR2BIFkXmMXVvz7sckm5B8nr0aJnpS/vz5W29ToJ5ZvB9ch637 mo6oRtXTqC1R44rqZzaWB3g= X-Google-Smtp-Source: APiQypJKO41SwoGYtMr0W78Iy4uRRnomN4YPjQ1CcHK8Gd4pMjlPVLol/r86FW15PfZ8WWS+pKcJNQ== X-Received: by 2002:a17:90a:a402:: with SMTP id y2mr10777507pjp.55.1586599930865; Sat, 11 Apr 2020 03:12:10 -0700 (PDT) Received: from localhost ([43.224.245.179]) by smtp.gmail.com with ESMTPSA id e143sm933711pfh.98.2020.04.11.03.12.10 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Sat, 11 Apr 2020 03:12:10 -0700 (PDT) From: qiwuchen55@gmail.com To: akpm@linux-foundation.org, willy@infradead.org, david@redhat.com, richard.weiyang@gmail.com, mhocko@suse.com, pankaj.gupta.linux@gmail.com, yang.shi@linux.alibaba.com, cai@lca.pw, bhe@redhat.com Cc: linux-mm@kvack.org, chenqiwu Subject: [RESEND PATCH 3/3] mm/vmscan: make several optimizations for isolate_lru_pages() Date: Sat, 11 Apr 2020 18:11:56 +0800 Message-Id: <1586599916-15456-3-git-send-email-qiwuchen55@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1586599916-15456-1-git-send-email-qiwuchen55@gmail.com> References: <1586599916-15456-1-git-send-email-qiwuchen55@gmail.com> 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: From: chenqiwu 1) Simplify the code of initializing some variables. 1) Constify the LRU isolation mode. 2) Define a page_zoneidx variable to reduce the redundant code of page_zonenum(). Signed-off-by: chenqiwu --- mm/vmscan.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index b06868f..2f65a91 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1638,16 +1638,15 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan, struct list_head *src = &lruvec->lists[lru]; unsigned long nr_taken = 0; unsigned long nr_zone_taken[MAX_NR_ZONES] = { 0 }; - unsigned long nr_skipped[MAX_NR_ZONES] = { 0, }; + unsigned long nr_skipped[MAX_NR_ZONES] = { 0 }; unsigned long skipped = 0; - unsigned long scan, total_scan, nr_pages; + unsigned long scan = 0, total_scan = 0, nr_pages; LIST_HEAD(pages_skipped); - isolate_mode_t mode = (sc->may_unmap ? 0 : ISOLATE_UNMAPPED); + const isolate_mode_t mode = (sc->may_unmap ? 0 : ISOLATE_UNMAPPED); - total_scan = 0; - scan = 0; while (scan < nr_to_scan && !list_empty(src)) { struct page *page; + enum zone_type page_zoneidx; page = lru_to_page(src); prefetchw_prev_lru_page(page, src, flags); @@ -1657,9 +1656,10 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan, nr_pages = compound_nr(page); total_scan += nr_pages; - if (page_zonenum(page) > sc->reclaim_idx) { + page_zoneidx = page_zonenum(page); + if (page_zoneidx > sc->reclaim_idx) { list_move(&page->lru, &pages_skipped); - nr_skipped[page_zonenum(page)] += nr_pages; + nr_skipped[page_zoneidx] += nr_pages; continue; } @@ -1677,7 +1677,7 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan, switch (__isolate_lru_page(page, mode)) { case 0: nr_taken += nr_pages; - nr_zone_taken[page_zonenum(page)] += nr_pages; + nr_zone_taken[page_zoneidx] += nr_pages; list_move(&page->lru, dst); break;