Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3824139ybl; Tue, 20 Aug 2019 02:51:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqyvhv47It0nGitN/mZhyBI/r10Wg/e+GhZ1QMmeBq8j04ptL55gttfQxzfrO2tml2ncfrOB X-Received: by 2002:a63:124a:: with SMTP id 10mr23945824pgs.254.1566294707514; Tue, 20 Aug 2019 02:51:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566294707; cv=none; d=google.com; s=arc-20160816; b=Q4ZCEvYLygyUOh9svt2fzDlF85VSkj7ESgqnz3NyiHEyIZ4j7PmM8f0l2DDeMTSpJg UL1d1y8rPLzmc1WAjtHhOBJoumgQ5X6YfgEoHhEL3GWdffjBVTaVbZhDDswdl/HhoTvL II8oHRCYbRh14ufp8p3GDBzJ9xS8+hME9gZh8DyqENvn6JkNFKld9yoaGmnPYmUoW3Lo ZciGIdoZl6MvIWQvUFrJgkOhjxu0y5Mbrysr+vwtraNo3TV6ywaPWOvnk7iOOLjKVFk5 YCG2GnkkAtZXJHPB/5pPCOv0csYLArk6NdO3EMxlRQuIlPDikhEX169EdeKLrLzx3Vwr 4fRA== 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=62gOxZGU7GIpoJBwkwyANiKeS8cAr3/fqWhbgTUyD7s=; b=FEaEnfXuvax05vZWJDSkyojG87MBbg1h+wwR4VVSCnZ9NBz6RSeR7FLVIwndLRGP+w JHjorDGSSa6J3biAan295U+M9ThSUSJmfQUdgfJhIHB3/LAwfkqaCB+IZSos11HOziFM NUhTfEhEBot8aVopM1WFNVcmP/lIiZlENBt0YPn4CQifHN4EFkMlOm0RNERm1SbMmUpY HUjOW53FrGSYYZLVcXfldaZ9qGTO0O81y20GWtgdKHhAPeR9/jab+2GtoG00iIVIJF2I go8p56hQ1nqpLjayNzEDBiPMaUeWY/boY8nMGsFUYDtOPIcHmVJah5PXX6g6i5aVLJk3 mAhg== 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 q16si11676824pgv.140.2019.08.20.02.51.32; Tue, 20 Aug 2019 02:51:47 -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 S1729735AbfHTJuP (ORCPT + 99 others); Tue, 20 Aug 2019 05:50:15 -0400 Received: from out30-133.freemail.mail.aliyun.com ([115.124.30.133]:56240 "EHLO out30-133.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729705AbfHTJto (ORCPT ); Tue, 20 Aug 2019 05:49:44 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R301e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04446;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=15;SR=0;TI=SMTPD_---0Ta-6uiR_1566294572; Received: from localhost(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0Ta-6uiR_1566294572) by smtp.aliyun-inc.com(127.0.0.1); Tue, 20 Aug 2019 17:49:32 +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 , Roman Gushchin , Shakeel Butt , Chris Down , Kirill Tkhai , Thomas Gleixner Subject: [PATCH 02/14] lru/memcg: move the lruvec->pgdat sync out lru_lock Date: Tue, 20 Aug 2019 17:48:25 +0800 Message-Id: <1566294517-86418-3-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 We are going to move lruvec getting out of lru_lock, the only unsafe part is lruvec->pgdat syncing when memory node hot pluging. Splitting out the lruvec->pgdat assignment now and will put it in lruvec lru_lock protection. No function changes in this patch now. Signed-off-by: Alex Shi Cc: Johannes Weiner Cc: Michal Hocko Cc: Vladimir Davydov Cc: Roman Gushchin Cc: Shakeel Butt Cc: Chris Down Cc: Kirill Tkhai Cc: Thomas Gleixner Cc: Andrew Morton Cc: Tejun Heo Cc: cgroups@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org --- include/linux/memcontrol.h | 24 +++++++++++++++++------- mm/memcontrol.c | 8 +------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 2cd4359cb38c..95b3d9885ab6 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -359,6 +359,17 @@ void mem_cgroup_cancel_charge(struct page *page, struct mem_cgroup *memcg, return memcg->nodeinfo[nid]; } +static void sync_lruvec_pgdat(struct lruvec *lruvec, struct pglist_data *pgdat) +{ + /* + * Since a node can be onlined after the mem_cgroup was created, + * we have to be prepared to initialize lruvec->pgdat here; + * and if offlined then reonlined, we need to reinitialize it. + */ + if (!mem_cgroup_disabled() && unlikely(lruvec->pgdat != pgdat)) + lruvec->pgdat = pgdat; +} + /** * mem_cgroup_lruvec - get the lru list vector for a node or a memcg zone * @node: node of the wanted lruvec @@ -382,13 +393,7 @@ static inline struct lruvec *mem_cgroup_lruvec(struct pglist_data *pgdat, mz = mem_cgroup_nodeinfo(memcg, pgdat->node_id); lruvec = &mz->lruvec; out: - /* - * Since a node can be onlined after the mem_cgroup was created, - * we have to be prepared to initialize lruvec->pgdat here; - * and if offlined then reonlined, we need to reinitialize it. - */ - if (unlikely(lruvec->pgdat != pgdat)) - lruvec->pgdat = pgdat; + sync_lruvec_pgdat(lruvec, pgdat); return lruvec; } @@ -857,6 +862,11 @@ static inline void mem_cgroup_migrate(struct page *old, struct page *new) { } +static inline void sync_lruvec_pgdat(struct lruvec *lruvec, + struct pglist_data *pgdat) +{ +} + static inline struct lruvec *mem_cgroup_lruvec(struct pglist_data *pgdat, struct mem_cgroup *memcg) { diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 2792b8ed405f..e8a1b0d95ba8 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1257,13 +1257,7 @@ struct lruvec *mem_cgroup_page_lruvec(struct page *page, struct pglist_data *pgd mz = mem_cgroup_page_nodeinfo(memcg, page); lruvec = &mz->lruvec; out: - /* - * Since a node can be onlined after the mem_cgroup was created, - * we have to be prepared to initialize lruvec->zone here; - * and if offlined then reonlined, we need to reinitialize it. - */ - if (unlikely(lruvec->pgdat != pgdat)) - lruvec->pgdat = pgdat; + sync_lruvec_pgdat(lruvec, pgdat); return lruvec; } -- 1.8.3.1