Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cgroup: put cgroup_tryget_css() inside CONFIG_CGROUP_SCHED

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 <linmiaohe@huawei.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

Miaohe Lin and committed by
Tejun Heo
d1d4ff5d 3ae0b773

+22 -22
+22 -22
kernel/cgroup/cgroup.c
··· 493 493 } 494 494 495 495 /** 496 - * cgroup_tryget_css - try to get a cgroup's css for the specified subsystem 497 - * @cgrp: the cgroup of interest 498 - * @ss: the subsystem of interest 499 - * 500 - * Find and get @cgrp's css associated with @ss. If the css doesn't exist 501 - * or is offline, %NULL is returned. 502 - */ 503 - static struct cgroup_subsys_state *cgroup_tryget_css(struct cgroup *cgrp, 504 - struct cgroup_subsys *ss) 505 - { 506 - struct cgroup_subsys_state *css; 507 - 508 - rcu_read_lock(); 509 - css = cgroup_css(cgrp, ss); 510 - if (css && !css_tryget_online(css)) 511 - css = NULL; 512 - rcu_read_unlock(); 513 - 514 - return css; 515 - } 516 - 517 - /** 518 496 * cgroup_e_css_by_mask - obtain a cgroup's effective css for the specified ss 519 497 * @cgrp: the cgroup of interest 520 498 * @ss: the subsystem of interest (%NULL returns @cgrp->self) ··· 3633 3655 } 3634 3656 3635 3657 #ifdef CONFIG_CGROUP_SCHED 3658 + /** 3659 + * cgroup_tryget_css - try to get a cgroup's css for the specified subsystem 3660 + * @cgrp: the cgroup of interest 3661 + * @ss: the subsystem of interest 3662 + * 3663 + * Find and get @cgrp's css associated with @ss. If the css doesn't exist 3664 + * or is offline, %NULL is returned. 3665 + */ 3666 + static struct cgroup_subsys_state *cgroup_tryget_css(struct cgroup *cgrp, 3667 + struct cgroup_subsys *ss) 3668 + { 3669 + struct cgroup_subsys_state *css; 3670 + 3671 + rcu_read_lock(); 3672 + css = cgroup_css(cgrp, ss); 3673 + if (css && !css_tryget_online(css)) 3674 + css = NULL; 3675 + rcu_read_unlock(); 3676 + 3677 + return css; 3678 + } 3679 + 3636 3680 static int cgroup_extra_stat_show(struct seq_file *seq, int ssid) 3637 3681 { 3638 3682 struct cgroup *cgrp = seq_css(seq)->cgroup;