/* * Mode arguments of xxx_hrtimer functions: * * HRTIMER_MODE_ABS - Time value is absolute * HRTIMER_MODE_REL - Time value is relative to now * HRTIMER_MODE_PINNED - Timer is bound to CPU (is only considered * when starting the timer) * HRTIMER_MODE_SOFT - Timer callback function will be executed in * soft irq context * HRTIMER_MODE_HARD - Timer callback function will be executed in * hard irq context even on PREEMPT_RT.
*/ enum hrtimer_mode {
HRTIMER_MODE_ABS = 0x00,
HRTIMER_MODE_REL = 0x01,
HRTIMER_MODE_PINNED = 0x02,
HRTIMER_MODE_SOFT = 0x04,
HRTIMER_MODE_HARD = 0x08,
/* * Values to track state of the timer * * Possible states: * * 0x00 inactive * 0x01 enqueued into rbtree * * The callback state is not part of the timer->state because clearing it would * mean touching the timer after the callback, this makes it impossible to free * the timer from the callback function. * * Therefore we track the callback state in: * * timer->base->cpu_base->running == timer * * On SMP it is possible to have a "callback function running and enqueued" * status. It happens for example when a posix timer expired and the callback * queued a signal. Between dropping the lock which protects the posix timer * and reacquiring the base lock of the hrtimer, another CPU can deliver the * signal and rearm the timer. * * All state transitions are protected by cpu_base->lock.
*/ #define HRTIMER_STATE_INACTIVE 0x00 #define HRTIMER_STATE_ENQUEUED 0x01
/** * struct hrtimer_sleeper - simple sleeper structure * @timer: embedded timer structure * @task: task to wake up * * task is set to NULL, when the timer expires.
*/ struct hrtimer_sleeper { struct hrtimer timer; struct task_struct *task;
};
/* * Adjust relative timers for the extra we added in * hrtimer_start_range_ns() to prevent short timeouts.
*/ if (IS_ENABLED(CONFIG_TIME_LOW_RES) && timer->is_rel)
rem -= hrtimer_resolution; return rem;
}
/** * hrtimer_get_remaining - get remaining time for the timer * @timer: the timer to read
*/ staticinline ktime_t hrtimer_get_remaining(conststruct hrtimer *timer)
{ return __hrtimer_get_remaining(timer, false);
}
/** * hrtimer_is_queued - check, whether the timer is on one of the queues * @timer: Timer to check * * Returns: True if the timer is queued, false otherwise * * The function can be used lockless, but it gives only a current snapshot.
*/ staticinlinebool hrtimer_is_queued(struct hrtimer *timer)
{ /* The READ_ONCE pairs with the update functions of timer->state */ return !!(READ_ONCE(timer->state) & HRTIMER_STATE_ENQUEUED);
}
/* * Helper function to check, whether the timer is running the callback * function
*/ staticinlineint hrtimer_callback_running(struct hrtimer *timer)
{ return timer->base->running == timer;
}
/** * hrtimer_update_function - Update the timer's callback function * @timer: Timer to update * @function: New callback function * * Only safe to call if the timer is not enqueued. Can be called in the callback function if the * timer is not enqueued at the same time (see the comments above HRTIMER_STATE_ENQUEUED).
*/ staticinlinevoid hrtimer_update_function(struct hrtimer *timer, enum hrtimer_restart (*function)(struct hrtimer *))
{ #ifdef CONFIG_PROVE_LOCKING
guard(raw_spinlock_irqsave)(&timer->base->cpu_base->lock);
if (WARN_ON_ONCE(hrtimer_is_queued(timer))) return;
if (WARN_ON_ONCE(!function)) return; #endif
ACCESS_PRIVATE(timer, function) = function;
}
/* Forward a hrtimer so it expires after now: */ extern u64
hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval);
/** * hrtimer_forward_now() - forward the timer expiry so it expires after now * @timer: hrtimer to forward * @interval: the interval to forward * * It is a variant of hrtimer_forward(). The timer will expire after the current * time of the hrtimer clock base. See hrtimer_forward() for details.
*/ staticinline u64 hrtimer_forward_now(struct hrtimer *timer,
ktime_t interval)
{ return hrtimer_forward(timer, timer->base->get_time(), interval);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.