Commit c4446266 authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Frederic Weisbecker

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: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarFrederic Weisbecker <frederic@kernel.org>
Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
parent bd29d773
...@@ -622,7 +622,7 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags, ...@@ -622,7 +622,7 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags,
{ {
bool sigev_none = timer->it_sigev_notify == SIGEV_NONE; bool sigev_none = timer->it_sigev_notify == SIGEV_NONE;
clockid_t clkid = CPUCLOCK_WHICH(timer->it_clock); clockid_t clkid = CPUCLOCK_WHICH(timer->it_clock);
u64 old_expires, new_expires, old_incr, val; u64 old_expires, new_expires, old_incr, now;
struct cpu_timer *ctmr = &timer->it.cpu; struct cpu_timer *ctmr = &timer->it.cpu;
struct sighand_struct *sighand; struct sighand_struct *sighand;
struct task_struct *p; struct task_struct *p;
...@@ -674,23 +674,19 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags, ...@@ -674,23 +674,19 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags,
} }
/* /*
* We need to sample the current value to convert the new * Sample the current clock for saving the previous setting
* value from to relative and absolute, and to convert the * and for rearming the timer.
* old value from absolute to relative. To set a process
* timer, we need a sample to balance the thread expiry
* times (in arm_timer). With an absolute time, we must
* check if it's already passed. In short, we need a sample.
*/ */
if (CPUCLOCK_PERTHREAD(timer->it_clock)) if (CPUCLOCK_PERTHREAD(timer->it_clock))
val = cpu_clock_sample(clkid, p); now = cpu_clock_sample(clkid, p);
else else
val = cpu_clock_sample_group(clkid, p, !sigev_none); now = cpu_clock_sample_group(clkid, p, !sigev_none);
/* Retrieve the previous expiry value if requested. */ /* Retrieve the previous expiry value if requested. */
if (old) { if (old) {
old->it_value = (struct timespec64){ }; old->it_value = (struct timespec64){ };
if (old_expires) if (old_expires)
__posix_cpu_timer_get(timer, old, val); __posix_cpu_timer_get(timer, old, now);
} }
if (unlikely(ret)) { if (unlikely(ret)) {
...@@ -706,7 +702,7 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags, ...@@ -706,7 +702,7 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags,
/* Convert relative expiry time to absolute */ /* Convert relative expiry time to absolute */
if (new_expires && !(timer_flags & TIMER_ABSTIME)) if (new_expires && !(timer_flags & TIMER_ABSTIME))
new_expires += val; new_expires += now;
/* Set the new expiry time (might be 0) */ /* Set the new expiry time (might be 0) */
cpu_timer_setexpires(ctmr, new_expires); cpu_timer_setexpires(ctmr, new_expires);
...@@ -716,7 +712,7 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags, ...@@ -716,7 +712,7 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags,
* not yet expired and the timer requires signal delivery. * not yet expired and the timer requires signal delivery.
* SIGEV_NONE timers are never armed. * SIGEV_NONE timers are never armed.
*/ */
if (!sigev_none && new_expires && val < new_expires) if (!sigev_none && new_expires && now < new_expires)
arm_timer(timer, p); arm_timer(timer, p);
unlock_task_sighand(p, &flags); unlock_task_sighand(p, &flags);
...@@ -736,7 +732,7 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags, ...@@ -736,7 +732,7 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags,
timer->it_overrun_last = 0; timer->it_overrun_last = 0;
timer->it_overrun = -1; timer->it_overrun = -1;
if (!sigev_none && val >= new_expires) { if (!sigev_none && now >= new_expires) {
if (new_expires != 0) { if (new_expires != 0) {
/* /*
* The designated time already passed, so we notify * The designated time already passed, so we notify
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment