Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8546504ybl; Wed, 25 Dec 2019 01:05:46 -0800 (PST) X-Google-Smtp-Source: APXvYqxFPUcUxlp6zhKNYdUKUf8qny88aUV4MjSDX5GW8FoNMgE7Wm5ix7ryuKZ4YI9qWknrtGrM X-Received: by 2002:aca:4ad1:: with SMTP id x200mr1355754oia.104.1577264746716; Wed, 25 Dec 2019 01:05:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577264746; cv=none; d=google.com; s=arc-20160816; b=XWb5wQlWObrYHA32ceKm441LLHSMeKWLdJ1sJo6B0fk6+/0XjJi2OMFpVSSrJi6US5 SRMf+VIHoDY3rx29zw1BRJTSvmVkwk9cwz/LQCoppT8JmGLDzckH6HpzyDYxYI/nKUu7 1W5ukyQk6kf6Mw/9bpsw7gFc0JwULRNLFy+PYg34YWj1opAwkshHaUsR0ryJ6zuGjxA+ DEd/760Jiy7/H7uFIq/nF1CkInaYAJ2CO7AhFHb9+8HI/FjybcCm3dfbNib7ddmeKyIR N3RRbC6j9sTHvrwD8Vz7n+JzbiaS7ZPiOiVMgpzkYhCv+UeuYQPRZx52XOcMlCrrkda0 s8aA== 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=SB+CTba4ePG3Ng4BBHTPPpdTXJzl6slgsh5xKtbJnJE=; b=mjdmYOzLsuHGdiETFeQ1IbXE7l76xGlFGQk0jGWKaxB51uNLziCUwH8J6R29rQ7Qfp jB4hegiC3ri75oDKSg03/Ow/UyPMamc4pYwg25Hdw2FRCL1rprGRQVQDt5HDS7XBFOAC IsojfcLeneWacfEFAeWTSlZCF1uIw3VdCBrYbMDWDt4kalRDXB5WDJSTV6PZH7El2pKM XnqQ3yiuIaAU54wR0LIcH9xaocnfpkA15ywiwFEybwERZgi1YqsInZH9QkT3WX0oeD5v O8AB7kGRTpXfrMow//5yaMvjShEwgvMEtVRelfa4SwjTqDEdUdzjm9F1LrZRS4eHkCoX i2XQ== 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 s5si4663885oic.116.2019.12.25.01.05.35; Wed, 25 Dec 2019 01:05:46 -0800 (PST) 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 S1726896AbfLYJEu (ORCPT + 99 others); Wed, 25 Dec 2019 04:04:50 -0500 Received: from out30-54.freemail.mail.aliyun.com ([115.124.30.54]:58791 "EHLO out30-54.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726435AbfLYJEt (ORCPT ); Wed, 25 Dec 2019 04:04:49 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04407;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---0TltDsS6_1577264683; Received: from localhost(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0TltDsS6_1577264683) by smtp.aliyun-inc.com(127.0.0.1); Wed, 25 Dec 2019 17:04:43 +0800 From: Alex Shi To: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, mgorman@techsingularity.net, tj@kernel.org, hughd@google.com, khlebnikov@yandex-team.ru, daniel.m.jordan@oracle.com, yang.shi@linux.alibaba.com, willy@infradead.org, shakeelb@google.com, hannes@cmpxchg.org Cc: Thomas Gleixner , Mauro Carvalho Chehab , Yafang Shao Subject: [PATCH v7 06/10] mm/swap: only change the lru_lock iff page's lruvec is different Date: Wed, 25 Dec 2019 17:04:22 +0800 Message-Id: <1577264666-246071-7-git-send-email-alex.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1577264666-246071-1-git-send-email-alex.shi@linux.alibaba.com> References: <1577264666-246071-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 Since we introduced relock_page_lruvec, we could use it in more place to reduce spin_locks. Signed-off-by: Alex Shi Cc: Johannes Weiner Cc: Andrew Morton Cc: Thomas Gleixner Cc: Matthew Wilcox Cc: Mauro Carvalho Chehab Cc: Yafang Shao Cc: Mel Gorman Cc: Konstantin Khlebnikov Cc: Hugh Dickins Cc: linux-kernel@vger.kernel.org Cc: cgroups@vger.kernel.org Cc: linux-mm@kvack.org --- mm/swap.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/mm/swap.c b/mm/swap.c index 97e108be4f92..84a845968e1d 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -196,11 +196,12 @@ static void pagevec_lru_move_fn(struct pagevec *pvec, for (i = 0; i < pagevec_count(pvec); i++) { struct page *page = pvec->pages[i]; - lruvec = lock_page_lruvec_irqsave(page, &flags); + lruvec = relock_page_lruvec_irqsave(page, lruvec, &flags); (*move_fn)(page, lruvec, arg); - unlock_page_lruvec_irqrestore(lruvec, flags); } + if (lruvec) + unlock_page_lruvec_irqrestore(lruvec, flags); release_pages(pvec->pages, pvec->nr); pagevec_reinit(pvec); @@ -819,14 +820,11 @@ void release_pages(struct page **pages, int nr) } if (PageLRU(page)) { - struct lruvec *new_lruvec = mem_cgroup_page_lruvec(page, page_pgdat(page)); + struct lruvec *pre_lruvec = lruvec; - if (new_lruvec != lruvec) { - if (lruvec) - unlock_page_lruvec_irqrestore(lruvec, flags); + lruvec = relock_page_lruvec_irqsave(page, lruvec, &flags); + if (pre_lruvec != lruvec) lock_batch = 0; - lruvec = lock_page_lruvec_irqsave(page, &flags); - } VM_BUG_ON_PAGE(!PageLRU(page), page); __ClearPageLRU(page); -- 1.8.3.1