Put it where it belongs and clean up the ifdeffery in fork completely.
Showing the changes to include/linux (3 of 6 files). Show all
Unified · Split
| @@ -77,15 +77,23 @@ struct posix_cputimer_base { · 76 unmodified lines | ||
| 77 | 77 | /** |
| 78 | 78 | * posix_cputimers - Container for posix CPU timer related data |
| 79 | 79 | * @bases: Base container for posix CPU clocks |
| 80 | + * @timers_active: Timers are queued. | |
| 81 | + * @expiry_active: Timer expiry is active. Used for | |
| 82 | + * process wide timers to avoid multiple | |
| 83 | + * task trying to handle expiry concurrently | |
| 80 | 84 | * |
| 81 | 85 | * Used in task_struct and signal_struct |
| 82 | 86 | */ |
| 83 | 87 | struct posix_cputimers { |
| 84 | 88 | struct posix_cputimer_base bases[CPUCLOCK_MAX]; |
| 89 | + unsigned int timers_active; | |
| 90 | + unsigned int expiry_active; | |
| 85 | 91 | }; |
| 86 | 92 | |
| 87 | 93 | static inline void posix_cputimers_init(struct posix_cputimers *pct) |
| 88 | 94 | { |
| 95 | + pct->timers_active = 0; | |
| 96 | + pct->expiry_active = 0; | |
| 89 | 97 | pct->bases[0].nextevt = U64_MAX; |
| 90 | 98 | pct->bases[1].nextevt = U64_MAX; |
| 91 | 99 | pct->bases[2].nextevt = U64_MAX; |
| @@ -70,7 +70,7 @@ void thread_group_sample_cputime(struct task_struct *tsk, u64 *samples); · 69 unmodified lines | ||
| 70 | 70 | */ |
| 71 | 71 | |
| 72 | 72 | /** |
| 73 | − * get_running_cputimer - return &tsk->signal->cputimer if cputimer is running | |
| 73 | + * get_running_cputimer - return &tsk->signal->cputimer if cputimers are active | |
| 74 | 74 | * |
| 75 | 75 | * @tsk: Pointer to target task. |
| 76 | 76 | */ |
| @@ -80,8 +80,11 @@ struct thread_group_cputimer *get_running_cputimer(struct task_struct *tsk) · 3 unmodified lines | ||
| 80 | 80 | { |
| 81 | 81 | struct thread_group_cputimer *cputimer = &tsk->signal->cputimer; |
| 82 | 82 | |
| 83 | − /* Check if cputimer isn't running. This is accessed without locking. */ | |
| 84 | − if (!READ_ONCE(cputimer->running)) | |
| 83 | + /* | |
| 84 | + * Check whether posix CPU timers are active. If not the thread | |
| 85 | + * group accounting is not active either. Lockless check. | |
| 86 | + */ | |
| 87 | + if (!READ_ONCE(tsk->signal->posix_cputimers.timers_active)) | |
| 85 | 88 | return NULL; |
| 86 | 89 | |
| 87 | 90 | /* |
| @@ -57,18 +57,12 @@ struct task_cputime_atomic { · 56 unmodified lines | ||
| 57 | 57 | /** |
| 58 | 58 | * struct thread_group_cputimer - thread group interval timer counts |
| 59 | 59 | * @cputime_atomic: atomic thread group interval timers. |
| 60 | − * @running: true when there are timers running and | |
| 61 | − * @cputime_atomic receives updates. | |
| 62 | − * @checking_timer: true when a thread in the group is in the | |
| 63 | − * process of checking for thread group timers. | |
| 64 | 60 | * |
| 65 | 61 | * This structure contains the version of task_cputime, above, that is |
| 66 | 62 | * used for thread group CPU timer calculations. |
| 67 | 63 | */ |
| 68 | 64 | struct thread_group_cputimer { |
| 69 | 65 | struct task_cputime_atomic cputime_atomic; |
| 70 | − bool running; | |
| 71 | − bool checking_timer; | |
| 72 | 66 | }; |
| 73 | 67 | |
| 74 | 68 | struct multiprocess_signals { |