Skip to content

Commit c444626

Browse files
KAGA-KOKOFrederic Weisbecker
authored andcommitted
posix-cpu-timers: Use @now instead of @Val for clarity
posix_cpu_timer_set() uses @Val as variable for the current time. That's confusing at best. Use @now as anywhere else and rewrite the confusing comment about clock sampling. No functional change. Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Frederic Weisbecker <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]>
1 parent bd29d77 commit c444626

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

kernel/time/posix-cpu-timers.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags,
622622
{
623623
bool sigev_none = timer->it_sigev_notify == SIGEV_NONE;
624624
clockid_t clkid = CPUCLOCK_WHICH(timer->it_clock);
625-
u64 old_expires, new_expires, old_incr, val;
625+
u64 old_expires, new_expires, old_incr, now;
626626
struct cpu_timer *ctmr = &timer->it.cpu;
627627
struct sighand_struct *sighand;
628628
struct task_struct *p;
@@ -674,23 +674,19 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags,
674674
}
675675

676676
/*
677-
* We need to sample the current value to convert the new
678-
* value from to relative and absolute, and to convert the
679-
* old value from absolute to relative. To set a process
680-
* timer, we need a sample to balance the thread expiry
681-
* times (in arm_timer). With an absolute time, we must
682-
* check if it's already passed. In short, we need a sample.
677+
* Sample the current clock for saving the previous setting
678+
* and for rearming the timer.
683679
*/
684680
if (CPUCLOCK_PERTHREAD(timer->it_clock))
685-
val = cpu_clock_sample(clkid, p);
681+
now = cpu_clock_sample(clkid, p);
686682
else
687-
val = cpu_clock_sample_group(clkid, p, !sigev_none);
683+
now = cpu_clock_sample_group(clkid, p, !sigev_none);
688684

689685
/* Retrieve the previous expiry value if requested. */
690686
if (old) {
691687
old->it_value = (struct timespec64){ };
692688
if (old_expires)
693-
__posix_cpu_timer_get(timer, old, val);
689+
__posix_cpu_timer_get(timer, old, now);
694690
}
695691

696692
if (unlikely(ret)) {
@@ -706,7 +702,7 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags,
706702

707703
/* Convert relative expiry time to absolute */
708704
if (new_expires && !(timer_flags & TIMER_ABSTIME))
709-
new_expires += val;
705+
new_expires += now;
710706

711707
/* Set the new expiry time (might be 0) */
712708
cpu_timer_setexpires(ctmr, new_expires);
@@ -716,7 +712,7 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags,
716712
* not yet expired and the timer requires signal delivery.
717713
* SIGEV_NONE timers are never armed.
718714
*/
719-
if (!sigev_none && new_expires && val < new_expires)
715+
if (!sigev_none && new_expires && now < new_expires)
720716
arm_timer(timer, p);
721717

722718
unlock_task_sighand(p, &flags);
@@ -736,7 +732,7 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags,
736732
timer->it_overrun_last = 0;
737733
timer->it_overrun = -1;
738734

739-
if (!sigev_none && val >= new_expires) {
735+
if (!sigev_none && now >= new_expires) {
740736
if (new_expires != 0) {
741737
/*
742738
* The designated time already passed, so we notify

0 commit comments

Comments
 (0)