Skip to content

Commit 60f2cea

Browse files
ebiedermKAGA-KOKO
authored andcommitted
posix-cpu-timers: Remove unnecessary locking around cpu_clock_sample_group
As of e78c349 ("time, signal: Protect resource use statistics with seqlock") cpu_clock_sample_group no longers needs siglock protection. Unfortunately no one realized it at the time. Remove the extra locking that is for cpu_clock_sample_group and not for cpu_clock_sample. This significantly simplifies the code. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lkml.kernel.org/r/878skmvdts.fsf@x220.int.ebiederm.org
1 parent a2efdbf commit 60f2cea

1 file changed

Lines changed: 12 additions & 54 deletions

File tree

‎kernel/time/posix-cpu-timers.c‎

Lines changed: 12 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -718,31 +718,10 @@ static void posix_cpu_timer_get(struct k_itimer *timer, struct itimerspec64 *itp
718718
/*
719719
* Sample the clock to take the difference with the expiry time.
720720
*/
721-
if (CPUCLOCK_PERTHREAD(timer->it_clock)) {
721+
if (CPUCLOCK_PERTHREAD(timer->it_clock))
722722
now = cpu_clock_sample(clkid, p);
723-
} else {
724-
struct sighand_struct *sighand;
725-
unsigned long flags;
726-
727-
/*
728-
* Protect against sighand release/switch in exit/exec and
729-
* also make timer sampling safe if it ends up calling
730-
* thread_group_cputime().
731-
*/
732-
sighand = lock_task_sighand(p, &flags);
733-
if (unlikely(sighand == NULL)) {
734-
/*
735-
* The process has been reaped.
736-
* We can't even collect a sample any more.
737-
* Disarm the timer, nothing else to do.
738-
*/
739-
cpu_timer_setexpires(ctmr, 0);
740-
return;
741-
} else {
742-
now = cpu_clock_sample_group(clkid, p, false);
743-
unlock_task_sighand(p, &flags);
744-
}
745-
}
723+
else
724+
now = cpu_clock_sample_group(clkid, p, false);
746725

747726
if (now < expires) {
748727
itp->it_value = ns_to_timespec64(expires - now);
@@ -986,43 +965,22 @@ static void posix_cpu_timer_rearm(struct k_itimer *timer)
986965
/*
987966
* Fetch the current sample and update the timer's expiry time.
988967
*/
989-
if (CPUCLOCK_PERTHREAD(timer->it_clock)) {
968+
if (CPUCLOCK_PERTHREAD(timer->it_clock))
990969
now = cpu_clock_sample(clkid, p);
991-
bump_cpu_timer(timer, now);
992-
if (unlikely(p->exit_state))
993-
return;
994-
995-
/* Protect timer list r/w in arm_timer() */
996-
sighand = lock_task_sighand(p, &flags);
997-
if (!sighand)
998-
return;
999-
} else {
1000-
/*
1001-
* Protect arm_timer() and timer sampling in case of call to
1002-
* thread_group_cputime().
1003-
*/
1004-
sighand = lock_task_sighand(p, &flags);
1005-
if (unlikely(sighand == NULL)) {
1006-
/*
1007-
* The process has been reaped.
1008-
* We can't even collect a sample any more.
1009-
*/
1010-
cpu_timer_setexpires(ctmr, 0);
1011-
return;
1012-
} else if (unlikely(p->exit_state) && thread_group_empty(p)) {
1013-
/* If the process is dying, no need to rearm */
1014-
goto unlock;
1015-
}
970+
else
1016971
now = cpu_clock_sample_group(clkid, p, true);
1017-
bump_cpu_timer(timer, now);
1018-
/* Leave the sighand locked for the call below. */
1019-
}
972+
973+
bump_cpu_timer(timer, now);
974+
975+
/* Protect timer list r/w in arm_timer() */
976+
sighand = lock_task_sighand(p, &flags);
977+
if (unlikely(sighand == NULL))
978+
return;
1020979

1021980
/*
1022981
* Now re-arm for the new expiry time.
1023982
*/
1024983
arm_timer(timer);
1025-
unlock:
1026984
unlock_task_sighand(p, &flags);
1027985
}
1028986

0 commit comments

Comments
 (0)