@@ -407,6 +407,17 @@ static int posix_cpu_timer_create(struct k_itimer *new_timer)
407
407
return 0 ;
408
408
}
409
409
410
+ static struct posix_cputimer_base * timer_base (struct k_itimer * timer ,
411
+ struct task_struct * tsk )
412
+ {
413
+ int clkidx = CPUCLOCK_WHICH (timer -> it_clock );
414
+
415
+ if (CPUCLOCK_PERTHREAD (timer -> it_clock ))
416
+ return tsk -> posix_cputimers .bases + clkidx ;
417
+ else
418
+ return tsk -> signal -> posix_cputimers .bases + clkidx ;
419
+ }
420
+
410
421
/*
411
422
* Dequeue the timer and reset the base if it was its earliest expiration.
412
423
* 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
432
{
422
433
struct cpu_timer * ctmr = & timer -> it .cpu ;
423
434
struct posix_cputimer_base * base ;
424
- int clkidx ;
425
435
426
436
if (!cpu_timer_dequeue (ctmr ))
427
437
return ;
428
438
429
- clkidx = CPUCLOCK_WHICH (timer -> it_clock );
430
-
431
- if (CPUCLOCK_PERTHREAD (timer -> it_clock ))
432
- base = p -> posix_cputimers .bases + clkidx ;
433
- else
434
- base = p -> signal -> posix_cputimers .bases + clkidx ;
435
-
439
+ base = timer_base (timer , p );
436
440
if (cpu_timer_getexpires (ctmr ) == base -> nextevt )
437
441
base -> nextevt = 0 ;
438
442
}
@@ -531,15 +535,9 @@ void posix_cpu_timers_exit_group(struct task_struct *tsk)
531
535
*/
532
536
static void arm_timer (struct k_itimer * timer , struct task_struct * p )
533
537
{
534
- int clkidx = CPUCLOCK_WHICH (timer -> it_clock );
538
+ struct posix_cputimer_base * base = timer_base (timer , p );
535
539
struct cpu_timer * ctmr = & timer -> it .cpu ;
536
540
u64 newexp = cpu_timer_getexpires (ctmr );
537
- struct posix_cputimer_base * base ;
538
-
539
- if (CPUCLOCK_PERTHREAD (timer -> it_clock ))
540
- base = p -> posix_cputimers .bases + clkidx ;
541
- else
542
- base = p -> signal -> posix_cputimers .bases + clkidx ;
543
541
544
542
if (!cpu_timer_enqueue (& base -> tqhead , ctmr ))
545
543
return ;
0 commit comments