hrtimer.c (c9f289701540baeef9ac7c9977d67a7259f404db) hrtimer.c (73d20564e0dcae003e0d79977f044d5e57496304)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright(C) 2005-2006, Thomas Gleixner <tglx@linutronix.de>
4 * Copyright(C) 2005-2007, Red Hat, Inc., Ingo Molnar
5 * Copyright(C) 2006-2007 Timesys Corp., Thomas Gleixner
6 *
7 * High-resolution kernel timers
8 *

--- 297 unchanged lines hidden (view full) ---

306 tmp = dclc < 0 ? -dclc : dclc;
307
308 /* Make sure the divisor is less than 2^32: */
309 while (div >> 32) {
310 sft++;
311 div >>= 1;
312 }
313 tmp >>= sft;
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright(C) 2005-2006, Thomas Gleixner <tglx@linutronix.de>
4 * Copyright(C) 2005-2007, Red Hat, Inc., Ingo Molnar
5 * Copyright(C) 2006-2007 Timesys Corp., Thomas Gleixner
6 *
7 * High-resolution kernel timers
8 *

--- 297 unchanged lines hidden (view full) ---

306 tmp = dclc < 0 ? -dclc : dclc;
307
308 /* Make sure the divisor is less than 2^32: */
309 while (div >> 32) {
310 sft++;
311 div >>= 1;
312 }
313 tmp >>= sft;
314 do_div(tmp, (unsigned long) div);
314 do_div(tmp, (u32) div);
315 return dclc < 0 ? -tmp : tmp;
316}
317EXPORT_SYMBOL_GPL(__ktime_divns);
318#endif /* BITS_PER_LONG >= 64 */
319
320/*
321 * Add two ktime values and do a safety check for overflow:
322 */

--- 1076 unchanged lines hidden (view full) ---

1399 * ensure POSIX compliance.
1400 */
1401 if (clock_id == CLOCK_REALTIME && mode & HRTIMER_MODE_REL)
1402 clock_id = CLOCK_MONOTONIC;
1403
1404 base = softtimer ? HRTIMER_MAX_CLOCK_BASES / 2 : 0;
1405 base += hrtimer_clockid_to_base(clock_id);
1406 timer->is_soft = softtimer;
315 return dclc < 0 ? -tmp : tmp;
316}
317EXPORT_SYMBOL_GPL(__ktime_divns);
318#endif /* BITS_PER_LONG >= 64 */
319
320/*
321 * Add two ktime values and do a safety check for overflow:
322 */

--- 1076 unchanged lines hidden (view full) ---

1399 * ensure POSIX compliance.
1400 */
1401 if (clock_id == CLOCK_REALTIME && mode & HRTIMER_MODE_REL)
1402 clock_id = CLOCK_MONOTONIC;
1403
1404 base = softtimer ? HRTIMER_MAX_CLOCK_BASES / 2 : 0;
1405 base += hrtimer_clockid_to_base(clock_id);
1406 timer->is_soft = softtimer;
1407 timer->is_hard = !softtimer;
1407 timer->is_hard = !!(mode & HRTIMER_MODE_HARD);
1408 timer->base = &cpu_base->clock_base[base];
1409 timerqueue_init(&timer->node);
1410}
1411
1412/**
1413 * hrtimer_init - initialize a timer to the given clock
1414 * @timer: the timer to be initialized
1415 * @clock_id: the clock to be used

--- 59 unchanged lines hidden (view full) ---

1475 */
1476
1477static void __run_hrtimer(struct hrtimer_cpu_base *cpu_base,
1478 struct hrtimer_clock_base *base,
1479 struct hrtimer *timer, ktime_t *now,
1480 unsigned long flags) __must_hold(&cpu_base->lock)
1481{
1482 enum hrtimer_restart (*fn)(struct hrtimer *);
1408 timer->base = &cpu_base->clock_base[base];
1409 timerqueue_init(&timer->node);
1410}
1411
1412/**
1413 * hrtimer_init - initialize a timer to the given clock
1414 * @timer: the timer to be initialized
1415 * @clock_id: the clock to be used

--- 59 unchanged lines hidden (view full) ---

1475 */
1476
1477static void __run_hrtimer(struct hrtimer_cpu_base *cpu_base,
1478 struct hrtimer_clock_base *base,
1479 struct hrtimer *timer, ktime_t *now,
1480 unsigned long flags) __must_hold(&cpu_base->lock)
1481{
1482 enum hrtimer_restart (*fn)(struct hrtimer *);
1483 bool expires_in_hardirq;
1483 int restart;
1484
1485 lockdep_assert_held(&cpu_base->lock);
1486
1487 debug_deactivate(timer);
1488 base->running = timer;
1489
1490 /*

--- 18 unchanged lines hidden (view full) ---

1509
1510 /*
1511 * The timer is marked as running in the CPU base, so it is
1512 * protected against migration to a different CPU even if the lock
1513 * is dropped.
1514 */
1515 raw_spin_unlock_irqrestore(&cpu_base->lock, flags);
1516 trace_hrtimer_expire_entry(timer, now);
1484 int restart;
1485
1486 lockdep_assert_held(&cpu_base->lock);
1487
1488 debug_deactivate(timer);
1489 base->running = timer;
1490
1491 /*

--- 18 unchanged lines hidden (view full) ---

1510
1511 /*
1512 * The timer is marked as running in the CPU base, so it is
1513 * protected against migration to a different CPU even if the lock
1514 * is dropped.
1515 */
1516 raw_spin_unlock_irqrestore(&cpu_base->lock, flags);
1517 trace_hrtimer_expire_entry(timer, now);
1518 expires_in_hardirq = lockdep_hrtimer_enter(timer);
1519
1517 restart = fn(timer);
1520 restart = fn(timer);
1521
1522 lockdep_hrtimer_exit(expires_in_hardirq);
1518 trace_hrtimer_expire_exit(timer);
1519 raw_spin_lock_irq(&cpu_base->lock);
1520
1521 /*
1522 * Note: We clear the running state after enqueue_hrtimer and
1523 * we do not reprogram the event hardware. Happens either in
1524 * hrtimer_start_range_ns() or in hrtimer_interrupt()
1525 *

--- 688 unchanged lines hidden ---
1523 trace_hrtimer_expire_exit(timer);
1524 raw_spin_lock_irq(&cpu_base->lock);
1525
1526 /*
1527 * Note: We clear the running state after enqueue_hrtimer and
1528 * we do not reprogram the event hardware. Happens either in
1529 * hrtimer_start_range_ns() or in hrtimer_interrupt()
1530 *

--- 688 unchanged lines hidden ---