Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2123339pxa; Mon, 24 Aug 2020 06:01:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuQtyhPwNelbRUvhgnA3su+SXnjAqTJgC9byo2NY2Y5nBigsGqX0xnDNvYbcvb8p9R3EIl X-Received: by 2002:a17:907:7094:: with SMTP id yj20mr5301030ejb.179.1598274063957; Mon, 24 Aug 2020 06:01:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598274063; cv=none; d=google.com; s=arc-20160816; b=Z+EpwMp4StUFdGVmtzS9aC07vxUMNT0XL6J1PTRu1nlFlUXNSsVQhBAWug+NcB6zeL Fshh6gtKbzhVi1inP6a0vyri8Xr3fTBUiVfCznDxMMvxCZmf63zV5v0ocf3FccVxQJWe O+QhnB+Y8W+gCq7bAo444ostMy1InEPnQZVBZMQOzNZnD0y//mP6YbiIWAN5NeAa/+4L WrID3P59nKIHbT6+jXc9KaEX20bBVm23/gZVWASU7gGFBBZUVVyOKphQ5P5iXD9zOptT /+Qkzd4I5vMpjGMSyY0xD25k9J4k0X7IvHdqZP4N5GtW/hgHqk5UNrFB0ri7Bsy5K7U8 sA7Q== 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=qMh3KBuvAPY13A4ebUmUah8Y1WYYF+GdhSkhe/WqJbs=; b=NjWKGr0GpDVk3ltWqabjkxKFxycdZNEVGdRnWFz5HiWo1COkh8pCuX9BKe6mZVlS6F w44h2s/Pd5MHMPSmqy7sdMuNHpG/0gTVr/zh/K34mjTfao/11VL1kL40wDNuYnui2Nmk y8uhN45BgldGK8qj5W3mub/BOk3xV82RoA5dc5mpt8dUun9JdiCypppQetdlc3Gr/uaP u+dob0mv7C6pNaZOHeis7BQw2MiqiLW8pkd49lDEFkR21Ar2T+ED0R0wGM+U6tsS5nRV oNQGORY+KFqIJZTG/Xp2W07pBpZIz1QcOx+6/JIZElmikWIZT/SPSEga4PRLKBJDuOp9 d35g== 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 h24si2378763edq.394.2020.08.24.06.00.40; Mon, 24 Aug 2020 06:01:03 -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 S1726873AbgHXM52 (ORCPT + 99 others); Mon, 24 Aug 2020 08:57:28 -0400 Received: from out30-43.freemail.mail.aliyun.com ([115.124.30.43]:59594 "EHLO out30-43.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727822AbgHXMz3 (ORCPT ); Mon, 24 Aug 2020 08:55:29 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R101e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01419;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=23;SR=0;TI=SMTPD_---0U6k9-bl_1598273712; Received: from aliy80.localdomain(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0U6k9-bl_1598273712) by smtp.aliyun-inc.com(127.0.0.1); Mon, 24 Aug 2020 20:55:21 +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, 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, mhocko@suse.com, vdavydov.dev@gmail.com, shy828301@gmail.com Cc: Andrey Ryabinin , Jann Horn Subject: [PATCH v18 22/32] mm/vmscan: use relock for move_pages_to_lru Date: Mon, 24 Aug 2020 20:54:55 +0800 Message-Id: <1598273705-69124-23-git-send-email-alex.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1598273705-69124-1-git-send-email-alex.shi@linux.alibaba.com> References: <1598273705-69124-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 Reviewed-by: Alexander Duyck 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 2c94790d4cb1..04ef94190530 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1848,15 +1848,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; } @@ -1871,12 +1871,7 @@ static unsigned noinline_for_stack move_pages_to_lru(struct lruvec *lruvec, * list_add(&page->lru,) * list_add(&page->lru,) */ - 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))) { @@ -1885,8 +1880,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