Lines Matching refs:timer

22 static void posix_cpu_timer_rearm(struct k_itimer *timer);
113 static inline struct task_struct *cpu_timer_task_rcu(struct k_itimer *timer) in cpu_timer_task_rcu() argument
115 return pid_task(timer->it.cpu.pid, clock_pid_type(timer->it_clock)); in cpu_timer_task_rcu()
122 static u64 bump_cpu_timer(struct k_itimer *timer, u64 now) in bump_cpu_timer() argument
124 u64 delta, incr, expires = timer->it.cpu.node.expires; in bump_cpu_timer()
127 if (!timer->it_interval) in bump_cpu_timer()
133 incr = timer->it_interval; in bump_cpu_timer()
144 timer->it.cpu.node.expires += incr; in bump_cpu_timer()
145 timer->it_overrun += 1LL << i; in bump_cpu_timer()
148 return timer->it.cpu.node.expires; in bump_cpu_timer()
416 static struct posix_cputimer_base *timer_base(struct k_itimer *timer, in timer_base() argument
419 int clkidx = CPUCLOCK_WHICH(timer->it_clock); in timer_base()
421 if (CPUCLOCK_PERTHREAD(timer->it_clock)) in timer_base()
433 static void trigger_base_recalc_expires(struct k_itimer *timer, in trigger_base_recalc_expires() argument
436 struct posix_cputimer_base *base = timer_base(timer, tsk); in trigger_base_recalc_expires()
451 static void disarm_timer(struct k_itimer *timer, struct task_struct *p) in disarm_timer() argument
453 struct cpu_timer *ctmr = &timer->it.cpu; in disarm_timer()
459 base = timer_base(timer, p); in disarm_timer()
461 trigger_base_recalc_expires(timer, p); in disarm_timer()
471 static int posix_cpu_timer_del(struct k_itimer *timer) in posix_cpu_timer_del() argument
473 struct cpu_timer *ctmr = &timer->it.cpu; in posix_cpu_timer_del()
480 p = cpu_timer_task_rcu(timer); in posix_cpu_timer_del()
496 if (timer->it.cpu.firing) in posix_cpu_timer_del()
499 disarm_timer(timer, p); in posix_cpu_timer_del()
556 static void arm_timer(struct k_itimer *timer, struct task_struct *p) in arm_timer() argument
558 struct posix_cputimer_base *base = timer_base(timer, p); in arm_timer()
559 struct cpu_timer *ctmr = &timer->it.cpu; in arm_timer()
574 if (CPUCLOCK_PERTHREAD(timer->it_clock)) in arm_timer()
583 static void cpu_timer_fire(struct k_itimer *timer) in cpu_timer_fire() argument
585 struct cpu_timer *ctmr = &timer->it.cpu; in cpu_timer_fire()
587 if ((timer->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE) { in cpu_timer_fire()
592 } else if (unlikely(timer->sigq == NULL)) { in cpu_timer_fire()
597 wake_up_process(timer->it_process); in cpu_timer_fire()
599 } else if (!timer->it_interval) { in cpu_timer_fire()
603 posix_timer_event(timer, 0); in cpu_timer_fire()
605 } else if (posix_timer_event(timer, ++timer->it_requeue_pending)) { in cpu_timer_fire()
612 posix_cpu_timer_rearm(timer); in cpu_timer_fire()
613 ++timer->it_requeue_pending; in cpu_timer_fire()
623 static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags, in posix_cpu_timer_set() argument
626 clockid_t clkid = CPUCLOCK_WHICH(timer->it_clock); in posix_cpu_timer_set()
628 struct cpu_timer *ctmr = &timer->it.cpu; in posix_cpu_timer_set()
635 p = cpu_timer_task_rcu(timer); in posix_cpu_timer_set()
668 old_incr = timer->it_interval; in posix_cpu_timer_set()
671 if (unlikely(timer->it.cpu.firing)) { in posix_cpu_timer_set()
672 timer->it.cpu.firing = -1; in posix_cpu_timer_set()
686 if (CPUCLOCK_PERTHREAD(timer->it_clock)) in posix_cpu_timer_set()
703 u64 exp = bump_cpu_timer(timer, val); in posix_cpu_timer_set()
737 arm_timer(timer, p); in posix_cpu_timer_set()
745 timer->it_interval = timespec64_to_ktime(new->it_interval); in posix_cpu_timer_set()
752 timer->it_requeue_pending = (timer->it_requeue_pending + 2) & in posix_cpu_timer_set()
754 timer->it_overrun_last = 0; in posix_cpu_timer_set()
755 timer->it_overrun = -1; in posix_cpu_timer_set()
764 cpu_timer_fire(timer); in posix_cpu_timer_set()
776 trigger_base_recalc_expires(timer, p); in posix_cpu_timer_set()
788 static void posix_cpu_timer_get(struct k_itimer *timer, struct itimerspec64 *itp) in posix_cpu_timer_get() argument
790 clockid_t clkid = CPUCLOCK_WHICH(timer->it_clock); in posix_cpu_timer_get()
791 struct cpu_timer *ctmr = &timer->it.cpu; in posix_cpu_timer_get()
796 p = cpu_timer_task_rcu(timer); in posix_cpu_timer_get()
803 itp->it_interval = ktime_to_timespec64(timer->it_interval); in posix_cpu_timer_get()
811 if (CPUCLOCK_PERTHREAD(timer->it_clock)) in posix_cpu_timer_get()
1047 static void posix_cpu_timer_rearm(struct k_itimer *timer) in posix_cpu_timer_rearm() argument
1049 clockid_t clkid = CPUCLOCK_WHICH(timer->it_clock); in posix_cpu_timer_rearm()
1056 p = cpu_timer_task_rcu(timer); in posix_cpu_timer_rearm()
1068 if (CPUCLOCK_PERTHREAD(timer->it_clock)) in posix_cpu_timer_rearm()
1073 bump_cpu_timer(timer, now); in posix_cpu_timer_rearm()
1078 arm_timer(timer, p); in posix_cpu_timer_rearm()
1329 struct k_itimer *timer, *next; in handle_posix_cpu_timers() local
1402 list_for_each_entry_safe(timer, next, &firing, it.cpu.elist) { in handle_posix_cpu_timers()
1412 spin_lock(&timer->it_lock); in handle_posix_cpu_timers()
1413 list_del_init(&timer->it.cpu.elist); in handle_posix_cpu_timers()
1414 cpu_firing = timer->it.cpu.firing; in handle_posix_cpu_timers()
1415 timer->it.cpu.firing = 0; in handle_posix_cpu_timers()
1422 cpu_timer_fire(timer); in handle_posix_cpu_timers()
1424 rcu_assign_pointer(timer->it.cpu.handling, NULL); in handle_posix_cpu_timers()
1425 spin_unlock(&timer->it_lock); in handle_posix_cpu_timers()
1505 struct k_itimer timer; in do_cpu_nanosleep() local
1512 memset(&timer, 0, sizeof timer); in do_cpu_nanosleep()
1513 spin_lock_init(&timer.it_lock); in do_cpu_nanosleep()
1514 timer.it_clock = which_clock; in do_cpu_nanosleep()
1515 timer.it_overrun = -1; in do_cpu_nanosleep()
1516 error = posix_cpu_timer_create(&timer); in do_cpu_nanosleep()
1517 timer.it_process = current; in do_cpu_nanosleep()
1526 spin_lock_irq(&timer.it_lock); in do_cpu_nanosleep()
1527 error = posix_cpu_timer_set(&timer, flags, &it, NULL); in do_cpu_nanosleep()
1529 spin_unlock_irq(&timer.it_lock); in do_cpu_nanosleep()
1534 if (!cpu_timer_getexpires(&timer.it.cpu)) { in do_cpu_nanosleep()
1539 posix_cpu_timer_del(&timer); in do_cpu_nanosleep()
1540 spin_unlock_irq(&timer.it_lock); in do_cpu_nanosleep()
1548 spin_unlock_irq(&timer.it_lock); in do_cpu_nanosleep()
1550 spin_lock_irq(&timer.it_lock); in do_cpu_nanosleep()
1556 expires = cpu_timer_getexpires(&timer.it.cpu); in do_cpu_nanosleep()
1557 error = posix_cpu_timer_set(&timer, 0, &zero_it, &it); in do_cpu_nanosleep()
1560 posix_cpu_timer_del(&timer); in do_cpu_nanosleep()
1563 posix_cpu_timer_wait_running_nsleep(&timer); in do_cpu_nanosleep()
1564 error = posix_cpu_timer_del(&timer); in do_cpu_nanosleep()
1568 spin_unlock_irq(&timer.it_lock); in do_cpu_nanosleep()
1642 static int process_cpu_timer_create(struct k_itimer *timer) in process_cpu_timer_create() argument
1644 timer->it_clock = PROCESS_CLOCK; in process_cpu_timer_create()
1645 return posix_cpu_timer_create(timer); in process_cpu_timer_create()
1662 static int thread_cpu_timer_create(struct k_itimer *timer) in thread_cpu_timer_create() argument
1664 timer->it_clock = THREAD_CLOCK; in thread_cpu_timer_create()
1665 return posix_cpu_timer_create(timer); in thread_cpu_timer_create()