Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2929994ybh; Sat, 25 Jul 2020 06:04:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjqKTy6apZWnwlqCSFYusykHg7eLL7ijxX9wc6L82F6ZwvjP3fxkmxDBvH9L+P9mTmAgHL X-Received: by 2002:a17:906:194b:: with SMTP id b11mr13313128eje.28.1595682261528; Sat, 25 Jul 2020 06:04:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595682261; cv=none; d=google.com; s=arc-20160816; b=rb9OT6Vwc3mh/5H2oo0nkho/vEgvrS2QDBIU8bzuFxrnnAPvWcH6Znr7LpxBt6hm4l ZVw4+LmJCtXqH6o5XOMXOhGa13Dka8dEGuZ8YWy19VQkSwfvzG2sN+q9Bp7hvBDpKl52 Y35iuItvTjWnzCEMpPnlFHV7nIFv9zn+pxUm9ZKiqUVQvxuOIOCdFzH5CwqxWPXXJ8RM +oVesMl7giEA/38xOLWcNS6FAwBH0q0TKJbL/jGr3ivajqW23E3DAasUxsRpNf7qtAdP 2MOe/cW+YQgtQoinXPw8swpq49l1rWEma0YtfrtW/UGiPYH/igUMvaDxdXbK/CA/Zmvk jwXw== 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:to:from; bh=zJiSMfkrXRhHp9Bu754z22Mbt6Do0qnCUAt3rH8yqQY=; b=ZiZPCbWUN8EAeI74elAk1Ul1LEqcWVb06RTHlqX2v3xMmoGBflaNvE5gWDwWMwAuH7 Ye+5sQh4I6OfWQPo2Iaknbav6pREBEGp2BdHTFkQUgCUcPUKu7VE3fzcSJ3Xc/EIHtsz R0XVOPOxxZw3GSUDelERY9mTjkCpP8Wr81tiX8v8zgjlCfLMK2+T6LnHchVjQw8Wx4wr 12hAh390ViQ9jO13Sr256BP1C5r6Umu9r0zrjBoBGDMukt/LnfONXrZa8jYyy5/s23H7 +pLsWjF0U3MzSq3IOmyNvHLd8eyn7BVHdyBX5FNgAukh2kpyb3N9RJQS6oRQoj6CyOSg gS0w== 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 op6si743867ejb.72.2020.07.25.06.03.58; Sat, 25 Jul 2020 06:04:21 -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 S1727929AbgGYNBJ (ORCPT + 99 others); Sat, 25 Jul 2020 09:01:09 -0400 Received: from out30-42.freemail.mail.aliyun.com ([115.124.30.42]:37287 "EHLO out30-42.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727776AbgGYNAd (ORCPT ); Sat, 25 Jul 2020 09:00:33 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R201e4;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_---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: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, kirill@shutemov.name, alexander.duyck@gmail.com, rong.a.chen@intel.com Subject: [PATCH v17 12/21] mm/lru: move lock into lru_note_cost Date: Sat, 25 Jul 2020 20:59:49 +0800 Message-Id: <1595681998-19193-13-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 This patch move lru_lock into lru_note_cost. It's a bit ugly and may cost more locking, but it's necessary for later per pgdat lru_lock to per memcg lru_lock change. Signed-off-by: Alex Shi Cc: Johannes Weiner Cc: Andrew Morton Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- mm/swap.c | 5 +++-- mm/vmscan.c | 4 +--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/mm/swap.c b/mm/swap.c index b88ca630db70..f645965fde0e 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -269,7 +269,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; @@ -293,15 +295,14 @@ 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))); } void lru_note_cost_page(struct page *page) { - spin_lock_irq(&page_pgdat(page)->lru_lock); lru_note_cost(mem_cgroup_page_lruvec(page, page_pgdat(page)), page_is_file_lru(page), hpage_nr_pages(page)); - spin_unlock_irq(&page_pgdat(page)->lru_lock); } static void __activate_page(struct page *page, struct lruvec *lruvec) diff --git a/mm/vmscan.c b/mm/vmscan.c index ddb29d813d77..c1c4259b4de5 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1976,19 +1976,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); -- 1.8.3.1