Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3824749ybl; Tue, 20 Aug 2019 02:52:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqzmpxV92OBckEO4NLkDxmcDGzVlHQ4hMJTt6otrC57/aI6LOE4byAm8MmothDbMZnEjzePp X-Received: by 2002:a17:90a:fe5:: with SMTP id 92mr25569790pjz.35.1566294750031; Tue, 20 Aug 2019 02:52:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566294750; cv=none; d=google.com; s=arc-20160816; b=sUVAmDj+2i448XmUA9nAVxktAPwIr+1RWpRXyDsLsMiSOust/fDEvjAUzeMnCp126T 6UOpZFGJkcnR+jB2tELgPaFaUWn5ghYvjxHckHst66EzYGcJpDxufNOoge6xCK6ttBcZ Ig25QAkj3YNKtxgBlch3SC2SM7p2gCVdDEaNRnByyW8HKGAiCKiR25A/OEhc+d1dpWay Hdv6b3dPbFI1N1D3lZ4WlLTiDKg0Ihe54ucoAKsjDDvLuvxbsSvn/nEznm4b4cgmquaK 7sHlSBEeRPatNuqSXO2+n0oZmFi5CTk8tAPomo2TLSbEfxJkKww66i/1TFS5gief2C4y MP8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=I4nJ75w9SuS+XedpqVMRAwXI1ilQcGxA0ueXTTYOXsE=; b=NQeX3Iu+iZ4Q4Xjft005HhUMQDTS14fg0G+V6C7Lfa3pID3MzBJkuEKdnEqAzlFDtP FGjNGrFbNnpAG5nCNUaQAmy0J+gTIVL1VbyIMnSOFhDkigHPPDN85MY2azSmVNr0GvXe ZvwdLa3yn72hp97qtoBQ6vuOHXKTow5Km48WOd6aglU2jasG0aRFNIc57ilOogqLBgEH mRgWWoIuE4CiomDdG4bE6GHQxZh0WIHpnbzwEfI+vkMNgB+X6OgY+oUrUwOeshVDEmZq 1PNVtrbYQdl+xiaiDwBCJei42SgHJW6gOJ+3muqyeg5C6QEtYPc5EpHDQouJIcTRB7sL E35w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j127si12654932pfg.12.2019.08.20.02.52.15; Tue, 20 Aug 2019 02:52:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729814AbfHTJuB (ORCPT + 99 others); Tue, 20 Aug 2019 05:50:01 -0400 Received: from out30-56.freemail.mail.aliyun.com ([115.124.30.56]:57118 "EHLO out30-56.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729763AbfHTJtr (ORCPT ); Tue, 20 Aug 2019 05:49:47 -0400 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 1.8.3.1