Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp36195231rwd; Mon, 10 Jul 2023 20:00:28 -0700 (PDT) X-Google-Smtp-Source: APBJJlHuEEMrjmSQoCSX8l7aQzZ185833WM7nFJQzbs9WFMnW0/IaG1k6pQCSdNFK2MfTo5V1/sx X-Received: by 2002:a05:6402:1b0b:b0:51d:a6e3:81f4 with SMTP id by11-20020a0564021b0b00b0051da6e381f4mr12724811edb.10.1689044428257; Mon, 10 Jul 2023 20:00:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689044428; cv=none; d=google.com; s=arc-20160816; b=AushIGnZ7ek1M/1215O4U9U1gicv9ikxYzDpPr1U5HHeGCaXW6KT75BtlagvSi9Akv 2nu7+Lkf/zVXcW6SK5QAkDIfqR/3vwbIopBg+SLhPvYmiKIaZ/plZ5KXFHhN6rd8935S 0vu9c/uFJ6JL2Uzb05Iru4KE/O2fy6/pdkZwtIVQ24dBYwocGR77stQwioIjMt1inqSA /jyvcxlC0VG5zV/5LZ0JPv5Fy2jPIy3ejNop00FGVfurUvxWVq0mASjapR6TPMy7nPk5 3GeMV7zdMgDPapEssHwFeN8esbpxGXHZybCulY3Ji3Q1YAWn9/SQcN1o4i7+cynG3uFu d3dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=jkaZm9ukTrESC3UJfq/tTNszgz4mm9hDQPJ7q5uYUmM=; fh=r0JBE4s2Vl/bPuj6SRT77Qp3jst4aOwF9lEieMo1+WU=; b=Hj4TwlpwszsTB33mQUph9KYe1lgA89FrKc2UymN5Qipt59BfuzIcE2DBVyLXWz9puH SL5KnH8nVR3MyrgW1WH2wQvPjHGzB6KYHodmX9rAjAo8KOVjTV8BPRk8QsVbUew6qLnJ 4nUYcjEIEtjIF4YZCkSMcqMruiWIFgcGhQoB1/VnFhVz+RtIuEA81q5sVXGUs/FmBARs PCUYnzx/TQUSaifli0CbtkOFhAUZeEU7HAs40g0B7OK9bAeP8dV1MSDwBOEOqhr7S6u8 rNoTHe0n4dd3It6T8sEEB7CM2LIkvrctbcLFkkomyHKobqebeGc0B3CCuq6WIztXmrXr SJgg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id be5-20020a0564021a2500b0050dfd8e2a70si1045997edb.78.2023.07.10.20.00.02; Mon, 10 Jul 2023 20:00:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229714AbjGKCi1 (ORCPT + 99 others); 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: 7BIT Content-Type: text/plain; charset=US-ASCII 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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 cgroup *cgrp, return &cgrp->self; } -/** - * cgroup_tryget_css - try to get a cgroup's css for the specified subsystem - * @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 = cgroup_css(cgrp, ss); - if (css && !css_tryget_online(css)) - css = NULL; - rcu_read_unlock(); - - return css; -} - /** * cgroup_e_css_by_mask - obtain a cgroup's effective css for the specified ss * @cgrp: the cgroup of interest @@ -3655,6 +3633,28 @@ static int cgroup_stat_show(struct seq_file *seq, void *v) } #ifdef CONFIG_CGROUP_SCHED +/** + * cgroup_tryget_css - try to get a cgroup's css for the specified subsystem + * @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 = cgroup_css(cgrp, ss); + if (css && !css_tryget_online(css)) + css = NULL; + rcu_read_unlock(); + + return css; +} + static int cgroup_extra_stat_show(struct seq_file *seq, int ssid) { struct cgroup *cgrp = seq_css(seq)->cgroup; -- 2.33.0