Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp967412ybt; Tue, 7 Jul 2020 04:48:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLp+4EWoQv9X5zi4I++/ocRINm6p+2MeMxKC2oclWMP1dgl2z79ryI5eWlIamxS3NpEtQr X-Received: by 2002:aa7:c353:: with SMTP id j19mr13383747edr.219.1594122530594; Tue, 07 Jul 2020 04:48:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594122530; cv=none; d=google.com; s=arc-20160816; b=xKST8lfE7jW6U72LPlhTzBodTOQoco1fyyFMKzpMNCOdaIA+YRTeWjQ+/rs/1yFnkT UZRpSaUqD+E2KM/XwrX06pm1y5PiwDPcIFjGK4ldTRFSCCR0NrchBiVeQo2AMhVIk5W+ 7q2shdorY59mnaLhsNf0CLPlDGowP579T7fIXAkta7TrD3AbilKZctAmgo51DMJhHteA pzKQSpnyR8+9DW6hhpqUe5YoV7iQDaYgs5ibupZA39Tp58VU8I2ef8KRUUG+iHL2OuGW zeVoKZFWXNvpx8rMyl+HNKaFRqq5yqQyiv312nQCiNAu2OAWS+vLXsHgePgGc6ZpBzM1 qDYw== 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=DTV9Fut7A/nfFQskISVM8VVhWGski97tfgixgTuBfmE=; b=rMxd4CJJik+LySrfJbpb2KRlHo1d6+BaIEQ51yiEqZoAhVzrbQ8lYl+8R4kBbLQ86O Z+2+DqwZR0ttODnIo2ScpN5w0/ME2d5PoPT4g8NSzX2iu96lCVty8nFsBTrxzStQMwNY Y/Ds++IgDHAm8/PALy4HRTqtgnUV6FCLMR7F08oMVUoYzwXWVCNeGjgsdmudypiPdGzj +Igd10Iuo9h0L6Oetenf2aPxNiB46dHy2yOzTuW6ptzmhvixde1orzPAWphfAjbjmy+i 0A8o4wQhRZjlv7D3EnsURuMBrw45DfntS8LIFZSlwwcq8WdDzEAMRuBCjyqnWn7bMCB7 Qp6g== 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 e18si13156706eji.614.2020.07.07.04.48.27; Tue, 07 Jul 2020 04:48:50 -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 S1728677AbgGGLrd (ORCPT + 99 others); Tue, 7 Jul 2020 07:47:33 -0400 Received: from out30-132.freemail.mail.aliyun.com ([115.124.30.132]:36726 "EHLO out30-132.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728290AbgGGLrc (ORCPT ); Tue, 7 Jul 2020 07:47:32 -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=19;SR=0;TI=SMTPD_---0U20joWQ_1594122436; Received: from alexshi-test.localdomain(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0U20joWQ_1594122436) by smtp.aliyun-inc.com(127.0.0.1); Tue, 07 Jul 2020 19:47:25 +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: Alex Shi , Andrey Ryabinin , Jann Horn Subject: [PATCH v15 18/21] mm/vmscan: use relock for move_pages_to_lru Date: Tue, 7 Jul 2020 19:46:50 +0800 Message-Id: <1594122412-28057-19-git-send-email-alex.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1594122412-28057-1-git-send-email-alex.shi@linux.alibaba.com> References: <1594122412-28057-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 bdb53a678e7e..078a1640ec60 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); -- 1.8.3.1