Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2451978pxb; Tue, 13 Apr 2021 02:08:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFTTdfk9p2hFJip85cXLrfXIuZAAoqS0aMav257SphGK63k65nL1R2OxtnQukxVBpjfSBl X-Received: by 2002:a17:902:aa0c:b029:ea:d2a7:32d0 with SMTP id be12-20020a170902aa0cb02900ead2a732d0mr15046901plb.18.1618304902035; Tue, 13 Apr 2021 02:08:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618304902; cv=none; d=google.com; s=arc-20160816; b=Mj7jHZhpkzMDlU2zN+MaQ76oDu/3OSd9eUDnl2D4yEAlB1I4SWHD0DWTxdxuYuLT8n 1haaKwQSMsjXEGV6FmHYXTH6ut2YAsvZN/RRS5pz8kCX9SKjQSlUVnP60OdllaeCOc0T /q2xxLVxnlcaOnqqu5XBSfTW7kba88eNFY3hNlzrjkfUig+IYNMLoBrPnMOkro2dRFeY Mfw5XyWPKwk+MmC59zw0uB6v7h/vCysVnuAHGDp3FocMeqO3pr63sUHgX2gAiGW7Ll5K FQJ5cdrA4OOA6NjcaUlO+lXCduH4QyzO9WUG9eKOWwK30bnUZIRz+oioLzCvpKRitaOp /Fug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=NPo7MPPcRQhwQwi0VkGJEhiUUoPZKpCjODwiJd36ReE=; b=nJnFh94vXCAWg3F1YHochlk+UEt+YAEINwtnNmErZsZyihpvthJblSnW6kb1GZT4BN x7FyZra4lU7FZ52f9tO3HOYddG8G/wlp0lRe9jwvtgtXdcKygw2N3vIYO5cE6aW7925G E2NXbvlUo7UhROvizR2Xqkfpe20qUQVpNPRrh+VDKZdg71UCb/q2zFbYyPnCfGIOsLTv J57/JAmOOXVnxdWoU2sy0lmPE0u1czMAp123x5PeOGE0lkFk+JrJsuL3q+AoMy6EzdXn qmn3kHOPOELG5CZxkhlxscb8blOmIC6JCcfKsNL5656A5f4u7zdTKgQ0aWLliAYbZBbm xS6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=baGnCiio; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r15si2661215pjo.90.2021.04.13.02.08.09; Tue, 13 Apr 2021 02:08:22 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=baGnCiio; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345087AbhDMG5Q (ORCPT + 99 others); Tue, 13 Apr 2021 02:57:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237122AbhDMG5G (ORCPT ); Tue, 13 Apr 2021 02:57:06 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70228C061756 for ; Mon, 12 Apr 2021 23:56:47 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id d1so15228352ybj.15 for ; Mon, 12 Apr 2021 23:56:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=NPo7MPPcRQhwQwi0VkGJEhiUUoPZKpCjODwiJd36ReE=; b=baGnCiioZTP9ADs7IVEB/mQcb3cvKmCKgg9drauUZQ+Tp4ZFhqV8SVk54iVXXC/g4a cpq3VBdcxXnUKSenbwAnH9Jp0vcf5HUqcvm0/PItCUte5xo66HxROV5Obn4PGte89xi9 p+R4eomS1+PIS2MLxgShOMpnFvyxeBgpYJvBAHU3FKJ3dtUuQ8TMqtRRYgDLRETQtThQ kFEKuP+qBTfl6NS1fHTb9BFTIgP5Z/N1DOBc07huBgFItja27dgr56dPRNvm09QqhgN8 KNYrM6tJs6Md4vWQFOufoHl576biAVAYjl1tmh0+nRa81An0lfEfinpclElVWZVJap6f 3K6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=NPo7MPPcRQhwQwi0VkGJEhiUUoPZKpCjODwiJd36ReE=; b=VQUPKq30uKeUAF6Ejq35xfekJF7nOdr7VngI/76uX8lOU1pIKoO4mC5aTAYeOIOrr8 d9hpCUWEcuxEWFU49K2HTzz6r9TRtei0Z3TR3n5CdNJqIigsBiTmuLGfOPgRfmTdf4p1 Gy4MP3Ln+GHBFflwKZ+f5OPcq+R/slU8HpAWd4KR6PshMeb/Uf/RnHWhIQ3qI8S3QLXv K66JL1wL5gT1XsIvdtHxoLQ/CLC3QqmB2rSMp/tB7Orqc6DK48r53Kt037j1ALstA0O7 qY6CPZRsbCum+NhqDvT8/KN1dsIkOSEmKUt0TfQc8hUEIm0I2juU0HYZsBV7D9xioz8r p45w== X-Gm-Message-State: AOAM533p7SYDUFBf9Ifm7vaTwGtjEO4CrlaCuZ4KoZ7jp3M6fMJFAFBH 4BBDhvIWmrjLJRxSeBVIWDYQXg1lPro= X-Received: from yuzhao.bld.corp.google.com ([2620:15c:183:200:d02d:cccc:9ebe:9fe9]) (user=yuzhao job=sendgmr) by 2002:a25:8b86:: with SMTP id j6mr39368340ybl.470.1618297006589; Mon, 12 Apr 2021 23:56:46 -0700 (PDT) Date: Tue, 13 Apr 2021 00:56:21 -0600 In-Reply-To: <20210413065633.2782273-1-yuzhao@google.com> Message-Id: <20210413065633.2782273-5-yuzhao@google.com> Mime-Version: 1.0 References: <20210413065633.2782273-1-yuzhao@google.com> X-Mailer: git-send-email 2.31.1.295.g9ea45b61b8-goog Subject: [PATCH v2 04/16] include/linux/cgroup.h: export cgroup_mutex From: Yu Zhao To: linux-mm@kvack.org Cc: Alex Shi , Andi Kleen , Andrew Morton , Benjamin Manes , Dave Chinner , Dave Hansen , Hillf Danton , Jens Axboe , Johannes Weiner , Jonathan Corbet , Joonsoo Kim , Matthew Wilcox , Mel Gorman , Miaohe Lin , Michael Larabel , Michal Hocko , Michel Lespinasse , Rik van Riel , Roman Gushchin , Rong Chen , SeongJae Park , Tim Chen , Vlastimil Babka , Yang Shi , Ying Huang , Zi Yan , linux-kernel@vger.kernel.org, lkp@lists.01.org, page-reclaim@google.com, Yu Zhao Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org cgroup_mutex is needed to synchronize with memcg creations. Signed-off-by: Yu Zhao --- include/linux/cgroup.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index 4f2f79de083e..bd5744360cfa 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h @@ -432,6 +432,18 @@ static inline void cgroup_put(struct cgroup *cgrp) css_put(&cgrp->self); } +extern struct mutex cgroup_mutex; + +static inline void cgroup_lock(void) +{ + mutex_lock(&cgroup_mutex); +} + +static inline void cgroup_unlock(void) +{ + mutex_unlock(&cgroup_mutex); +} + /** * task_css_set_check - obtain a task's css_set with extra access conditions * @task: the task to obtain css_set for @@ -446,7 +458,6 @@ static inline void cgroup_put(struct cgroup *cgrp) * as locks used during the cgroup_subsys::attach() methods. */ #ifdef CONFIG_PROVE_RCU -extern struct mutex cgroup_mutex; extern spinlock_t css_set_lock; #define task_css_set_check(task, __c) \ rcu_dereference_check((task)->cgroups, \ @@ -704,6 +715,8 @@ struct cgroup; static inline u64 cgroup_id(const struct cgroup *cgrp) { return 1; } static inline void css_get(struct cgroup_subsys_state *css) {} static inline void css_put(struct cgroup_subsys_state *css) {} +static inline void cgroup_lock(void) {} +static inline void cgroup_unlock(void) {} static inline int cgroup_attach_task_all(struct task_struct *from, struct task_struct *t) { return 0; } static inline int cgroupstats_build(struct cgroupstats *stats, -- 2.31.1.295.g9ea45b61b8-goog