From nobody Sun Feb 8 12:31:31 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 92CF5EB64DA for ; Tue, 11 Jul 2023 02:38:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229911AbjGKCi1 (ORCPT ); Mon, 10 Jul 2023 22:38:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229844AbjGKCiY (ORCPT ); Mon, 10 Jul 2023 22:38:24 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13C2AE4D; Mon, 10 Jul 2023 19:38:22 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4R0Q3M64vxzPk5Y; Tue, 11 Jul 2023 10:35:59 +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; Tue, 11 Jul 2023 10:38:05 +0800 From: Miaohe Lin To: , , , CC: , , , Subject: [PATCH] cgroup: put cgroup_tryget_css() inside CONFIG_CGROUP_SCHED Date: Tue, 11 Jul 2023 10:38:20 +0800 Message-ID: <20230711023820.3854596-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: dggems701-chm.china.huawei.com (10.3.19.178) 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" Put cgroup_tryget_css() inside CONFIG_CGROUP_SCHED to fix the warning of 'cgroup_tryget_css' defined but not used [-Wunused-function] when CONFIG_CGROUP_SCHED is disabled. Signed-off-by: Miaohe Lin Reviewed-by: Kamalesh Babulal --- kernel/cgroup/cgroup.c | 44 +++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index b990eda6b3cd..46401157028e 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; --=20 2.33.0