Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1064897ybg; Wed, 10 Jun 2020 23:19:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYn3WXa+RtXDqa9kpZXWYHvl09KYT/Marcf6Yj9m06b/1OLNk6eC1qJzo2SI3yTYNwp7R/ X-Received: by 2002:a17:906:4056:: with SMTP id y22mr6788530ejj.304.1591856376259; Wed, 10 Jun 2020 23:19:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591856376; cv=none; d=google.com; s=arc-20160816; b=M4phpFAyev7DXshpk7Ux2cE/G7B5mo4H+C1KNmqHDydqMg3GVh7LXpnkMD9dMQVES+ 15+1Tj2IKTBgY2kfYSewgT/SQhLcXJ+cK0XuLeSSfJXZDPod+OwDm4VfODjpGnIvT/n5 UekeUDUExCHra75sbtyVmlpy5FMIwoUxbEEnvUtWyqaaQ4gajQHh5eJiEoMyMECXYoT0 tNjH6QfpeBn+Q1jIqvt31ahVj+Am/EXJT9gNNyIooI3xHl9MkiXt29e5pYFw4lOInw5U nlz9K5Qii8k4ar7n4o+Ry/WuSe5iVQxuisgMutp7cTZnFdws0E3A2/iFL7bRfJ1LcW2Y 7wUg== 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=gSPR1LHHzuNI3sl2QWwuEVtVOY5w5A3UAE2akpVWv1o=; b=g63R0RFKl7PMqdyYmtqq2OAfMX7c4lXl7BM+yJt52C5Zwijvu4GBCxGNNgqACypFqi DLcFKYkwZW1DPN3CKzD7XdbemWJLZILF6/TI61vbQG3HMphHCmVnYwe01hJalItZhhwu 0S20BxzHPAqFzu7T7NKkeyjuz3ufX+T4hXUocNfAa+hltMH5xP5WG9M2/XFSMGx3bL6p aSK4tMn8dD9X7O8injAgWNoBJXp1DvJhltj4+F65zi8PlrFhIJ4wmg9eZY/XUZSi8ifz BAm1X+cdSxFbDAfvEXwNtu65EOCmOgR6AzftPjVIaAgGHtSXTyyqXGqSkf7C1hssvswF nljg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id fy2si1594680ejb.11.2020.06.10.23.19.14; Wed, 10 Jun 2020 23:19:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726695AbgFKGRT (ORCPT + 99 others); Thu, 11 Jun 2020 02:17:19 -0400 Received: from out30-132.freemail.mail.aliyun.com ([115.124.30.132]:54874 "EHLO out30-132.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726462AbgFKGRR (ORCPT ); Thu, 11 Jun 2020 02:17:17 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R191e4;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=18;SR=0;TI=SMTPD_---0U.FIUmA_1591856231; Received: from localhost(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0U.FIUmA_1591856231) by smtp.aliyun-inc.com(127.0.0.1); Thu, 11 Jun 2020 14:17:11 +0800 From: Alex Shi To: 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, hannes@cmpxchg.org, lkp@intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, shakeelb@google.com, iamjoonsoo.kim@lge.com, richard.weiyang@gmail.com Cc: Andrey Ryabinin , Jann Horn Subject: [PATCH v12 14/16] mm/vmscan: use relock for move_pages_to_lru Date: Thu, 11 Jun 2020 14:16:47 +0800 Message-Id: <1591856209-166869-15-git-send-email-alex.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1591856209-166869-1-git-send-email-alex.shi@linux.alibaba.com> References: <1591856209-166869-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 From: Hugh Dickins Use the relock function to replace relocking action. And try to save few lock times. Signed-off-by: Hugh Dickins Signed-off-by: Alex Shi Cc: Andrew Morton Cc: Tejun Heo Cc: Andrey Ryabinin Cc: Jann Horn Cc: Mel Gorman Cc: Johannes Weiner Cc: Matthew Wilcox Cc: Hugh Dickins Cc: cgroups@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org --- mm/vmscan.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 1253cdb16c96..d763cb307e92 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1854,15 +1854,15 @@ static unsigned noinline_for_stack move_pages_to_lru(struct lruvec *lruvec, enum lru_list lru; while (!list_empty(list)) { - struct lruvec *new_lruvec = NULL; - page = lru_to_page(list); VM_BUG_ON_PAGE(PageLRU(page), page); list_del(&page->lru); if (unlikely(!page_evictable(page))) { - spin_unlock_irq(&lruvec->lru_lock); + if (lruvec) { + spin_unlock_irq(&lruvec->lru_lock); + lruvec = NULL; + } putback_lru_page(page); - spin_lock_irq(&lruvec->lru_lock); continue; } @@ -1876,12 +1876,7 @@ static unsigned noinline_for_stack move_pages_to_lru(struct lruvec *lruvec, * list_add(&page->lru,) * list_add(&page->lru,) //corrupt */ - new_lruvec = mem_cgroup_page_lruvec(page, page_pgdat(page)); - if (new_lruvec != lruvec) { - if (lruvec) - spin_unlock_irq(&lruvec->lru_lock); - lruvec = lock_page_lruvec_irq(page); - } + lruvec = relock_page_lruvec_irq(page, lruvec); SetPageLRU(page); if (unlikely(put_page_testzero(page))) { @@ -1890,8 +1885,8 @@ static unsigned noinline_for_stack move_pages_to_lru(struct lruvec *lruvec, if (unlikely(PageCompound(page))) { spin_unlock_irq(&lruvec->lru_lock); + lruvec = NULL; destroy_compound_page(page); - spin_lock_irq(&lruvec->lru_lock); } else list_add(&page->lru, &pages_to_free); continue; -- 1.8.3.1