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
77/**77/**
78 * posix_cputimers - Container for posix CPU timer related data78 * posix_cputimers - Container for posix CPU timer related data
79 * @bases: Base container for posix CPU clocks79 * @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 * Used in task_struct and signal_struct85 * Used in task_struct and signal_struct
82 */86 */
83struct posix_cputimers {87struct posix_cputimers {
84 struct posix_cputimer_base bases[CPUCLOCK_MAX];88 struct posix_cputimer_base bases[CPUCLOCK_MAX];
89 unsigned int timers_active;
90 unsigned int expiry_active;
85};91};
86 92
87static inline void posix_cputimers_init(struct posix_cputimers *pct)93static inline void posix_cputimers_init(struct posix_cputimers *pct)
88{94{
95 pct->timers_active = 0;
96 pct->expiry_active = 0;
89 pct->bases[0].nextevt = U64_MAX;97 pct->bases[0].nextevt = U64_MAX;
90 pct->bases[1].nextevt = U64_MAX;98 pct->bases[1].nextevt = U64_MAX;
91 pct->bases[2].nextevt = U64_MAX;99 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
70 */70 */
71 71
72/**72/**
73 * get_running_cputimer - return &tsk->signal->cputimer if cputimer is running73 * get_running_cputimer - return &tsk->signal->cputimer if cputimers are active
74 *74 *
75 * @tsk: Pointer to target task.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 struct thread_group_cputimer *cputimer = &tsk->signal->cputimer;81 struct thread_group_cputimer *cputimer = &tsk->signal->cputimer;
82 82
83 /* Check if cputimer isn't running. This is accessed without locking. */83 /*
84 if (!READ_ONCE(cputimer->running))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 return NULL;88 return NULL;
86 89
87 /*90 /*
include/linux/sched/signal.h+0−6
@@ -57,18 +57,12 @@ struct task_cputime_atomic { · 56 unmodified lines
57/**57/**
58 * struct thread_group_cputimer - thread group interval timer counts58 * struct thread_group_cputimer - thread group interval timer counts
59 * @cputime_atomic: atomic thread group interval timers.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 * This structure contains the version of task_cputime, above, that is61 * This structure contains the version of task_cputime, above, that is
66 * used for thread group CPU timer calculations.62 * used for thread group CPU timer calculations.
67 */63 */
68struct thread_group_cputimer {64struct thread_group_cputimer {
69 struct task_cputime_atomic cputime_atomic;65 struct task_cputime_atomic cputime_atomic;
70 bool running;
71 bool checking_timer;
72};66};
73 67
74struct multiprocess_signals {68struct 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