From nobody Sun Feb 8 23:05:59 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7E56C001E0 for ; Sun, 23 Jul 2023 03:19:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229782AbjGWDTt (ORCPT ); Sat, 22 Jul 2023 23:19:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229545AbjGWDTq (ORCPT ); Sat, 22 Jul 2023 23:19:46 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D330F10CA; Sat, 22 Jul 2023 20:19:44 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4R7pPL6zp3zHnVL; Sun, 23 Jul 2023 11:17:10 +0800 (CST) Received: from huawei.com (10.174.151.185) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Sun, 23 Jul 2023 11:19:32 +0800 From: Miaohe Lin To: , , CC: , , Subject: [PATCH] cgroup: minor cleanup for cgroup_local_stat_show() Date: Sun, 23 Jul 2023 11:19:32 +0800 Message-ID: <20230723031932.3152951-1-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.174.151.185] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Make it under CONFIG_CGROUP_SCHED to rid of __maybe_unused annotation. Also put cgroup_tryget_css() inside CONFIG_CGROUP_SCHED as it's only called when CONFIG_CGROUP_SCHED. No functional change intended. Signed-off-by: Miaohe Lin --- kernel/cgroup/cgroup.c | 63 ++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 31603146e7c2..7296331c7582 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -492,28 +492,6 @@ static struct cgroup_subsys_state *cgroup_css(struct c= group *cgrp, return &cgrp->self; } =20 -/** - * cgroup_tryget_css - try to get a cgroup's css for the specified subsyst= em - * @cgrp: the cgroup of interest - * @ss: the subsystem of interest - * - * Find and get @cgrp's css associated with @ss. If the css doesn't exist - * or is offline, %NULL is returned. - */ -static struct cgroup_subsys_state *cgroup_tryget_css(struct cgroup *cgrp, - struct cgroup_subsys *ss) -{ - struct cgroup_subsys_state *css; - - rcu_read_lock(); - css =3D cgroup_css(cgrp, ss); - if (css && !css_tryget_online(css)) - css =3D NULL; - rcu_read_unlock(); - - return css; -} - /** * cgroup_e_css_by_mask - obtain a cgroup's effective css for the specifie= d ss * @cgrp: the cgroup of interest @@ -3655,6 +3633,28 @@ static int cgroup_stat_show(struct seq_file *seq, vo= id *v) } =20 #ifdef CONFIG_CGROUP_SCHED +/** + * cgroup_tryget_css - try to get a cgroup's css for the specified subsyst= em + * @cgrp: the cgroup of interest + * @ss: the subsystem of interest + * + * Find and get @cgrp's css associated with @ss. If the css doesn't exist + * or is offline, %NULL is returned. + */ +static struct cgroup_subsys_state *cgroup_tryget_css(struct cgroup *cgrp, + struct cgroup_subsys *ss) +{ + struct cgroup_subsys_state *css; + + rcu_read_lock(); + css =3D cgroup_css(cgrp, ss); + if (css && !css_tryget_online(css)) + css =3D NULL; + rcu_read_unlock(); + + return css; +} + static int cgroup_extra_stat_show(struct seq_file *seq, int ssid) { struct cgroup *cgrp =3D seq_css(seq)->cgroup; @@ -3686,8 +3686,9 @@ static int cpu_stat_show(struct seq_file *seq, void *= v) return ret; } =20 -static int __maybe_unused cgroup_local_stat_show(struct seq_file *seq, - struct cgroup *cgrp, int ssid) +#ifdef CONFIG_CGROUP_SCHED +static int cgroup_local_stat_show(struct seq_file *seq, + struct cgroup *cgrp, int ssid) { struct cgroup_subsys *ss =3D cgroup_subsys[ssid]; struct cgroup_subsys_state *css; @@ -3707,14 +3708,16 @@ static int __maybe_unused cgroup_local_stat_show(st= ruct seq_file *seq, =20 static int cpu_local_stat_show(struct seq_file *seq, void *v) { - struct cgroup __maybe_unused *cgrp =3D seq_css(seq)->cgroup; - int ret =3D 0; + struct cgroup *cgrp =3D seq_css(seq)->cgroup; =20 -#ifdef CONFIG_CGROUP_SCHED - ret =3D cgroup_local_stat_show(seq, cgrp, cpu_cgrp_id); -#endif - return ret; + return cgroup_local_stat_show(seq, cgrp, cpu_cgrp_id); +} +#else +static int cpu_local_stat_show(struct seq_file *seq, void *v) +{ + return 0; } +#endif =20 #ifdef CONFIG_PSI static int cgroup_io_pressure_show(struct seq_file *seq, void *v) --=20 2.33.0