Skip to content

Commit a2ed4fd

Browse files
committed
posix-cpu-timers: Make expiry_active check actually work correctly
The state tracking changes broke the expiry active check by not writing to it and instead sitting timers_active, which is already set. That's not a big issue as the actual expiry is protected by sighand lock, so concurrent handling is not possible. That means that the second task which invokes that function executes the expiry code for nothing. Write to the proper flag. Also add a check whether the flag is set into check_process_timers(). That check had been missing in the code before the rework already. The check for another task handling the expiry of process wide timers was only done in the fastpath check. If the fastpath check returns true because a per task timer expired, then the checking of process wide timers was done in parallel which is as explained above just a waste of cycles. Fixes: 244d49e ("posix-cpu-timers: Move state tracking to struct posix_cputimers") Signed-off-by: Thomas Gleixner <[email protected]> Cc: Frederic Weisbecker <[email protected]>
1 parent 8f2edb4 commit a2ed4fd

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

kernel/time/posix-cpu-timers.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -884,16 +884,17 @@ static void check_process_timers(struct task_struct *tsk,
884884

885885
/*
886886
* If there are no active process wide timers (POSIX 1.b, itimers,
887-
* RLIMIT_CPU) nothing to check.
887+
* RLIMIT_CPU) nothing to check. Also skip the process wide timer
888+
* processing when there is already another task handling them.
888889
*/
889-
if (!READ_ONCE(pct->timers_active))
890+
if (!READ_ONCE(pct->timers_active) || pct->expiry_active)
890891
return;
891892

892-
/*
893+
/*
893894
* Signify that a thread is checking for process timers.
894895
* Write access to this field is protected by the sighand lock.
895896
*/
896-
pct->timers_active = true;
897+
pct->expiry_active = true;
897898

898899
/*
899900
* Collect the current process totals. Group accounting is active

0 commit comments

Comments
 (0)