Skip to content

Commit 54766d4

Browse files
committed
cgroup: rename CGRP_REMOVED to CGRP_DEAD
We will add another flag indicating that the cgroup is in the process of being killed. REMOVING / REMOVED is more difficult to distinguish and cgroup_is_removing()/cgroup_is_removed() are a bit awkward. Also, later percpu_ref usage will involve "kill"ing the refcnt. s/CGRP_REMOVED/CGRP_DEAD/ s/cgroup_is_removed()/cgroup_is_dead() This patch is purely cosmetic. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Li Zefan <lizefan@huawei.com>
1 parent 5de0107 commit 54766d4

2 files changed

Lines changed: 15 additions & 17 deletions

File tree

‎include/linux/cgroup.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ static inline void css_put(struct cgroup_subsys_state *css)
143143
/* bits in struct cgroup flags field */
144144
enum {
145145
/* Control Group is dead */
146-
CGRP_REMOVED,
146+
CGRP_DEAD,
147147
/*
148148
* Control Group has previously had a child cgroup or a task,
149149
* but no longer (only if CGRP_NOTIFY_ON_RELEASE is set)

‎kernel/cgroup.c‎

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,9 @@ static int css_refcnt(struct cgroup_subsys_state *css)
226226
}
227227

228228
/* convenient tests for these bits */
229-
static inline bool cgroup_is_removed(const struct cgroup *cgrp)
229+
static inline bool cgroup_is_dead(const struct cgroup *cgrp)
230230
{
231-
return test_bit(CGRP_REMOVED, &cgrp->flags);
231+
return test_bit(CGRP_DEAD, &cgrp->flags);
232232
}
233233

234234
/**
@@ -300,7 +300,7 @@ static inline struct cftype *__d_cft(struct dentry *dentry)
300300
static bool cgroup_lock_live_group(struct cgroup *cgrp)
301301
{
302302
mutex_lock(&cgroup_mutex);
303-
if (cgroup_is_removed(cgrp)) {
303+
if (cgroup_is_dead(cgrp)) {
304304
mutex_unlock(&cgroup_mutex);
305305
return false;
306306
}
@@ -892,7 +892,7 @@ static void cgroup_diput(struct dentry *dentry, struct inode *inode)
892892
if (S_ISDIR(inode->i_mode)) {
893893
struct cgroup *cgrp = dentry->d_fsdata;
894894

895-
BUG_ON(!(cgroup_is_removed(cgrp)));
895+
BUG_ON(!(cgroup_is_dead(cgrp)));
896896
call_rcu(&cgrp->rcu_head, cgroup_free_rcu);
897897
} else {
898898
struct cfent *cfe = __d_cfe(dentry);
@@ -2363,7 +2363,7 @@ static ssize_t cgroup_file_write(struct file *file, const char __user *buf,
23632363
struct cftype *cft = __d_cft(file->f_dentry);
23642364
struct cgroup *cgrp = __d_cgrp(file->f_dentry->d_parent);
23652365

2366-
if (cgroup_is_removed(cgrp))
2366+
if (cgroup_is_dead(cgrp))
23672367
return -ENODEV;
23682368
if (cft->write)
23692369
return cft->write(cgrp, cft, file, buf, nbytes, ppos);
@@ -2408,7 +2408,7 @@ static ssize_t cgroup_file_read(struct file *file, char __user *buf,
24082408
struct cftype *cft = __d_cft(file->f_dentry);
24092409
struct cgroup *cgrp = __d_cgrp(file->f_dentry->d_parent);
24102410

2411-
if (cgroup_is_removed(cgrp))
2411+
if (cgroup_is_dead(cgrp))
24122412
return -ENODEV;
24132413

24142414
if (cft->read)
@@ -2831,7 +2831,7 @@ static void cgroup_cfts_commit(struct cgroup_subsys *ss,
28312831

28322832
mutex_lock(&inode->i_mutex);
28332833
mutex_lock(&cgroup_mutex);
2834-
if (!cgroup_is_removed(cgrp))
2834+
if (!cgroup_is_dead(cgrp))
28352835
cgroup_addrm_files(cgrp, ss, cfts, is_add);
28362836
mutex_unlock(&cgroup_mutex);
28372837
mutex_unlock(&inode->i_mutex);
@@ -2999,14 +2999,14 @@ struct cgroup *cgroup_next_sibling(struct cgroup *pos)
29992999
/*
30003000
* @pos could already have been removed. Once a cgroup is removed,
30013001
* its ->sibling.next is no longer updated when its next sibling
3002-
* changes. As CGRP_REMOVED is set on removal which is fully
3002+
* changes. As CGRP_DEAD is set on removal which is fully
30033003
* serialized, if we see it unasserted, it's guaranteed that the
30043004
* next sibling hasn't finished its grace period even if it's
30053005
* already removed, and thus safe to dereference from this RCU
30063006
* critical section. If ->sibling.next is inaccessible,
3007-
* cgroup_is_removed() is guaranteed to be visible as %true here.
3007+
* cgroup_is_dead() is guaranteed to be visible as %true here.
30083008
*/
3009-
if (likely(!cgroup_is_removed(pos))) {
3009+
if (likely(!cgroup_is_dead(pos))) {
30103010
next = list_entry_rcu(pos->sibling.next, struct cgroup, sibling);
30113011
if (&next->sibling != &pos->parent->children)
30123012
return next;
@@ -4383,7 +4383,7 @@ static int cgroup_destroy_locked(struct cgroup *cgrp)
43834383
* attempts fail thus maintaining the removal conditions verified
43844384
* above.
43854385
*
4386-
* Note that CGRP_REMVOED clearing is depended upon by
4386+
* Note that CGRP_DEAD assertion is depended upon by
43874387
* cgroup_next_sibling() to resume iteration after dropping RCU
43884388
* read lock. See cgroup_next_sibling() for details.
43894389
*/
@@ -4393,7 +4393,7 @@ static int cgroup_destroy_locked(struct cgroup *cgrp)
43934393
WARN_ON(atomic_read(&css->refcnt) < 0);
43944394
atomic_add(CSS_DEACT_BIAS, &css->refcnt);
43954395
}
4396-
set_bit(CGRP_REMOVED, &cgrp->flags);
4396+
set_bit(CGRP_DEAD, &cgrp->flags);
43974397

43984398
/* tell subsystems to initate destruction */
43994399
for_each_subsys(cgrp->root, ss)
@@ -5063,7 +5063,7 @@ static void check_for_release(struct cgroup *cgrp)
50635063
int need_schedule_work = 0;
50645064

50655065
raw_spin_lock(&release_list_lock);
5066-
if (!cgroup_is_removed(cgrp) &&
5066+
if (!cgroup_is_dead(cgrp) &&
50675067
list_empty(&cgrp->release_list)) {
50685068
list_add(&cgrp->release_list, &release_list);
50695069
need_schedule_work = 1;
@@ -5209,9 +5209,7 @@ __setup("cgroup_disable=", cgroup_disable);
52095209
* Functons for CSS ID.
52105210
*/
52115211

5212-
/*
5213-
*To get ID other than 0, this should be called when !cgroup_is_removed().
5214-
*/
5212+
/* to get ID other than 0, this should be called when !cgroup_is_dead() */
52155213
unsigned short css_id(struct cgroup_subsys_state *css)
52165214
{
52175215
struct css_id *cssid;

0 commit comments

Comments
 (0)