Lines Matching +full:timer +full:-
1 // SPDX-License-Identifier: GPL-2.0
3 * Virtual cpu timer based timer functions.
38 u64 timer; in get_vtimer() local
40 asm volatile("stpt %0" : "=Q" (timer)); in get_vtimer()
41 return timer; in get_vtimer()
46 u64 timer; in set_vtimer() local
49 " stpt %0\n" /* Store current cpu timer value */ in set_vtimer()
51 : "=Q" (timer) : "Q" (expires)); in set_vtimer()
52 S390_lowcore.system_timer += S390_lowcore.last_update_timer - timer; in set_vtimer()
77 delta = cycles_new[i] - cycles_old[i]; in update_mt_scaling()
98 delta = new - *tsk_vtime; in update_tsk_timer()
117 p->stimescaled += cputime_to_nsecs(scale_vtime(cputime)); in account_system_index_scaled()
127 u64 timer, clock, user, guest, system, hardirq, softirq; in do_account_vtime() local
129 timer = S390_lowcore.last_update_timer; in do_account_vtime()
132 " stpt %0\n" /* Store current cpu timer value */ in do_account_vtime()
137 clock = S390_lowcore.last_update_clock - clock; in do_account_vtime()
138 timer -= S390_lowcore.last_update_timer; in do_account_vtime()
141 S390_lowcore.hardirq_timer += timer; in do_account_vtime()
143 S390_lowcore.system_timer += timer; in do_account_vtime()
151 user = update_tsk_timer(&tsk->thread.user_timer, in do_account_vtime()
153 guest = update_tsk_timer(&tsk->thread.guest_timer, in do_account_vtime()
155 system = update_tsk_timer(&tsk->thread.system_timer, in do_account_vtime()
157 hardirq = update_tsk_timer(&tsk->thread.hardirq_timer, in do_account_vtime()
159 softirq = update_tsk_timer(&tsk->thread.softirq_timer, in do_account_vtime()
162 clock - user - guest - system - hardirq - softirq; in do_account_vtime()
167 tsk->utimescaled += cputime_to_nsecs(scale_vtime(user)); in do_account_vtime()
172 tsk->utimescaled += cputime_to_nsecs(scale_vtime(guest)); in do_account_vtime()
188 prev->thread.user_timer = S390_lowcore.user_timer; in vtime_task_switch()
189 prev->thread.guest_timer = S390_lowcore.guest_timer; in vtime_task_switch()
190 prev->thread.system_timer = S390_lowcore.system_timer; in vtime_task_switch()
191 prev->thread.hardirq_timer = S390_lowcore.hardirq_timer; in vtime_task_switch()
192 prev->thread.softirq_timer = S390_lowcore.softirq_timer; in vtime_task_switch()
193 S390_lowcore.user_timer = current->thread.user_timer; in vtime_task_switch()
194 S390_lowcore.guest_timer = current->thread.guest_timer; in vtime_task_switch()
195 S390_lowcore.system_timer = current->thread.system_timer; in vtime_task_switch()
196 S390_lowcore.hardirq_timer = current->thread.hardirq_timer; in vtime_task_switch()
197 S390_lowcore.softirq_timer = current->thread.softirq_timer; in vtime_task_switch()
224 u64 timer = S390_lowcore.last_update_timer; in vtime_delta() local
228 return timer - S390_lowcore.last_update_timer; in vtime_delta()
239 if (tsk->flags & PF_VCPU) in vtime_account_kernel()
270 static void list_add_sorted(struct vtimer_list *timer, struct list_head *head) in list_add_sorted() argument
275 if (tmp->expires > timer->expires) { in list_add_sorted()
276 list_add_tail(&timer->entry, &tmp->entry); in list_add_sorted()
280 list_add_tail(&timer->entry, head); in list_add_sorted()
284 * Handler for expired virtual CPU timer.
288 struct vtimer_list *timer, *tmp; in virt_timer_expire() local
292 /* walk timer list, fire all expired timers */ in virt_timer_expire()
295 list_for_each_entry_safe(timer, tmp, &virt_timer_list, entry) { in virt_timer_expire()
296 if (timer->expires < elapsed) in virt_timer_expire()
297 /* move expired timer to the callback queue */ in virt_timer_expire()
298 list_move_tail(&timer->entry, &cb_list); in virt_timer_expire()
300 timer->expires -= elapsed; in virt_timer_expire()
303 timer = list_first_entry(&virt_timer_list, in virt_timer_expire()
305 atomic64_set(&virt_timer_current, timer->expires); in virt_timer_expire()
311 list_for_each_entry_safe(timer, tmp, &cb_list, entry) { in virt_timer_expire()
312 list_del_init(&timer->entry); in virt_timer_expire()
313 timer->function(timer->data); in virt_timer_expire()
314 if (timer->interval) { in virt_timer_expire()
315 /* Recharge interval timer */ in virt_timer_expire()
316 timer->expires = timer->interval + in virt_timer_expire()
319 list_add_sorted(timer, &virt_timer_list); in virt_timer_expire()
325 void init_virt_timer(struct vtimer_list *timer) in init_virt_timer() argument
327 timer->function = NULL; in init_virt_timer()
328 INIT_LIST_HEAD(&timer->entry); in init_virt_timer()
332 static inline int vtimer_pending(struct vtimer_list *timer) in vtimer_pending() argument
334 return !list_empty(&timer->entry); in vtimer_pending()
337 static void internal_add_vtimer(struct vtimer_list *timer) in internal_add_vtimer() argument
340 /* First timer, just program it. */ in internal_add_vtimer()
341 atomic64_set(&virt_timer_current, timer->expires); in internal_add_vtimer()
343 list_add(&timer->entry, &virt_timer_list); in internal_add_vtimer()
345 /* Update timer against current base. */ in internal_add_vtimer()
346 timer->expires += atomic64_read(&virt_timer_elapsed); in internal_add_vtimer()
347 if (likely((s64) timer->expires < in internal_add_vtimer()
349 /* The new timer expires before the current timer. */ in internal_add_vtimer()
350 atomic64_set(&virt_timer_current, timer->expires); in internal_add_vtimer()
351 /* Insert new timer into the list. */ in internal_add_vtimer()
352 list_add_sorted(timer, &virt_timer_list); in internal_add_vtimer()
356 static void __add_vtimer(struct vtimer_list *timer, int periodic) in __add_vtimer() argument
360 timer->interval = periodic ? timer->expires : 0; in __add_vtimer()
362 internal_add_vtimer(timer); in __add_vtimer()
367 * add_virt_timer - add a oneshot virtual CPU timer
369 void add_virt_timer(struct vtimer_list *timer) in add_virt_timer() argument
371 __add_vtimer(timer, 0); in add_virt_timer()
376 * add_virt_timer_int - add an interval virtual CPU timer
378 void add_virt_timer_periodic(struct vtimer_list *timer) in add_virt_timer_periodic() argument
380 __add_vtimer(timer, 1); in add_virt_timer_periodic()
384 static int __mod_vtimer(struct vtimer_list *timer, u64 expires, int periodic) in __mod_vtimer() argument
389 BUG_ON(!timer->function); in __mod_vtimer()
391 if (timer->expires == expires && vtimer_pending(timer)) in __mod_vtimer()
394 rc = vtimer_pending(timer); in __mod_vtimer()
396 list_del_init(&timer->entry); in __mod_vtimer()
397 timer->interval = periodic ? expires : 0; in __mod_vtimer()
398 timer->expires = expires; in __mod_vtimer()
399 internal_add_vtimer(timer); in __mod_vtimer()
405 * returns whether it has modified a pending timer (1) or not (0)
407 int mod_virt_timer(struct vtimer_list *timer, u64 expires) in mod_virt_timer() argument
409 return __mod_vtimer(timer, expires, 0); in mod_virt_timer()
414 * returns whether it has modified a pending timer (1) or not (0)
416 int mod_virt_timer_periodic(struct vtimer_list *timer, u64 expires) in mod_virt_timer_periodic() argument
418 return __mod_vtimer(timer, expires, 1); in mod_virt_timer_periodic()
423 * Delete a virtual timer.
425 * returns whether the deleted timer was pending (1) or not (0)
427 int del_virt_timer(struct vtimer_list *timer) in del_virt_timer() argument
431 if (!vtimer_pending(timer)) in del_virt_timer()
434 list_del_init(&timer->entry); in del_virt_timer()
441 * Start the virtual CPU timer on the current CPU.
445 /* set initial cpu timer */ in vtime_init()