Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp332530ybm; Thu, 28 May 2020 04:04:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxADjHpA1I17UY+N4mI9nCfAe93BUqK5HOsNToTZIbZtJa1OjAr1atQn/EWb9noJa2azErA X-Received: by 2002:a17:906:410a:: with SMTP id j10mr2398510ejk.378.1590663888925; Thu, 28 May 2020 04:04:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590663888; cv=none; d=google.com; s=arc-20160816; b=MELY71R7tQZIfGhOTaEyrTdCmT6jJm0iDhNl2Sw9x8UJn+UeYGHskfRKMbpYX8vfGJ 8Y76G9IqhiqFHkdhwDvLT8t9aIxapUUaElOU7Pna0ONKWsc+nQcdKdvIrH2jQFE3h9Oe dWtoKMfL4kTJUG1apJacZ3N/iakf3BUtE9howeS+27ANPx16Ct7KJ+h5n+814i6jExTF jnYG3Pj5eIsNReuoaGqwwSEVXa44nY/qVe+HWpr4OkqGa1WNlRPXYPreLHDT4Jn/I3rY uizIrWAnPZ+Xoj3Ph4tpIbZo6/VI6MvR7DFVzN7q99pDd2i6/xRIoZa5gBi6+2dFF6nV CJqg== 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=uUSee4NGxs+Pf77Qn6gnAqxKxr9QR/T6REIQrq9fTCU=; b=yw5H+CMZtng+i8AMy9vcyiHqroCE8U4zcy9ZPxKfRB6nQV74zwEwU0gc8t4/yFXm8U KYIZXLg3AWlXKImdx4z0rcIJddXRYraOFnc0d3gbO5PkIXeWD4d6nsAYpw9ToHPCjEyV NXyIi0TwIB9mq9wzIvj4b2Bjx1cHWlEb3lY3wD/st2GnqPj51O26TSLCjxQfK45wHTbP KX52e+h5tOjHcQsRGve2vcCMZwVQR7or6lOzNx6OljrgsmI2ZMiUWRi6Dl9KoQx7VHDT 33W14UF4Az9Md2gkX6/s3lEKGOHFwtafY7xLwhv9LhwTvdqXn2GEepRNPoQVbbBXi8g2 wMYA== 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 h6si3630506edl.221.2020.05.28.04.04.26; Thu, 28 May 2020 04:04:48 -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 S2388148AbgE1LBr (ORCPT + 99 others); Thu, 28 May 2020 07:01:47 -0400 Received: from out30-44.freemail.mail.aliyun.com ([115.124.30.44]:55280 "EHLO out30-44.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388095AbgE1LBh (ORCPT ); Thu, 28 May 2020 07:01:37 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R681e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04426;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=19;SR=0;TI=SMTPD_---0TztNDDl_1590663690; Received: from localhost(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0TztNDDl_1590663690) by smtp.aliyun-inc.com(127.0.0.1); Thu, 28 May 2020 19:01:31 +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 v11 14/16] mm/vmscan: use relock for move_pages_to_lru Date: Thu, 28 May 2020 19:00:56 +0800 Message-Id: <1590663658-184131-15-git-send-email-alex.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1590663658-184131-1-git-send-email-alex.shi@linux.alibaba.com> References: <1590663658-184131-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 7a0d4ac71558..672e7304f211 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