From patchwork Tue Aug 20 09:48:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 11103491 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 DA3C81398 for ; Tue, 20 Aug 2019 09:49:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AF94422CF7 for ; Tue, 20 Aug 2019 09:49:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AF94422CF7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E510F6B026A; Tue, 20 Aug 2019 05:49:43 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D140F6B026B; Tue, 20 Aug 2019 05:49:43 -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 BB6E66B026C; Tue, 20 Aug 2019 05:49:43 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0102.hostedemail.com [216.40.44.102]) by kanga.kvack.org (Postfix) with ESMTP id 800096B026B for ; Tue, 20 Aug 2019 05:49:43 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 25948181AC9B6 for ; Tue, 20 Aug 2019 09:49:43 +0000 (UTC) X-FDA: 75842334246.17.night49_54b2154014148 X-Spam-Summary: 2,0,0,ad25e7666eed6aba,d41d8cd98f00b204,alex.shi@linux.alibaba.com,:cgroups@vger.kernel.org:linux-kernel@vger.kernel.org::akpm@linux-foundation.org:mgorman@techsingularity.net:tj@kernel.org:alex.shi@linux.alibaba.com:mhocko@suse.com:vbabka@suse.cz:jgg@ziepe.ca:willy@infradead.org:mchehab+samsung@kernel.org:peng.fan@nxp.com:nborisov@suse.com:ira.weiny@intel.com:aryabinin@virtuozzo.com,RULES_HIT:41:69:355:379:541:800:960:966:973:988:989:1260:1261:1345:1359:1431:1437:1535:1543:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2559:2562:2898:3138:3139:3140:3141:3142:3167:3354:3865:3866:3871:3874:4385:4605:5007:6261:8957:10004:11026:11473:11658:11914:12043:12048:12291:12296:12297:12438:12555:12683:12895:13846:14096:14181:14394:14721:21060:21080:21451:21627:30054:30064:30070,0,RBL:115.124.30.57:@linux.alibaba.com:.lbl8.mailshell.net-62.20.2.100 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_r ules:0:0 X-HE-Tag: night49_54b2154014148 X-Filterd-Recvd-Size: 5342 Received: from out30-57.freemail.mail.aliyun.com (out30-57.freemail.mail.aliyun.com [115.124.30.57]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Tue, 20 Aug 2019 09:49:41 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R561e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04446;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---0Ta-6ujV_1566294576; Received: from localhost(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0Ta-6ujV_1566294576) by smtp.aliyun-inc.com(127.0.0.1); Tue, 20 Aug 2019 17:49:36 +0800 From: Alex Shi To: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Mel Gorman , Tejun Heo Cc: Alex Shi , Michal Hocko , Vlastimil Babka , Jason Gunthorpe , Matthew Wilcox , Mauro Carvalho Chehab , Peng Fan , Nikolay Borisov , Ira Weiny , Andrey Ryabinin Subject: [PATCH 10/14] lru/swap: use per lruvec lock in release_pages Date: Tue, 20 Aug 2019 17:48:33 +0800 Message-Id: <1566294517-86418-11-git-send-email-alex.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1566294517-86418-1-git-send-email-alex.shi@linux.alibaba.com> References: <1566294517-86418-1-git-send-email-alex.shi@linux.alibaba.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: Replace pgdat lru_lock with lruvec lru_lock. Signed-off-by: Alex Shi Cc: Andrew Morton Cc: Michal Hocko Cc: Vlastimil Babka Cc: Jason Gunthorpe Cc: Matthew Wilcox Cc: Mauro Carvalho Chehab Cc: Peng Fan Cc: Nikolay Borisov Cc: Ira Weiny Cc: Andrey Ryabinin Cc: cgroups@vger.kernel.org Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- mm/swap.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/mm/swap.c b/mm/swap.c index 24a2b3456e10..798bffe7875d 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -724,8 +724,7 @@ void release_pages(struct page **pages, int nr) { int i; LIST_HEAD(pages_to_free); - struct pglist_data *locked_pgdat = NULL; - struct lruvec *lruvec; + struct lruvec *locked_lruvec = NULL; unsigned long uninitialized_var(flags); unsigned int uninitialized_var(lock_batch); @@ -737,19 +736,19 @@ void release_pages(struct page **pages, int nr) * excessive with a continuous string of pages from the * same pgdat. The lock is held only if pgdat != NULL. */ - if (locked_pgdat && ++lock_batch == SWAP_CLUSTER_MAX) { - spin_unlock_irqrestore(&locked_pgdat->lruvec.lru_lock, flags); - locked_pgdat = NULL; + if (locked_lruvec && ++lock_batch == SWAP_CLUSTER_MAX) { + spin_unlock_irqrestore(&locked_lruvec->lru_lock, flags); + locked_lruvec = NULL; } if (is_huge_zero_page(page)) continue; if (is_zone_device_page(page)) { - if (locked_pgdat) { - spin_unlock_irqrestore(&locked_pgdat->lruvec.lru_lock, + if (locked_lruvec) { + spin_unlock_irqrestore(&locked_lruvec->lru_lock, flags); - locked_pgdat = NULL; + locked_lruvec = NULL; } /* * ZONE_DEVICE pages that return 'false' from @@ -766,27 +765,30 @@ void release_pages(struct page **pages, int nr) continue; if (PageCompound(page)) { - if (locked_pgdat) { - spin_unlock_irqrestore(&locked_pgdat->lruvec.lru_lock, flags); - locked_pgdat = NULL; + if (locked_lruvec) { + spin_unlock_irqrestore(&locked_lruvec->lru_lock, flags); + locked_lruvec = NULL; } __put_compound_page(page); continue; } if (PageLRU(page)) { + struct lruvec *lruvec; struct pglist_data *pgdat = page_pgdat(page); - if (pgdat != locked_pgdat) { - if (locked_pgdat) - spin_unlock_irqrestore(&locked_pgdat->lruvec.lru_lock, + lruvec = mem_cgroup_page_lruvec(page, pgdat); + + if (lruvec != locked_lruvec) { + if (locked_lruvec) + spin_unlock_irqrestore(&locked_lruvec->lru_lock, flags); lock_batch = 0; - locked_pgdat = pgdat; - spin_lock_irqsave(&locked_pgdat->lruvec.lru_lock, flags); + locked_lruvec = lruvec; + spin_lock_irqsave(&locked_lruvec->lru_lock, flags); + sync_lruvec_pgdat(lruvec, pgdat); } - lruvec = mem_cgroup_page_lruvec(page, locked_pgdat); VM_BUG_ON_PAGE(!PageLRU(page), page); __ClearPageLRU(page); del_page_from_lru_list(page, lruvec, page_off_lru(page)); @@ -798,8 +800,8 @@ void release_pages(struct page **pages, int nr) list_add(&page->lru, &pages_to_free); } - if (locked_pgdat) - spin_unlock_irqrestore(&locked_pgdat->lruvec.lru_lock, flags); + if (locked_lruvec) + spin_unlock_irqrestore(&locked_lruvec->lru_lock, flags); mem_cgroup_uncharge_list(&pages_to_free); free_unref_page_list(&pages_to_free);