Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

posix-cpu-timers: Remove unnecessary locking around cpu_clock_sample_group

As of e78c3496790e ("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

authored by

Eric W. Biederman and committed by
Thomas Gleixner
60f2ceaa a2efdbf4

+12 -54
+12 -54
kernel/time/posix-cpu-timers.c
··· 718 718 /* 719 719 * Sample the clock to take the difference with the expiry time. 720 720 */ 721 - if (CPUCLOCK_PERTHREAD(timer->it_clock)) { 721 + if (CPUCLOCK_PERTHREAD(timer->it_clock)) 722 722 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); 746 725 747 726 if (now < expires) { 748 727 itp->it_value = ns_to_timespec64(expires - now); ··· 965 986 /* 966 987 * Fetch the current sample and update the timer's expiry time. 967 988 */ 968 - if (CPUCLOCK_PERTHREAD(timer->it_clock)) { 989 + if (CPUCLOCK_PERTHREAD(timer->it_clock)) 969 990 now = cpu_clock_sample(clkid, p); 970 - bump_cpu_timer(timer, now); 971 - if (unlikely(p->exit_state)) 972 - return; 973 - 974 - /* Protect timer list r/w in arm_timer() */ 975 - sighand = lock_task_sighand(p, &flags); 976 - if (!sighand) 977 - return; 978 - } else { 979 - /* 980 - * Protect arm_timer() and timer sampling in case of call to 981 - * thread_group_cputime(). 982 - */ 983 - sighand = lock_task_sighand(p, &flags); 984 - if (unlikely(sighand == NULL)) { 985 - /* 986 - * The process has been reaped. 987 - * We can't even collect a sample any more. 988 - */ 989 - cpu_timer_setexpires(ctmr, 0); 990 - return; 991 - } else if (unlikely(p->exit_state) && thread_group_empty(p)) { 992 - /* If the process is dying, no need to rearm */ 993 - goto unlock; 994 - } 991 + else 995 992 now = cpu_clock_sample_group(clkid, p, true); 996 - bump_cpu_timer(timer, now); 997 - /* Leave the sighand locked for the call below. */ 998 - } 993 + 994 + bump_cpu_timer(timer, now); 995 + 996 + /* Protect timer list r/w in arm_timer() */ 997 + sighand = lock_task_sighand(p, &flags); 998 + if (unlikely(sighand == NULL)) 999 + return; 999 1000 1000 1001 /* 1001 1002 * Now re-arm for the new expiry time. 1002 1003 */ 1003 1004 arm_timer(timer); 1004 - unlock: 1005 1005 unlock_task_sighand(p, &flags); 1006 1006 } 1007 1007