Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp335897pxb; Thu, 5 Nov 2020 01:01:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJykboRKEa6r6DWImRv8ReLbCg6DC+uyliyL+3SIsOoJIACh0/UW1whhvcae9pEUp8G7XlUN X-Received: by 2002:a17:906:b0f:: with SMTP id u15mr435250ejg.109.1604566915279; Thu, 05 Nov 2020 01:01:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604566915; cv=none; d=google.com; s=arc-20160816; b=weCEk99ikyaqidlqSPVjHw/LrLxfHSSAZAbV+QG+WjuVJJ37pdquf3tP0FdkAyBa/c +fyDPlyXTP/7ftuY+Iuv19hKXziqdVOXF1mD/4INteXC9HF2qv12LJfB+mevoiNogG4k bh5/XFZe11ug2hCxbP2b8xxGx8bYwINs47x57QzXgWbV+O+dJ42ngoY9vQ85lv63suFD Kd03vHkKV+bDr2tTJ6mXgnJV88R/iKhkJ0GqZAd7e60euZj0i217WSxr6Wpg1dAkp8I0 UjpJtDDk8Xeiet/2x5DwGpJVnsMfj57w/Y6CnRRl55R8CNZQip1CIIjKaZarxbzquuzi KqQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :to:from; bh=9xmAtB8kFE5vX1vwg7ZZK2D+WsdC1+DO9NONmX20h/4=; b=X/iOswq0jpwab5LQoGcnsvsslQcigJjj6+VDEZZpSAwOpuQgGs9owGGXv8HUAhJeLA NzJbdZR24TTJgIpbkcAmHIgrfc6qR0DjtkDC1esZWhxSa3iVeStRxwnTEaPwn3WFwB29 3aCfivRUcdUFusBykeXZKtoGFizRKzHNHAC6wQx7mLM4XFB03FVmy1TuiAxFktfr1Xqe JwRAIZYfflCesyaCAUBxtma0SqunXPjlbFO+N98xFvb5IU7JgC9Ju1fw4lqAW33yxzGv hClnF5u93Tx86YMSDTVx859cs8Qs2z7f2XBb0yE7fKRH1hSXdtCoPB4uclNZAQNus+6F 9Vqg== 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 sb16si624364ejb.674.2020.11.05.01.01.32; Thu, 05 Nov 2020 01:01:55 -0800 (PST) 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 S1731307AbgKEI5Z (ORCPT + 99 others); Thu, 5 Nov 2020 03:57:25 -0500 Received: from out30-130.freemail.mail.aliyun.com ([115.124.30.130]:46987 "EHLO out30-130.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730499AbgKEI4U (ORCPT ); Thu, 5 Nov 2020 03:56:20 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R451e4;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=21;SR=0;TI=SMTPD_---0UEJC3Fv_1604566567; Received: from aliy80.localdomain(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0UEJC3Fv_1604566567) by smtp.aliyun-inc.com(127.0.0.1); Thu, 05 Nov 2020 16:56:12 +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 Subject: [PATCH v21 10/19] mm/lru: move lock into lru_note_cost Date: Thu, 5 Nov 2020 16:55:40 +0800 Message-Id: <1604566549-62481-11-git-send-email-alex.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1604566549-62481-1-git-send-email-alex.shi@linux.alibaba.com> References: <1604566549-62481-1-git-send-email-alex.shi@linux.alibaba.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We have to move lru_lock into lru_note_cost, since it cycle up on memcg tree, for future per lruvec lru_lock replace. It's a bit ugly and may cost a bit more locking, but benefit from multiple memcg locking could cover the lost. Signed-off-by: Alex Shi Acked-by: Hugh Dickins Acked-by: Johannes Weiner Cc: Johannes Weiner Cc: Andrew Morton Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- mm/swap.c | 3 +++ mm/vmscan.c | 4 +--- mm/workingset.c | 2 -- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/mm/swap.c b/mm/swap.c index ce8c97146e0d..2681d9023998 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -268,7 +268,9 @@ void lru_note_cost(struct lruvec *lruvec, bool file, unsigned int nr_pages) { do { unsigned long lrusize; + struct pglist_data *pgdat = lruvec_pgdat(lruvec); + spin_lock_irq(&pgdat->lru_lock); /* Record cost event */ if (file) lruvec->file_cost += nr_pages; @@ -292,6 +294,7 @@ void lru_note_cost(struct lruvec *lruvec, bool file, unsigned int nr_pages) lruvec->file_cost /= 2; lruvec->anon_cost /= 2; } + spin_unlock_irq(&pgdat->lru_lock); } while ((lruvec = parent_lruvec(lruvec))); } diff --git a/mm/vmscan.c b/mm/vmscan.c index b9935668d121..d771f812e983 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1973,19 +1973,17 @@ static int current_may_throttle(void) &stat, false); spin_lock_irq(&pgdat->lru_lock); - move_pages_to_lru(lruvec, &page_list); __mod_node_page_state(pgdat, NR_ISOLATED_ANON + file, -nr_taken); - lru_note_cost(lruvec, file, stat.nr_pageout); item = current_is_kswapd() ? PGSTEAL_KSWAPD : PGSTEAL_DIRECT; if (!cgroup_reclaim(sc)) __count_vm_events(item, nr_reclaimed); __count_memcg_events(lruvec_memcg(lruvec), item, nr_reclaimed); __count_vm_events(PGSTEAL_ANON + file, nr_reclaimed); - spin_unlock_irq(&pgdat->lru_lock); + lru_note_cost(lruvec, file, stat.nr_pageout); mem_cgroup_uncharge_list(&page_list); free_unref_page_list(&page_list); diff --git a/mm/workingset.c b/mm/workingset.c index 130348cbf40a..a915a812c363 100644 --- a/mm/workingset.c +++ b/mm/workingset.c @@ -381,9 +381,7 @@ void workingset_refault(struct page *page, void *shadow) if (workingset) { SetPageWorkingset(page); /* XXX: Move to lru_cache_add() when it supports new vs putback */ - spin_lock_irq(&page_pgdat(page)->lru_lock); lru_note_cost_page(page); - spin_unlock_irq(&page_pgdat(page)->lru_lock); inc_lruvec_state(lruvec, WORKINGSET_RESTORE_BASE + file); } out: -- 1.8.3.1