From patchwork Tue Dec 24 01:13:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: JP Kobryn X-Patchwork-Id: 13919570 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8B45E7718D for ; Tue, 24 Dec 2024 01:14:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3FBD26B0088; Mon, 23 Dec 2024 20:14:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3ABE66B0089; Mon, 23 Dec 2024 20:14:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1FF186B008A; Mon, 23 Dec 2024 20:14:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id EEFBD6B0088 for ; Mon, 23 Dec 2024 20:14:20 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 81AEF4667D for ; Tue, 24 Dec 2024 01:14:20 +0000 (UTC) X-FDA: 82928080956.15.D51C4B9 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by imf29.hostedemail.com (Postfix) with ESMTP id 48415120002 for ; Tue, 24 Dec 2024 01:13:24 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Rn34CfIz; spf=pass (imf29.hostedemail.com: domain of inwardvessel@gmail.com designates 209.85.214.176 as permitted sender) smtp.mailfrom=inwardvessel@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1735002840; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=JL2jgd7riB8bL0/y/2MxSvAIl3x85Oo9zvXWGx0Vk6k=; b=PxvBDMPf9kcR7JVlEjKNHE9SJQeecBu4inO4LSzabi4exPheFs5HclT4WCu+UJvYtorVON ydzFj6zOK8/H39NS9ezlHjFsjzXEd/vRRryX1qZEMfSJ2Ue2ul6tOl0dHG/Dq8y+aImEVo x5qyHvSd2KpHgxo9cmHJui6tCQeQ7AE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1735002840; a=rsa-sha256; cv=none; b=3vW0h4VqUV21wQylE4/npliHWmyLbDrfPNtvXSU3X3GKAPQpopYrI8OGOHVuo0sXGBY5er 7DcXo8dbC4OAktJCPme2qeQRxbRbOLqukLOrbRGKBKFJd6+QoU/BjVbeLaXNd9jMe13eo0 sO+m16h+d68AWgsjqy/9XYgN+Iesu08= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Rn34CfIz; spf=pass (imf29.hostedemail.com: domain of inwardvessel@gmail.com designates 209.85.214.176 as permitted sender) smtp.mailfrom=inwardvessel@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-21669fd5c7cso45795325ad.3 for ; Mon, 23 Dec 2024 17:14:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735002857; x=1735607657; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JL2jgd7riB8bL0/y/2MxSvAIl3x85Oo9zvXWGx0Vk6k=; b=Rn34CfIzKxGwPFjCMteVk/oFqFGzHuznxMksMz9Vg7Qzu8hiKTVjKuuBbqHV5ArkVl nj7fTxlLRTMfysfdfeQCpCm5DGkhgD2indVdCV3+z3Qmx/k3uGa8YxnZ0wv0Q/Hwif6M zxycO+Eo42/MlFRwcODX1fiz97s7EHH+p0bepUUC7NuLqOR+WA3DnURGsb8c76kC2XLP tUl7rs7NTNwX9enXiU5VBrDANc/avKnqe9PoaVdgRH0sVn++Qs12uUL3ASAoSLRrDhPF mb+UkCNvxx1cY3OabKxq0nAXjN5uHHphyfewVKTFfhyLPwy6uth5YNdmecLscsHitdpA r2Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735002857; x=1735607657; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JL2jgd7riB8bL0/y/2MxSvAIl3x85Oo9zvXWGx0Vk6k=; b=ZtVsXr7KvVThYxvWcUtqOJsRsnz2PLil+Y91a5dDtX6Yqt5Y+K4iUPVQJ/hB/+mFNv sqXoWdZ6o7mdVpcodKy+eh9XK7ZQde44PWajPSH/5NJLM4i9SbQ7Gl1iBd7H98H/xEHI c7R6sS8XCIC8BuWSxt7sy8J9ICAvXESHoUnksuitLbcfijRZ6QhXLHXqfxGSTjzca/Yv xXRAjFdgrj1LniTYb1C3xBbN+cQdIpP9C+ISVrKq3aM8uw4N4uTW2FUpDztzeQMZojKF 6hYa2CWUW6xe4BvObp2d0qlzGjp3qANZjeqh5QoslDK+plRzmoGNMgBKklLyQow71dkW d4Dw== X-Gm-Message-State: AOJu0YzH7ss38dGqFGdhZfe4PcAawdnW+7P59nzfuWpgTkZiqkilyYRG WNSII3EOLd7dWPLONL/0RMM9sbtqq5BJ8Oj4+Ejjccj79w9Eb8no X-Gm-Gg: ASbGncsBwEoIyBj62pnUlcZUdDmEsXLNzbIi0n5Xn3SLYHoolPucuV5MgH2PPnTyy2c r9QBVgyDjxJ+cTFWAUyLq/7Rdz7qbddGmgKisYvaDuFETNv9RUFzWEf2liHNs77p8EnJ7r2LdUt LT0d2C/dMpNACn+e+WW1LlYDEhqSjtgGpHAeOF2fD4MPuoM0SOAy4EhBh1bqQPyFQuTWlcGgyzp pT/I4QNhmv2gBr8G9SuI9KwyQmx9kXEXkzePMnPkssJBzen5i+AAnCGo91DG5zOPFJFVmGgvhLD 8od7Mbw5Iy2kdEfB0w== X-Google-Smtp-Source: AGHT+IE3QHLwg9ReNpugqbcBsAF2fSOEsH+CCNMaVbUB+N1MFpxZaa07QtuA97SwYcItxeQb83M4Xw== X-Received: by 2002:a17:902:c943:b0:216:6d48:9177 with SMTP id d9443c01a7336-219e6e8c7e8mr225018355ad.11.1735002857492; Mon, 23 Dec 2024 17:14:17 -0800 (PST) Received: from saturn.. (c-67-188-127-15.hsd1.ca.comcast.net. [67.188.127.15]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc970c84sm79541255ad.58.2024.12.23.17.14.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Dec 2024 17:14:16 -0800 (PST) From: JP Kobryn To: shakeel.butt@linux.dev, hannes@cmpxchg.org, yosryahmed@google.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, cgroups@vger.kernel.org Subject: [PATCH 3/9 RFC] cgroup: change cgroup to css in rstat init and exit api Date: Mon, 23 Dec 2024 17:13:56 -0800 Message-ID: <20241224011402.134009-4-inwardvessel@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241224011402.134009-1-inwardvessel@gmail.com> References: <20241224011402.134009-1-inwardvessel@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 48415120002 X-Stat-Signature: ku1ch6e8p71knxiq8ts8tikj6dspb4a8 X-Rspam-User: X-HE-Tag: 1735002804-891006 X-HE-Meta: U2FsdGVkX1/DTYRpHYdCo9F51qJh16Ewfbxzwtq1mxNybkDb30acl+biN9lYUtNoajDssAAP5K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LNXYxiDaXOdnYHC0X0Dgdz5hch6SgNXnUE/YepS0ULb74JXgyvpo8YpaLB+sdkmWPV+lpsGHAlnwTSeUgoxRpGdUm7ZTEB47+t+GooU3y0ZSO4OLkuT+A/DAU2e1M6GtvKewgXTMTPZIiuUnHb4V5jhdP77jC54ZbeyrC/zeQCHxYpymwSWytjJtHA2978NP8YgUDrYrQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.069124, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Change API calls to accept a cgroup_subsys_state instead of a cgroup. Signed-off-by: JP Kobryn --- kernel/cgroup/cgroup-internal.h | 4 ++-- kernel/cgroup/cgroup.c | 16 ++++++++++------ kernel/cgroup/rstat.c | 6 ++++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/kernel/cgroup/cgroup-internal.h b/kernel/cgroup/cgroup-internal.h index c964dd7ff967..87d062baff90 100644 --- a/kernel/cgroup/cgroup-internal.h +++ b/kernel/cgroup/cgroup-internal.h @@ -269,8 +269,8 @@ int cgroup_task_count(const struct cgroup *cgrp); /* * rstat.c */ -int cgroup_rstat_init(struct cgroup *cgrp); -void cgroup_rstat_exit(struct cgroup *cgrp); +int cgroup_rstat_init(struct cgroup_subsys_state *css); +void cgroup_rstat_exit(struct cgroup_subsys_state *css); void cgroup_rstat_boot(void); void cgroup_base_stat_cputime_show(struct seq_file *seq); diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index fdddd5ec5f3c..848e09f433c0 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -1358,7 +1358,7 @@ static void cgroup_destroy_root(struct cgroup_root *root) cgroup_unlock(); - cgroup_rstat_exit(cgrp); + cgroup_rstat_exit(&cgrp->self); kernfs_destroy_root(root->kf_root); cgroup_free_root(root); } @@ -2132,7 +2132,7 @@ int cgroup_setup_root(struct cgroup_root *root, u16 ss_mask) if (ret) goto destroy_root; - ret = cgroup_rstat_init(root_cgrp); + ret = cgroup_rstat_init(&root_cgrp->self); if (ret) goto destroy_root; @@ -2174,7 +2174,7 @@ int cgroup_setup_root(struct cgroup_root *root, u16 ss_mask) goto out; exit_stats: - cgroup_rstat_exit(root_cgrp); + cgroup_rstat_exit(&root_cgrp->self); destroy_root: kernfs_destroy_root(root->kf_root); root->kf_root = NULL; @@ -5435,7 +5435,7 @@ static void css_free_rwork_fn(struct work_struct *work) cgroup_put(cgroup_parent(cgrp)); kernfs_put(cgrp->kn); psi_cgroup_free(cgrp); - cgroup_rstat_exit(cgrp); + cgroup_rstat_exit(css); kfree(cgrp); } else { /* @@ -5686,7 +5686,11 @@ static struct cgroup *cgroup_create(struct cgroup *parent, const char *name, if (ret) goto out_free_cgrp; - ret = cgroup_rstat_init(cgrp); + /* init self cgroup early so css->cgroup is valid within cgroup_rstat_init() + * note that this will go away in a subsequent patch in this series + */ + cgrp->self.cgroup = cgrp; + ret = cgroup_rstat_init(&cgrp->self); if (ret) goto out_cancel_ref; @@ -5779,7 +5783,7 @@ static struct cgroup *cgroup_create(struct cgroup *parent, const char *name, out_kernfs_remove: kernfs_remove(cgrp->kn); out_stat_exit: - cgroup_rstat_exit(cgrp); + cgroup_rstat_exit(&cgrp->self); out_cancel_ref: percpu_ref_exit(&cgrp->self.refcnt); out_free_cgrp: diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c index 1b7ef8690a09..01a5c185b02a 100644 --- a/kernel/cgroup/rstat.c +++ b/kernel/cgroup/rstat.c @@ -390,8 +390,9 @@ void cgroup_rstat_flush_release(struct cgroup_subsys_state *css) __cgroup_rstat_unlock(css, -1); } -int cgroup_rstat_init(struct cgroup *cgrp) +int cgroup_rstat_init(struct cgroup_subsys_state *css) { + struct cgroup *cgrp = css->cgroup; int cpu; /* the root cgrp has rstat_cpu preallocated */ @@ -412,8 +413,9 @@ int cgroup_rstat_init(struct cgroup *cgrp) return 0; } -void cgroup_rstat_exit(struct cgroup *cgrp) +void cgroup_rstat_exit(struct cgroup_subsys_state *css) { + struct cgroup *cgrp = css->cgroup; int cpu; cgroup_rstat_flush(&cgrp->self);