mirror of
https://github.com/torvalds/linux.git
synced 2026-05-05 23:05:25 -04:00
posix-timers: Add proper state tracking
Right now the state tracking is done by two struct members:
- it_active:
A boolean which tracks armed/disarmed state
- it_signal_seq:
A sequence counter which is used to invalidate settings
and prevent rearming
Replace it_active with it_status and keep properly track about the states
in one place.
This allows to reuse it_signal_seq to track reprogramming, disarm and
delete operations in order to drop signals which are related to the state
previous of those operations.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/all/20241001083835.670337048@linutronix.de
This commit is contained in:
@@ -453,7 +453,6 @@ static void disarm_timer(struct k_itimer *timer, struct task_struct *p)
|
||||
struct cpu_timer *ctmr = &timer->it.cpu;
|
||||
struct posix_cputimer_base *base;
|
||||
|
||||
timer->it_active = 0;
|
||||
if (!cpu_timer_dequeue(ctmr))
|
||||
return;
|
||||
|
||||
@@ -494,11 +493,12 @@ static int posix_cpu_timer_del(struct k_itimer *timer)
|
||||
*/
|
||||
WARN_ON_ONCE(ctmr->head || timerqueue_node_queued(&ctmr->node));
|
||||
} else {
|
||||
if (timer->it.cpu.firing)
|
||||
if (timer->it.cpu.firing) {
|
||||
ret = TIMER_RETRY;
|
||||
else
|
||||
} else {
|
||||
disarm_timer(timer, p);
|
||||
|
||||
timer->it_status = POSIX_TIMER_DISARMED;
|
||||
}
|
||||
unlock_task_sighand(p, &flags);
|
||||
}
|
||||
|
||||
@@ -560,7 +560,7 @@ static void arm_timer(struct k_itimer *timer, struct task_struct *p)
|
||||
struct cpu_timer *ctmr = &timer->it.cpu;
|
||||
u64 newexp = cpu_timer_getexpires(ctmr);
|
||||
|
||||
timer->it_active = 1;
|
||||
timer->it_status = POSIX_TIMER_ARMED;
|
||||
if (!cpu_timer_enqueue(&base->tqhead, ctmr))
|
||||
return;
|
||||
|
||||
@@ -586,7 +586,8 @@ static void cpu_timer_fire(struct k_itimer *timer)
|
||||
{
|
||||
struct cpu_timer *ctmr = &timer->it.cpu;
|
||||
|
||||
timer->it_active = 0;
|
||||
timer->it_status = POSIX_TIMER_DISARMED;
|
||||
|
||||
if (unlikely(timer->sigq == NULL)) {
|
||||
/*
|
||||
* This a special case for clock_nanosleep,
|
||||
@@ -671,7 +672,7 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags,
|
||||
ret = TIMER_RETRY;
|
||||
} else {
|
||||
cpu_timer_dequeue(ctmr);
|
||||
timer->it_active = 0;
|
||||
timer->it_status = POSIX_TIMER_DISARMED;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user