Skip to content

Commit f4f809f

Browse files
rgushchinhtejun
authored andcommitted
cgroup: inline cgroup_task_freeze()
After the introduction of the cgroup.kill there is only one call site of cgroup_task_freeze() left: cgroup_exit(). cgroup_task_freeze() is currently taking rcu_read_lock() to read task's cgroup flags, but because it's always called with css_set_lock locked, the rcu protection is excessive. Simplify the code by inlining cgroup_task_freeze(). v2: fix build Signed-off-by: Roman Gushchin <[email protected]> Reviewed-by: Shakeel Butt <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 85e3b86 commit f4f809f

File tree

2 files changed

+2
-19
lines changed

2 files changed

+2
-19
lines changed

include/linux/cgroup.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -906,20 +906,6 @@ void cgroup_freeze(struct cgroup *cgrp, bool freeze);
906906
void cgroup_freezer_migrate_task(struct task_struct *task, struct cgroup *src,
907907
struct cgroup *dst);
908908

909-
static inline bool cgroup_task_freeze(struct task_struct *task)
910-
{
911-
bool ret;
912-
913-
if (task->flags & PF_KTHREAD)
914-
return false;
915-
916-
rcu_read_lock();
917-
ret = test_bit(CGRP_FREEZE, &task_dfl_cgroup(task)->flags);
918-
rcu_read_unlock();
919-
920-
return ret;
921-
}
922-
923909
static inline bool cgroup_task_frozen(struct task_struct *task)
924910
{
925911
return task->frozen;
@@ -929,10 +915,6 @@ static inline bool cgroup_task_frozen(struct task_struct *task)
929915

930916
static inline void cgroup_enter_frozen(void) { }
931917
static inline void cgroup_leave_frozen(bool always_leave) { }
932-
static inline bool cgroup_task_freeze(struct task_struct *task)
933-
{
934-
return false;
935-
}
936918
static inline bool cgroup_task_frozen(struct task_struct *task)
937919
{
938920
return false;

kernel/cgroup/cgroup.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6267,7 +6267,8 @@ void cgroup_exit(struct task_struct *tsk)
62676267
cset->nr_tasks--;
62686268

62696269
WARN_ON_ONCE(cgroup_task_frozen(tsk));
6270-
if (unlikely(cgroup_task_freeze(tsk)))
6270+
if (unlikely(!(tsk->flags & PF_KTHREAD) &&
6271+
test_bit(CGRP_FREEZE, &task_dfl_cgroup(tsk)->flags)))
62716272
cgroup_update_frozen(task_dfl_cgroup(tsk));
62726273

62736274
spin_unlock_irq(&css_set_lock);

0 commit comments

Comments
 (0)