Commit 5c8f23e6 authored by Frederic Weisbecker's avatar Frederic Weisbecker Committed by Thomas Gleixner

posix-cpu-timers: Consolidate timer base accessor

Remove the ad-hoc timer base accessors and provide a consolidated one.
Signed-off-by: default avatarFrederic Weisbecker <frederic@kernel.org>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20210726125513.271824-6-frederic@kernel.org
parent d9c1b2a1
...@@ -407,6 +407,17 @@ static int posix_cpu_timer_create(struct k_itimer *new_timer) ...@@ -407,6 +407,17 @@ static int posix_cpu_timer_create(struct k_itimer *new_timer)
return 0; return 0;
} }
static struct posix_cputimer_base *timer_base(struct k_itimer *timer,
struct task_struct *tsk)
{
int clkidx = CPUCLOCK_WHICH(timer->it_clock);
if (CPUCLOCK_PERTHREAD(timer->it_clock))
return tsk->posix_cputimers.bases + clkidx;
else
return tsk->signal->posix_cputimers.bases + clkidx;
}
/* /*
* Dequeue the timer and reset the base if it was its earliest expiration. * Dequeue the timer and reset the base if it was its earliest expiration.
* It makes sure the next tick recalculates the base next expiration so we * It makes sure the next tick recalculates the base next expiration so we
...@@ -421,18 +432,11 @@ static void disarm_timer(struct k_itimer *timer, struct task_struct *p) ...@@ -421,18 +432,11 @@ static void disarm_timer(struct k_itimer *timer, struct task_struct *p)
{ {
struct cpu_timer *ctmr = &timer->it.cpu; struct cpu_timer *ctmr = &timer->it.cpu;
struct posix_cputimer_base *base; struct posix_cputimer_base *base;
int clkidx;
if (!cpu_timer_dequeue(ctmr)) if (!cpu_timer_dequeue(ctmr))
return; return;
clkidx = CPUCLOCK_WHICH(timer->it_clock); base = timer_base(timer, p);
if (CPUCLOCK_PERTHREAD(timer->it_clock))
base = p->posix_cputimers.bases + clkidx;
else
base = p->signal->posix_cputimers.bases + clkidx;
if (cpu_timer_getexpires(ctmr) == base->nextevt) if (cpu_timer_getexpires(ctmr) == base->nextevt)
base->nextevt = 0; base->nextevt = 0;
} }
...@@ -531,15 +535,9 @@ void posix_cpu_timers_exit_group(struct task_struct *tsk) ...@@ -531,15 +535,9 @@ void posix_cpu_timers_exit_group(struct task_struct *tsk)
*/ */
static void arm_timer(struct k_itimer *timer, struct task_struct *p) static void arm_timer(struct k_itimer *timer, struct task_struct *p)
{ {
int clkidx = CPUCLOCK_WHICH(timer->it_clock); struct posix_cputimer_base *base = timer_base(timer, p);
struct cpu_timer *ctmr = &timer->it.cpu; struct cpu_timer *ctmr = &timer->it.cpu;
u64 newexp = cpu_timer_getexpires(ctmr); u64 newexp = cpu_timer_getexpires(ctmr);
struct posix_cputimer_base *base;
if (CPUCLOCK_PERTHREAD(timer->it_clock))
base = p->posix_cputimers.bases + clkidx;
else
base = p->signal->posix_cputimers.bases + clkidx;
if (!cpu_timer_enqueue(&base->tqhead, ctmr)) if (!cpu_timer_enqueue(&base->tqhead, ctmr))
return; return;
......
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