Skip to content

Commit 16dad78

Browse files
committed
cgroup: Rename cgroup lifecycle hooks to cgroup_task_*()
The current names cgroup_exit(), cgroup_release(), and cgroup_free() are confusing because they look like they're operating on cgroups themselves when they're actually task lifecycle hooks. For example, cgroup_init() initializes the cgroup subsystem while cgroup_exit() is a task exit notification to cgroup. Rename them to cgroup_task_exit(), cgroup_task_release(), and cgroup_task_free() to make it clear that these operate on tasks. Cc: Dan Schatzberg <dschatzberg@meta.com> Cc: Peter Zijlstra <peterz@infradead.org> Reviewed-by: Chen Ridong <chenridong@huawei.com> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent d5cf4d3 commit 16dad78

5 files changed

Lines changed: 17 additions & 16 deletions

File tree

include/linux/cgroup.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ extern void cgroup_cancel_fork(struct task_struct *p,
137137
struct kernel_clone_args *kargs);
138138
extern void cgroup_post_fork(struct task_struct *p,
139139
struct kernel_clone_args *kargs);
140-
void cgroup_exit(struct task_struct *p);
141-
void cgroup_release(struct task_struct *p);
142-
void cgroup_free(struct task_struct *p);
140+
void cgroup_task_exit(struct task_struct *p);
141+
void cgroup_task_release(struct task_struct *p);
142+
void cgroup_task_free(struct task_struct *p);
143143

144144
int cgroup_init_early(void);
145145
int cgroup_init(void);
@@ -680,9 +680,9 @@ static inline void cgroup_cancel_fork(struct task_struct *p,
680680
struct kernel_clone_args *kargs) {}
681681
static inline void cgroup_post_fork(struct task_struct *p,
682682
struct kernel_clone_args *kargs) {}
683-
static inline void cgroup_exit(struct task_struct *p) {}
684-
static inline void cgroup_release(struct task_struct *p) {}
685-
static inline void cgroup_free(struct task_struct *p) {}
683+
static inline void cgroup_task_exit(struct task_struct *p) {}
684+
static inline void cgroup_task_release(struct task_struct *p) {}
685+
static inline void cgroup_task_free(struct task_struct *p) {}
686686

687687
static inline int cgroup_init_early(void) { return 0; }
688688
static inline int cgroup_init(void) { return 0; }

kernel/cgroup/cgroup.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,8 @@ static void css_set_move_task(struct task_struct *task,
944944
/*
945945
* We are synchronized through cgroup_threadgroup_rwsem
946946
* against PF_EXITING setting such that we can't race
947-
* against cgroup_exit()/cgroup_free() dropping the css_set.
947+
* against cgroup_task_exit()/cgroup_task_free() dropping
948+
* the css_set.
948949
*/
949950
WARN_ON_ONCE(task->flags & PF_EXITING);
950951

@@ -6972,13 +6973,13 @@ void cgroup_post_fork(struct task_struct *child,
69726973
}
69736974

69746975
/**
6975-
* cgroup_exit - detach cgroup from exiting task
6976+
* cgroup_task_exit - detach cgroup from exiting task
69766977
* @tsk: pointer to task_struct of exiting process
69776978
*
69786979
* Description: Detach cgroup from @tsk.
69796980
*
69806981
*/
6981-
void cgroup_exit(struct task_struct *tsk)
6982+
void cgroup_task_exit(struct task_struct *tsk)
69826983
{
69836984
struct cgroup_subsys *ss;
69846985
struct css_set *cset;
@@ -7010,7 +7011,7 @@ void cgroup_exit(struct task_struct *tsk)
70107011
} while_each_subsys_mask();
70117012
}
70127013

7013-
void cgroup_release(struct task_struct *task)
7014+
void cgroup_task_release(struct task_struct *task)
70147015
{
70157016
struct cgroup_subsys *ss;
70167017
int ssid;
@@ -7027,7 +7028,7 @@ void cgroup_release(struct task_struct *task)
70277028
}
70287029
}
70297030

7030-
void cgroup_free(struct task_struct *task)
7031+
void cgroup_task_free(struct task_struct *task)
70317032
{
70327033
struct css_set *cset = task_css_set(task);
70337034
put_css_set(cset);

kernel/exit.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ void release_task(struct task_struct *p)
257257
rcu_read_unlock();
258258

259259
pidfs_exit(p);
260-
cgroup_release(p);
260+
cgroup_task_release(p);
261261

262262
/* Retrieve @thread_pid before __unhash_process() may set it to NULL. */
263263
thread_pid = task_pid(p);
@@ -967,7 +967,7 @@ void __noreturn do_exit(long code)
967967
exit_thread(tsk);
968968

969969
sched_autogroup_exit_task(tsk);
970-
cgroup_exit(tsk);
970+
cgroup_task_exit(tsk);
971971

972972
/*
973973
* FIXME: do that only when needed, using sched_exit tracepoint

kernel/fork.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ void __put_task_struct(struct task_struct *tsk)
738738
unwind_task_free(tsk);
739739
sched_ext_free(tsk);
740740
io_uring_free(tsk);
741-
cgroup_free(tsk);
741+
cgroup_task_free(tsk);
742742
task_numa_free(tsk, true);
743743
security_task_free(tsk);
744744
exit_creds(tsk);

kernel/sched/autogroup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ autogroup_move_group(struct task_struct *p, struct autogroup *ag)
178178
* this process can already run with task_group() == prev->tg or we can
179179
* race with cgroup code which can read autogroup = prev under rq->lock.
180180
* In the latter case for_each_thread() can not miss a migrating thread,
181-
* cpu_cgroup_attach() must not be possible after cgroup_exit() and it
182-
* can't be removed from thread list, we hold ->siglock.
181+
* cpu_cgroup_attach() must not be possible after cgroup_task_exit()
182+
* and it can't be removed from thread list, we hold ->siglock.
183183
*
184184
* If an exiting thread was already removed from thread list we rely on
185185
* sched_autogroup_exit_task().

0 commit comments

Comments
 (0)