History

posix-cpu-timers: Move state tracking to struct posix_cputimers

Put it where it belongs and clean up the ifdeffery in fork completely.

Thomas Gleixner committed 7 years ago

Commit 244d49e1 parent 8991afe6 files · +54 −50Browse files

Showing the changes to include/linux (3 of 6 files). Show all

Unified · Split

3 files
  1. include/linux/posix-timers.h +8 −0
  2. include/linux/sched/cputime.h +6 −3
  3. include/linux/sched/signal.h +0 −6
include/linux/posix-timers.h+8−0
@@ -77,15 +77,23 @@ struct posix_cputimer_base { · 76 unmodified lines
7777 /**
7878 * posix_cputimers - Container for posix CPU timer related data
7979 * @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
8084 *
8185 * Used in task_struct and signal_struct
8286 */
8387 struct posix_cputimers {
8488 struct posix_cputimer_base bases[CPUCLOCK_MAX];
89+ unsigned int timers_active;
90+ unsigned int expiry_active;
8591 };
8692
8793 static inline void posix_cputimers_init(struct posix_cputimers *pct)
8894 {
95+ pct->timers_active = 0;
96+ pct->expiry_active = 0;
8997 pct->bases[0].nextevt = U64_MAX;
9098 pct->bases[1].nextevt = U64_MAX;
9199 pct->bases[2].nextevt = U64_MAX;
include/linux/sched/cputime.h+6−3
@@ -70,7 +70,7 @@ void thread_group_sample_cputime(struct task_struct *tsk, u64 *samples); · 69 unmodified lines
7070 */
7171
7272 /**
73− * get_running_cputimer - return &tsk->signal->cputimer if cputimer is running
73+ * get_running_cputimer - return &tsk->signal->cputimer if cputimers are active
7474 *
7575 * @tsk: Pointer to target task.
7676 */
@@ -80,8 +80,11 @@ struct thread_group_cputimer *get_running_cputimer(struct task_struct *tsk) · 3 unmodified lines
8080 {
8181 struct thread_group_cputimer *cputimer = &tsk->signal->cputimer;
8282
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))
8588 return NULL;
8689
8790 /*
include/linux/sched/signal.h+0−6
@@ -57,18 +57,12 @@ struct task_cputime_atomic { · 56 unmodified lines
5757 /**
5858 * struct thread_group_cputimer - thread group interval timer counts
5959 * @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.
6460 *
6561 * This structure contains the version of task_cputime, above, that is
6662 * used for thread group CPU timer calculations.
6763 */
6864 struct thread_group_cputimer {
6965 struct task_cputime_atomic cputime_atomic;
70− bool running;
71− bool checking_timer;
7266 };
7367
7468 struct multiprocess_signals {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t