Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2927905ybh; Sat, 25 Jul 2020 06:01:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIW7cgFKF4XBwNhJYL+jFjz2RxuT6SbWXRup3O/aPtViV8bb3AgcdZ4Gc+lRMf6rvcUOCf X-Received: by 2002:aa7:c3d7:: with SMTP id l23mr13108173edr.18.1595682103427; Sat, 25 Jul 2020 06:01:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595682103; cv=none; d=google.com; s=arc-20160816; b=gVnfnQDg9gGlE4T5IJh4umKg+71W715WC0iDIzwScJ7RA5MQ3IaRj3Fft5Vt3ZHAiv 9bfdDHH5O0Y9Ncz6WtymA0RL13QJJZDSeFXUOiJqQTFXkZX4TOWK1abUkeu0yg6GUMgo S7jINcz0mBe/qXRg6XXezuDKqKI+RPDUWBaJLMLIhTVKDZIUcJiJ2Msg1NqlqkG3eAc9 /sr71616rIFOlt0SQ7Ce/Xd4lGtb5wEMWTjxx6S+qkyGXK1FBiiYP1gDUS3KQ46s1uLx quYR4J7W2EwLzsR69jDYuNQaMT48jOB69SPZ3NhMTgWs34X1uz9i8lf2tI1YjeCgfYgR +gzA== 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=fTTBh8iHWDfSe8mtBuFS9NYwhbye7SZ+xuKaQjvXB1vp6WaApd5mnpvBjo7cRnyOma 8FOWt5nt6MRopbsyPhAUyqRgo92RkmHrmzxaZQe+6mLFg1aYgsR7cYS42f3yTpleXx8b YHE1giivUI8kZnmRAQ+4/o/YVZCZg/d5QJK8xZrELmTejRaVMLzpnw8G3RiEgajJxVyq ni7v9zNjHjk6gmywxdlOCRX3YdhI5spbOqulC6s63pYUI+elfAGgQ9rvdrVovMw+WUlt Qct98O2Z+hq70pWp//TCVu8cbKC7hIBQudAkGaNesd9ocpqDZZ/+e2sC5LjwJaNCokuQ tz/g== 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 i26si2317544ejk.576.2020.07.25.06.01.20; Sat, 25 Jul 2020 06:01:43 -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 S1727886AbgGYNAw (ORCPT + 99 others); Sat, 25 Jul 2020 09:00:52 -0400 Received: from out30-44.freemail.mail.aliyun.com ([115.124.30.44]:38166 "EHLO out30-44.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727790AbgGYNAh (ORCPT ); Sat, 25 Jul 2020 09:00:37 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R661e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01355;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=21;SR=0;TI=SMTPD_---0U3l6fmD_1595682015; Received: from aliy8.localdomain(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0U3l6fmD_1595682015) by smtp.aliyun-inc.com(127.0.0.1); Sat, 25 Jul 2020 21:00:28 +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, kirill@shutemov.name, alexander.duyck@gmail.com, rong.a.chen@intel.com Cc: Andrey Ryabinin , Jann Horn Subject: [PATCH v17 19/21] mm/vmscan: use relock for move_pages_to_lru Date: Sat, 25 Jul 2020 20:59:56 +0800 Message-Id: <1595681998-19193-20-git-send-email-alex.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1595681998-19193-1-git-send-email-alex.shi@linux.alibaba.com> References: <1595681998-19193-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