Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3823397ybl; Tue, 20 Aug 2019 02:50:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqxPi1vOMKRcbY+79jKs5dL3Joc7dI5p++WLx3ldxfB/+1oWqHYSwWB+QRg5YHTcUoLKqYpC X-Received: by 2002:a63:66c5:: with SMTP id a188mr23817352pgc.127.1566294655696; Tue, 20 Aug 2019 02:50:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566294655; cv=none; d=google.com; s=arc-20160816; b=Y19rBNYY4BNU9WBR+ZzLaeVcetOEQLEgyKtZ27LEyK+yvozGKbELFqPckvxpE6R9MH bL5ovD4mxEPPD9nDFLana8eAaDle9Y/aAoqiRAEI1a5nmLd30Y376YAnnQpVWxspWjPW Y1tqzEeLs3yrJYN42GDYs18HNMg38spXJ9mdInkeIKJ6/N0N7Bqn2oYRkZkhgDXQg/1j miW+uKCzXsNCOduvzX7UzNxajteYZt1jnWPZlpdk/byncorCmoU4KZ6PATLRra5l+ACf sZUILxtlL+F/UmQYmpPTYZJRKdyj6OIMCzw0h3MtWg8MATAm2ClkkN0R4N3FRZnlprOf czog== 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=UrunVt3nYSAxGMoSXiHFGsltMm4jRyM0ppGUsfDOkSc=; b=dRHn78pMomZ8ZKm/mQzUnx9lPZrMsg43VmBeGwdoLQ9qgbFmWJnlkyhKTx2usIaBKA RcrOeS5XtGCVPmiV9zi6+3ApLB8DYaEl3Aig+Zs4VI8CMRArr45G2Hwlnkauum91cuIE RlXvY3XbEQKWCea1JV7QKPWB8tFOCArIt7R4qtxVeaIYgdxjhN0FVz74lM6mNjy0RRme X3uEcUy67sjpzL3uoa4rjScx/Fx9IYG7kHpBaGr9irwh6G/LukZ2mC6m36jYhCnEVnKN l4aUAru7PyqPZtbQqNSL3D2yp1ZCRPkAmoV7HTESqjxCT74AmmBtpeIHrZx4FGX7KgNJ pqSw== 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 r14si11763401pgm.406.2019.08.20.02.50.40; Tue, 20 Aug 2019 02:50:55 -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 S1729689AbfHTJtl (ORCPT + 99 others); Tue, 20 Aug 2019 05:49:41 -0400 Received: from out30-131.freemail.mail.aliyun.com ([115.124.30.131]:40890 "EHLO out30-131.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728426AbfHTJtl (ORCPT ); Tue, 20 Aug 2019 05:49:41 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R101e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07486;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---0Ta-BP3A_1566294575; Received: from localhost(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0Ta-BP3A_1566294575) 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 09/14] lru/swap: uer per lruvec lock in pagevec_lru_move_fn Date: Tue, 20 Aug 2019 17:48:32 +0800 Message-Id: <1566294517-86418-10-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 to replace pgdat 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 | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/mm/swap.c b/mm/swap.c index d2dad08fcfd0..24a2b3456e10 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -192,26 +192,27 @@ static void pagevec_lru_move_fn(struct pagevec *pvec, void *arg) { int i; - struct pglist_data *pgdat = NULL; - struct lruvec *lruvec; + struct lruvec *locked_lruvec = NULL; unsigned long flags = 0; for (i = 0; i < pagevec_count(pvec); i++) { struct page *page = pvec->pages[i]; - struct pglist_data *pagepgdat = page_pgdat(page); - - if (pagepgdat != pgdat) { - if (pgdat) - spin_unlock_irqrestore(&pgdat->lruvec.lru_lock, flags); - pgdat = pagepgdat; - spin_lock_irqsave(&pgdat->lruvec.lru_lock, flags); + struct pglist_data *pgdat = page_pgdat(page); + struct lruvec *lruvec = mem_cgroup_page_lruvec(page, pgdat); + + if (locked_lruvec != lruvec) { + if (locked_lruvec) + spin_unlock_irqrestore(&locked_lruvec->lru_lock, flags); + locked_lruvec = lruvec; + spin_lock_irqsave(&lruvec->lru_lock, flags); + sync_lruvec_pgdat(lruvec, pgdat); } - lruvec = mem_cgroup_page_lruvec(page, pgdat); (*move_fn)(page, lruvec, arg); } - if (pgdat) - spin_unlock_irqrestore(&pgdat->lruvec.lru_lock, flags); + if (locked_lruvec) + spin_unlock_irqrestore(&locked_lruvec->lru_lock, flags); + release_pages(pvec->pages, pvec->nr); pagevec_reinit(pvec); } -- 1.8.3.1