Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3824437ybl; Tue, 20 Aug 2019 02:52:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqy33zeIKNg5N12ZcQiLlgBOKA3bjs+eC9wcZQhNzws/rrxjsMgQ+67SM/RsPSK/0Kc8l8gV X-Received: by 2002:a65:6152:: with SMTP id o18mr18377064pgv.279.1566294729271; Tue, 20 Aug 2019 02:52:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566294729; cv=none; d=google.com; s=arc-20160816; b=hs3PRpV7aZ/Zh7JEEv5dnPZ2CTfWnHRWHxeZHkpVX8ACtyJqWPsw+Vxnh1m4tgTjhb wjHxLGzCMk7UhXeykBbDjhpygHdaQcIPAoeBZ24mnkXPzr8ertdes9AdbjZBvnIVETAL k4DfZ7ujMjb33PKW/HbaqO+g1ut/6kgt+WsqUXfxj5LFQHEYFNZs58axdWrO5qjMKcA1 8UXweQH8n8jNL39poOxB6IkZtQgHwmKp5N3rQRNuYLQ7NwCLibUFPi5Ky4+0rzQWR/XQ Sv3NejyNbRRk/P+3bzvHlcxZFIWw0H9eISvimIlTMnIux4rnxSWSZzEqgljT6WJMqEgs z1OQ== 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=3qcc5oY9gnmuxOVDXI6RaYq2UisSBAzN9WpFyJTlYyU=; b=wuuCxzeGlMNYQDl7K9BtnwPU0R/JIyGK2On8IMarYlUUPekJVuEmt71+sTWLnX9INa 5tCU3hDKcZZaph3NvttNbi7AQKVukOyhu22UOByUrmw24O7RbgGoxFmri1RjpJ/L6dei KNmnVjg9DiEPlfJsTuE7jNV223Qa6yITUAOxOzQy/M5RWMp4bz0Zvd7sWY7ExYWFD/sl VCMMzuP/PkuGWs482ftHtLl0lvbiqJmt13bR/tfZgju3wQg/ZG6/pMMt5l+ceJ9fjUkc Gh03kleovUtQCQmH/r6CW56WbbRFeHzoEH/D2HLzBCGEW/c2nuyXv9kAp8tKCcXuKZJ8 SZqg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id h186si11749011pge.110.2019.08.20.02.51.54; Tue, 20 Aug 2019 02:52:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1729755AbfHTJtp (ORCPT + 99 others); Tue, 20 Aug 2019 05:49:45 -0400 Received: from out30-132.freemail.mail.aliyun.com ([115.124.30.132]:54383 "EHLO out30-132.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729699AbfHTJto (ORCPT ); Tue, 20 Aug 2019 05:49:44 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R151e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04395;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0Ta-6uif_1566294573; Received: from localhost(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0Ta-6uif_1566294573) by smtp.aliyun-inc.com(127.0.0.1); Tue, 20 Aug 2019 17:49:33 +0800 From: Alex Shi To: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Mel Gorman , Tejun Heo Cc: Alex Shi , Johannes Weiner , Michal Hocko , Vladimir Davydov Subject: [PATCH 03/14] lru/memcg: using per lruvec lock in un/lock_page_lru Date: Tue, 20 Aug 2019 17:48:26 +0800 Message-Id: <1566294517-86418-4-git-send-email-alex.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1566294517-86418-1-git-send-email-alex.shi@linux.alibaba.com> References: <1566294517-86418-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 Now we repeatly assign the lruvec->pgdat in memcg. Will remove the assignment in lruvec getting function after very points are protected. Signed-off-by: Alex Shi Cc: Johannes Weiner Cc: Michal Hocko Cc: Vladimir Davydov Cc: Andrew Morton Cc: Tejun Heo Cc: cgroups@vger.kernel.org Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- mm/memcontrol.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index e8a1b0d95ba8..19fd911e8098 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2550,12 +2550,12 @@ static void cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages) static void lock_page_lru(struct page *page, int *isolated) { pg_data_t *pgdat = page_pgdat(page); + struct lruvec *lruvec = mem_cgroup_page_lruvec(page, pgdat); - spin_lock_irq(&pgdat->lruvec.lru_lock); + spin_lock_irq(&lruvec->lru_lock); + sync_lruvec_pgdat(lruvec, pgdat); if (PageLRU(page)) { - struct lruvec *lruvec; - lruvec = mem_cgroup_page_lruvec(page, pgdat); ClearPageLRU(page); del_page_from_lru_list(page, lruvec, page_lru(page)); *isolated = 1; @@ -2566,16 +2566,14 @@ static void lock_page_lru(struct page *page, int *isolated) static void unlock_page_lru(struct page *page, int isolated) { pg_data_t *pgdat = page_pgdat(page); + struct lruvec *lruvec = mem_cgroup_page_lruvec(page, pgdat); if (isolated) { - struct lruvec *lruvec; - - lruvec = mem_cgroup_page_lruvec(page, pgdat); VM_BUG_ON_PAGE(PageLRU(page), page); SetPageLRU(page); add_page_to_lru_list(page, lruvec, page_lru(page)); } - spin_unlock_irq(&pgdat->lruvec.lru_lock); + spin_unlock_irq(&lruvec->lru_lock); } static void commit_charge(struct page *page, struct mem_cgroup *memcg, -- 1.8.3.1