Skip to content

Commit 541a421

Browse files
inwardvesselhtejun
authored andcommitted
cgroup: compare css to cgroup::self in helper for distingushing css
Adjust the implementation of css_is_cgroup() so that it compares the given css to cgroup::self. Rename the function to css_is_self() in order to reflect that. Change the existing css->ss NULL check to a warning in the true branch. Finally, adjust call sites to use the new function name. Signed-off-by: JP Kobryn <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent b2713a5 commit 541a421

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

include/linux/cgroup.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,15 @@ static inline bool css_is_dying(struct cgroup_subsys_state *css)
347347
return css->flags & CSS_DYING;
348348
}
349349

350-
static inline bool css_is_cgroup(struct cgroup_subsys_state *css)
350+
static inline bool css_is_self(struct cgroup_subsys_state *css)
351351
{
352-
return css->ss == NULL;
352+
if (css == &css->cgroup->self) {
353+
/* cgroup::self should not have subsystem association */
354+
WARN_ON(css->ss != NULL);
355+
return true;
356+
}
357+
358+
return false;
353359
}
354360

355361
static inline void cgroup_get(struct cgroup *cgrp)

kernel/cgroup/cgroup.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,7 +1706,7 @@ static void css_clear_dir(struct cgroup_subsys_state *css)
17061706

17071707
css->flags &= ~CSS_VISIBLE;
17081708

1709-
if (css_is_cgroup(css)) {
1709+
if (css_is_self(css)) {
17101710
if (cgroup_on_dfl(cgrp)) {
17111711
cgroup_addrm_files(css, cgrp,
17121712
cgroup_base_files, false);
@@ -1738,7 +1738,7 @@ static int css_populate_dir(struct cgroup_subsys_state *css)
17381738
if (css->flags & CSS_VISIBLE)
17391739
return 0;
17401740

1741-
if (css_is_cgroup(css)) {
1741+
if (css_is_self(css)) {
17421742
if (cgroup_on_dfl(cgrp)) {
17431743
ret = cgroup_addrm_files(css, cgrp,
17441744
cgroup_base_files, true);
@@ -5406,7 +5406,7 @@ static void css_free_rwork_fn(struct work_struct *work)
54065406

54075407
percpu_ref_exit(&css->refcnt);
54085408

5409-
if (ss) {
5409+
if (!css_is_self(css)) {
54105410
/* css free path */
54115411
struct cgroup_subsys_state *parent = css->parent;
54125412
int id = css->id;
@@ -5460,7 +5460,7 @@ static void css_release_work_fn(struct work_struct *work)
54605460
css->flags |= CSS_RELEASED;
54615461
list_del_rcu(&css->sibling);
54625462

5463-
if (ss) {
5463+
if (!css_is_self(css)) {
54645464
struct cgroup *parent_cgrp;
54655465

54665466
/* css release path */

0 commit comments

Comments
 (0)