From patchwork Fri Apr 3 07:08:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenqiwu X-Patchwork-Id: 11471935 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 DEB8992A for ; Fri, 3 Apr 2020 07:09:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id ABC7120CC7 for ; Fri, 3 Apr 2020 07:09:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="f/6GCu/g" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ABC7120CC7 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 AF0668E0009; Fri, 3 Apr 2020 03:09:04 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id AA2098E0007; Fri, 3 Apr 2020 03:09:04 -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 9B8F78E0009; Fri, 3 Apr 2020 03:09:04 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0107.hostedemail.com [216.40.44.107]) by kanga.kvack.org (Postfix) with ESMTP id 7C8118E0007 for ; Fri, 3 Apr 2020 03:09:04 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 3B80A6103 for ; Fri, 3 Apr 2020 07:09:04 +0000 (UTC) X-FDA: 76665667008.26.cover41_6c437ece8543b X-Spam-Summary: 2,0,0,3e16afeba4270733,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:4321:5007:6119:6261:6653:7576:9413:10004:11026:11473:11658:11914:12043:12296:12297:12438:12517:12519:12555:12679:12895:14181:14394:14721:21080:21444:21451:21627:21666:30012:30054:30070,0,RBL:209.85.214.196:@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:23,LUA_SUMMARY:none X-HE-Tag: cover41_6c437ece8543b X-Filterd-Recvd-Size: 4977 Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by imf37.hostedemail.com (Postfix) with ESMTP for ; Fri, 3 Apr 2020 07:09:03 +0000 (UTC) Received: by mail-pl1-f196.google.com with SMTP id w3so2364329plz.5 for ; Fri, 03 Apr 2020 00:09:03 -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=LGvDKN0ALlk06+d1xgRhJlTW8R5sXEolJFf66toYiqA=; b=f/6GCu/gEfuskjFM3bNjp231yE9H2aQu64vsB5XTBpQkB/Y3IuWQsctWR0HGU3/6F3 SgCT4g5RU5vTAA2va3djFIec4yR0BgWi+wkT1T+nNbIuOxyPCEKzpnj32D00n5dlhGB2 jYRmfNd4T+RMIL+UpD2KTQuRjwME/OQNokUM/F6VPz/KISxUq+n+NU+jfl8COozPMg9E VEnE4JxBs0JCAZl98L+8b2eOkahD4ltyKuD5gSXZfymoAfAPIlC2UPmS1MxhG3+HQjWn rA01ZoNQ+pJCdQbTyW8WjKS6u35iVs2sqPzRDV8/XQYwE193yJykmn/jPF7zgzlty+HE U7xw== 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=LGvDKN0ALlk06+d1xgRhJlTW8R5sXEolJFf66toYiqA=; b=aijIEDLwzHRi3+uva7Ex+WEb/mnAi6wq+rqU0Dl+eveCrcB7ErKzqcc/nZb2CJ5Tqm o/mRTpxOQumKAfdghtLLO8iPklqh+gc4e9GIl6D3z+7MU2ebdgpjH+/y8M4y3rhdjM4o Ef23HgkBQpyhXjOHL7hdSMYTLgQ27eROfhHi9OmZsNUoAxxstv3B1pWhZDjrJvFtgpCK F4PcOxQdHGXn6HNFKV0CwgzaA7+Hcnf0iN7upYamVojW52sP6MBHNvC5NC6WqTAL+6Si T9/3imZMw53B5NI8D2VIa48riFg6Gh+TYMZ6DYsidmtGunX0GXDpgyATjQf6yAzHjc6g 1MYw== X-Gm-Message-State: AGi0PuZNXe8fYt/oaLp0u/YDnOQwnkPNZ/a5z+qQpJzHHyoNslGrnZUC ieM0dAXJSxUzeeRSgh2Fxko= X-Google-Smtp-Source: APiQypISuOsRz719Ls1APINfCWFvTRXPMcNlw1E1YhVLv9Ni/xZcZvE69A9h2wK+QgcxggQFNXCkvw== X-Received: by 2002:a17:90a:5d96:: with SMTP id t22mr8399663pji.132.1585897742785; Fri, 03 Apr 2020 00:09:02 -0700 (PDT) Received: from localhost ([43.224.245.179]) by smtp.gmail.com with ESMTPSA id e187sm5171287pfe.50.2020.04.03.00.09.01 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 03 Apr 2020 00:09:02 -0700 (PDT) From: qiwuchen55@gmail.com To: akpm@linux-foundation.org Cc: alexander.h.duyck@linux.intel.com, willy@infradead.org, vbabka@suse.cz, pankaj.gupta.linux@gmail.com, bhe@redhat.com, mhocko@kernel.org, linux-mm@kvack.org, chenqiwu Subject: [PATCH 2/2] mm/vmscan: make several optimizations for isolate_lru_pages() Date: Fri, 3 Apr 2020 15:08:53 +0800 Message-Id: <1585897733-4696-2-git-send-email-qiwuchen55@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1585897733-4696-1-git-send-email-qiwuchen55@gmail.com> References: <1585897733-4696-1-git-send-email-qiwuchen55@gmail.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, 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 for initializing some variables. 1) Add const modifier to decorate the mode variable. 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 8763705..cf90e8b 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1639,16 +1639,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); @@ -1658,9 +1657,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; } @@ -1678,7 +1678,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;