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

Configure Feed

Select the types of activity you want to include in your feed.

sched/headers, cgroups: Remove the threadgroup_change_*() wrappery

threadgroup_change_begin()/end() is a pointless wrapper around
cgroup_threadgroup_change_begin()/end(), minus a might_sleep()
in the !CONFIG_CGROUPS=y case.

Remove the wrappery, move the might_sleep() (the down_read()
already has a might_sleep() check).

This debloats <linux/sched.h> a bit and simplifies this API.

Update all call sites.

No change in functionality.

Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>

+18 -43
+3 -3
fs/exec.c
··· 1088 1088 struct task_struct *leader = tsk->group_leader; 1089 1089 1090 1090 for (;;) { 1091 - threadgroup_change_begin(tsk); 1091 + cgroup_threadgroup_change_begin(tsk); 1092 1092 write_lock_irq(&tasklist_lock); 1093 1093 /* 1094 1094 * Do this under tasklist_lock to ensure that ··· 1099 1099 break; 1100 1100 __set_current_state(TASK_KILLABLE); 1101 1101 write_unlock_irq(&tasklist_lock); 1102 - threadgroup_change_end(tsk); 1102 + cgroup_threadgroup_change_end(tsk); 1103 1103 schedule(); 1104 1104 if (unlikely(__fatal_signal_pending(tsk))) 1105 1105 goto killed; ··· 1157 1157 if (unlikely(leader->ptrace)) 1158 1158 __wake_up_parent(leader, leader->parent); 1159 1159 write_unlock_irq(&tasklist_lock); 1160 - threadgroup_change_end(tsk); 1160 + cgroup_threadgroup_change_end(tsk); 1161 1161 1162 1162 release_task(leader); 1163 1163 }
+8 -5
include/linux/cgroup-defs.h
··· 531 531 * cgroup_threadgroup_change_begin - threadgroup exclusion for cgroups 532 532 * @tsk: target task 533 533 * 534 - * Called from threadgroup_change_begin() and allows cgroup operations to 535 - * synchronize against threadgroup changes using a percpu_rw_semaphore. 534 + * Allows cgroup operations to synchronize against threadgroup changes 535 + * using a percpu_rw_semaphore. 536 536 */ 537 537 static inline void cgroup_threadgroup_change_begin(struct task_struct *tsk) 538 538 { ··· 543 543 * cgroup_threadgroup_change_end - threadgroup exclusion for cgroups 544 544 * @tsk: target task 545 545 * 546 - * Called from threadgroup_change_end(). Counterpart of 547 - * cgroup_threadcgroup_change_begin(). 546 + * Counterpart of cgroup_threadcgroup_change_begin(). 548 547 */ 549 548 static inline void cgroup_threadgroup_change_end(struct task_struct *tsk) 550 549 { ··· 554 555 555 556 #define CGROUP_SUBSYS_COUNT 0 556 557 557 - static inline void cgroup_threadgroup_change_begin(struct task_struct *tsk) {} 558 + static inline void cgroup_threadgroup_change_begin(struct task_struct *tsk) 559 + { 560 + might_sleep(); 561 + } 562 + 558 563 static inline void cgroup_threadgroup_change_end(struct task_struct *tsk) {} 559 564 560 565 #endif /* CONFIG_CGROUPS */
-28
include/linux/sched.h
··· 3162 3162 spin_unlock_irqrestore(&tsk->sighand->siglock, *flags); 3163 3163 } 3164 3164 3165 - /** 3166 - * threadgroup_change_begin - mark the beginning of changes to a threadgroup 3167 - * @tsk: task causing the changes 3168 - * 3169 - * All operations which modify a threadgroup - a new thread joining the 3170 - * group, death of a member thread (the assertion of PF_EXITING) and 3171 - * exec(2) dethreading the process and replacing the leader - are wrapped 3172 - * by threadgroup_change_{begin|end}(). This is to provide a place which 3173 - * subsystems needing threadgroup stability can hook into for 3174 - * synchronization. 3175 - */ 3176 - static inline void threadgroup_change_begin(struct task_struct *tsk) 3177 - { 3178 - might_sleep(); 3179 - cgroup_threadgroup_change_begin(tsk); 3180 - } 3181 - 3182 - /** 3183 - * threadgroup_change_end - mark the end of changes to a threadgroup 3184 - * @tsk: task causing the changes 3185 - * 3186 - * See threadgroup_change_begin(). 3187 - */ 3188 - static inline void threadgroup_change_end(struct task_struct *tsk) 3189 - { 3190 - cgroup_threadgroup_change_end(tsk); 3191 - } 3192 - 3193 3165 #ifdef CONFIG_THREAD_INFO_IN_TASK 3194 3166 3195 3167 static inline struct thread_info *task_thread_info(struct task_struct *task)
+1 -1
kernel/cgroup/pids.c
··· 214 214 215 215 /* 216 216 * task_css_check(true) in pids_can_fork() and pids_cancel_fork() relies 217 - * on threadgroup_change_begin() held by the copy_process(). 217 + * on cgroup_threadgroup_change_begin() held by the copy_process(). 218 218 */ 219 219 static int pids_can_fork(struct task_struct *task) 220 220 {
+3 -3
kernel/fork.c
··· 1746 1746 INIT_LIST_HEAD(&p->thread_group); 1747 1747 p->task_works = NULL; 1748 1748 1749 - threadgroup_change_begin(current); 1749 + cgroup_threadgroup_change_begin(current); 1750 1750 /* 1751 1751 * Ensure that the cgroup subsystem policies allow the new process to be 1752 1752 * forked. It should be noted the the new process's css_set can be changed ··· 1843 1843 1844 1844 proc_fork_connector(p); 1845 1845 cgroup_post_fork(p); 1846 - threadgroup_change_end(current); 1846 + cgroup_threadgroup_change_end(current); 1847 1847 perf_event_fork(p); 1848 1848 1849 1849 trace_task_newtask(p, clone_flags); ··· 1854 1854 bad_fork_cancel_cgroup: 1855 1855 cgroup_cancel_fork(p); 1856 1856 bad_fork_free_pid: 1857 - threadgroup_change_end(current); 1857 + cgroup_threadgroup_change_end(current); 1858 1858 if (pid != &init_struct_pid) 1859 1859 free_pid(pid); 1860 1860 bad_fork_cleanup_thread:
+3 -3
kernel/signal.c
··· 2395 2395 * @tsk is about to have PF_EXITING set - lock out users which 2396 2396 * expect stable threadgroup. 2397 2397 */ 2398 - threadgroup_change_begin(tsk); 2398 + cgroup_threadgroup_change_begin(tsk); 2399 2399 2400 2400 if (thread_group_empty(tsk) || signal_group_exit(tsk->signal)) { 2401 2401 tsk->flags |= PF_EXITING; 2402 - threadgroup_change_end(tsk); 2402 + cgroup_threadgroup_change_end(tsk); 2403 2403 return; 2404 2404 } 2405 2405 ··· 2410 2410 */ 2411 2411 tsk->flags |= PF_EXITING; 2412 2412 2413 - threadgroup_change_end(tsk); 2413 + cgroup_threadgroup_change_end(tsk); 2414 2414 2415 2415 if (!signal_pending(tsk)) 2416 2416 goto out;