From patchwork Fri Jan 3 01:50:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: JP Kobryn X-Patchwork-Id: 13925085 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 CDF1BE77198 for ; Fri, 3 Jan 2025 01:50:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AFD286B0088; Thu, 2 Jan 2025 20:50:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AAE396B0089; Thu, 2 Jan 2025 20:50:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 83C626B008A; Thu, 2 Jan 2025 20:50:38 -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 64FC66B0088 for ; Thu, 2 Jan 2025 20:50:38 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id E2470AEB7C for ; Fri, 3 Jan 2025 01:50:37 +0000 (UTC) X-FDA: 82964457744.17.DC52D1E Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by imf02.hostedemail.com (Postfix) with ESMTP id 2CBEA80005 for ; Fri, 3 Jan 2025 01:48:57 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Xp4aMFQo; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of inwardvessel@gmail.com designates 209.85.214.169 as permitted sender) smtp.mailfrom=inwardvessel@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1735868988; a=rsa-sha256; cv=none; b=LrYgdKxLge2JOqlEWhp/XxOVd4322SEEhCCITnKcJhUxcp8+LHP15yoIh5MP8WcH4NQApI Wyqk7EbXQwzmXWwbWhcvVMaQLlMrq6YVF72O/ULLOytqTku9Cibe/zRS5vNvN8zeqrQuoo 99Ho4IcLBqoUFxF3em0Jjs4yw35OslA= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Xp4aMFQo; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of inwardvessel@gmail.com designates 209.85.214.169 as permitted sender) smtp.mailfrom=inwardvessel@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1735868988; 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=0fygAlv7C86dgt6jCWO9W9TZivz+mHpPPlFRRnfsUsg=; b=TW/9fuFm0ZC06Q9hDbXVRHU4aTUOFR0v88KibHWUpk/vRGh5tsOPE4/qZEHLZojrRwh9Bf dWm/9IQytaOPR6O51J6Tz5eaKvDDo833wW0pZ37pyteafVtgwIT4NuSOLqYMPEs5XCFk3I T7nIg/I/vvLwwJdKfEs8PR4vcVV1IXQ= Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-21683192bf9so162871535ad.3 for ; Thu, 02 Jan 2025 17:50:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735869035; x=1736473835; 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=0fygAlv7C86dgt6jCWO9W9TZivz+mHpPPlFRRnfsUsg=; b=Xp4aMFQoHcNbn0rKGXebbWY5IpeY8sqi/Nf/6wu/OK/Y2iI7akRj+Z75jRY7tOdxwk KOMnpza3Q+opqlHVPAQk2Z5ocpoygrmdg62UZG3j4z21QLy0wR9LCXrZlyo3C7zJeTLU cg1BF86SynQbBrwTTCvrNBj/Avs5t70U4tIxTPDkqzwz+JfHuqy8mvVak0EEsDeBjLuy 65orQL6Di/MzCFdtTQjOWALDYl804CVastWdMvtOuI4Y2Wlvq8abz+FWI6RB2TOVgizu POqJWn75k+BiWEymANqJ8XdM13MYt+mrqaw4osyDQmsy3dXkxrXm9kl8f4AK9ZSqXkAZ 4s7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735869035; x=1736473835; 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=0fygAlv7C86dgt6jCWO9W9TZivz+mHpPPlFRRnfsUsg=; b=d529C0Jztn20OdC5wj82Lg68EdfZ3Q32OWg7iBjocC6sMgyNfX5mDVtTxybeBjX8Ru 3dezhs0F2Dc2NVyqhFpDLVw/zMsa0oFpD2+97kiY3D4McK7p4wNK+q1uxusqzjOTGNgt DS4xb12GDjSCj1zHs/eMdsZIN/CWgG16SlcKaVmZI/zpzUsAYtP6+a+oMVS81IRYmxTv zRYLgEIvGfcouXVksIPWkQco3CtIUcfaWHf1GXXW552ulfOD2m7IVkBF683ZKc/yWnwj QYmoA+FXGzhb3O3bSzjEw7UXRxsxVKGccC6xo39T/gR2rt2f0qDEk5q9kvj/4ArRvEJb O9fw== X-Gm-Message-State: AOJu0Yyy86oRYRa7iU6a4Xk2IZm3wm829RiiQgKL6m5gzBx8LVyQK5NN 8PtwgxOclvxKphqLX+Qn6aL0Mvr67YuBltCizXdEqgNBIbXImq0s X-Gm-Gg: ASbGncu3P3YunuGX+OAIYSCrIcz5wHjbFwDu+n5ZyflwtzPOTf9tYAOBPfvLMKVb58M eAa9a+Xij3xQz+ihgo99ikbY76NYiMke3NpGRxMONGdWrFqvq1gcwWl3rljaXl9s2jHiNn39BtM Is4tuzbJJf+i2n0/paQoq88gFcUiJ2P4cXm+WjJJuPBRFaX8G4ijT9i68m3N32W/VCx53PxkZbw yJ2AZsJoyNlguSyPcdV9EnY8zQ853nrQL52tqI+uZBWhKX4hp1fNObQB8W4TM/ztRj3Sou3uqD2 7MgHDOYxOtkCCh7Zpw== X-Google-Smtp-Source: AGHT+IFUq6pIKACZFu16YUBj6vJ2nI7etocge0+ZlELfgHcsYpw2HURYCpbJolc7uELa/ETm08W0tQ== X-Received: by 2002:a17:902:c951:b0:215:a039:738 with SMTP id d9443c01a7336-219e6e8928emr709570885ad.5.1735869034959; Thu, 02 Jan 2025 17:50:34 -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-219dca04ce7sm228851505ad.283.2025.01.02.17.50.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jan 2025 17:50:34 -0800 (PST) From: JP Kobryn To: shakeel.butt@linux.dev, tj@kernel.org, mhocko@kernel.org, hannes@cmpxchg.org, yosryahmed@google.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, cgroups@vger.kernel.org Subject: [RFC PATCH 3/9 v2] cgroup: change cgroup to css in rstat init and exit api Date: Thu, 2 Jan 2025 17:50:14 -0800 Message-ID: <20250103015020.78547-4-inwardvessel@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250103015020.78547-1-inwardvessel@gmail.com> References: <20250103015020.78547-1-inwardvessel@gmail.com> MIME-Version: 1.0 X-Stat-Signature: ydudtkt6hwsa8nwkd5ngw9qzqyd8cxoz X-Rspam-User: X-Rspamd-Queue-Id: 2CBEA80005 X-Rspamd-Server: rspam08 X-HE-Tag: 1735868937-971665 X-HE-Meta: U2FsdGVkX1+fCEmMja76KHb1tXxDLOUhvXcN1iTLm2UfV4X6mCpbIhBjnl0wRerp+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nvQR0SyHqyWg57j/wMoe2O/8+QVnIXlufKbsHsKuSrmhAD6iWgpbUNOHgdeteplT7nEpbU+HnVvG7UrNfEqdH6h0JmX8Sd8Jz9j9z0/I7HCfr/1Xu0MEhDsM7SGO7PVLlYuNpkxJByhbayX+nMYfrNzpqa39IWkitsZzp3r0yZ4HUAgaojzmDgglSWa0VkUtzYzZdQjUkkg/MrNO4UU1fo4jb3w== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, 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 rstat init and exit 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);