forked from Minki/linux
posix-cpu-timers: Consolidate timer base accessor
Remove the ad-hoc timer base accessors and provide a consolidated one. Signed-off-by: Frederic Weisbecker <frederic@kernel.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/r/20210726125513.271824-6-frederic@kernel.org
This commit is contained in:
parent
d9c1b2a108
commit
5c8f23e6b7
@ -407,6 +407,17 @@ static int posix_cpu_timer_create(struct k_itimer *new_timer)
|
||||
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.
|
||||
* 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)
|
||||
{
|
||||
struct cpu_timer *ctmr = &timer->it.cpu;
|
||||
struct posix_cputimer_base *base;
|
||||
int clkidx;
|
||||
|
||||
if (!cpu_timer_dequeue(ctmr))
|
||||
return;
|
||||
|
||||
clkidx = CPUCLOCK_WHICH(timer->it_clock);
|
||||
|
||||
if (CPUCLOCK_PERTHREAD(timer->it_clock))
|
||||
base = p->posix_cputimers.bases + clkidx;
|
||||
else
|
||||
base = p->signal->posix_cputimers.bases + clkidx;
|
||||
|
||||
base = timer_base(timer, p);
|
||||
if (cpu_timer_getexpires(ctmr) == base->nextevt)
|
||||
base->nextevt = 0;
|
||||
}
|
||||
@ -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)
|
||||
{
|
||||
int clkidx = CPUCLOCK_WHICH(timer->it_clock);
|
||||
struct posix_cputimer_base *base = timer_base(timer, p);
|
||||
struct cpu_timer *ctmr = &timer->it.cpu;
|
||||
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))
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user