Skip to content

Commit

Permalink
posix-timers: Rename k_itimer:: It_requeue_pending
Browse files Browse the repository at this point in the history
Prepare for using this struct member to do a proper reprogramming and
deletion accounting so that stale signals can be dropped.

No functional change.

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.611997737@linutronix.de
  • Loading branch information
Thomas Gleixner committed Oct 29, 2024
1 parent 2860d4d commit cd1e93a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
5 changes: 2 additions & 3 deletions include/linux/posix-timers.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ static inline void posix_cputimers_init_work(void) { }
* @it_active: Marker that timer is active
* @it_overrun: The overrun counter for pending signals
* @it_overrun_last: The overrun at the time of the last delivered signal
* @it_requeue_pending: Indicator that timer waits for being requeued on
* signal delivery
* @it_signal_seq: Sequence count to control signal delivery
* @it_sigev_notify: The notify word of sigevent struct for signal delivery
* @it_interval: The interval for periodic timers
* @it_signal: Pointer to the creators signal struct
Expand All @@ -172,7 +171,7 @@ struct k_itimer {
int it_active;
s64 it_overrun;
s64 it_overrun_last;
int it_requeue_pending;
unsigned int it_signal_seq;
int it_sigev_notify;
ktime_t it_interval;
struct signal_struct *it_signal;
Expand Down
2 changes: 1 addition & 1 deletion kernel/time/alarmtimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ static enum alarmtimer_restart alarm_handle_timer(struct alarm *alarm,
* small intervals cannot starve the system.
*/
ptr->it_overrun += __alarm_forward_now(alarm, ptr->it_interval, true);
++ptr->it_requeue_pending;
++ptr->it_signal_seq;
ptr->it_active = 1;
result = ALARMTIMER_RESTART;
}
Expand Down
4 changes: 2 additions & 2 deletions kernel/time/posix-cpu-timers.c
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ static void cpu_timer_fire(struct k_itimer *timer)
* ticking in case the signal is deliverable next time.
*/
posix_cpu_timer_rearm(timer);
++timer->it_requeue_pending;
++timer->it_signal_seq;
}
}

Expand Down Expand Up @@ -745,7 +745,7 @@ static void __posix_cpu_timer_get(struct k_itimer *timer, struct itimerspec64 *i
* - Timers which expired, but the signal has not yet been
* delivered
*/
if (iv && ((timer->it_requeue_pending & REQUEUE_PENDING) || sigev_none))
if (iv && ((timer->it_signal_seq & REQUEUE_PENDING) || sigev_none))
expires = bump_cpu_timer(timer, now);
else
expires = cpu_timer_getexpires(&timer->it.cpu);
Expand Down
12 changes: 6 additions & 6 deletions kernel/time/posix-timers.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,13 @@ bool posixtimer_deliver_signal(struct kernel_siginfo *info)
if (!timr)
goto out;

if (timr->it_interval && timr->it_requeue_pending == info->si_sys_private) {
if (timr->it_interval && timr->it_signal_seq == info->si_sys_private) {
timr->kclock->timer_rearm(timr);

timr->it_active = 1;
timr->it_overrun_last = timr->it_overrun;
timr->it_overrun = -1LL;
++timr->it_requeue_pending;
++timr->it_signal_seq;

info->si_overrun = timer_overrun_to_int(timr, info->si_overrun);
}
Expand All @@ -299,7 +299,7 @@ int posix_timer_queue_signal(struct k_itimer *timr)

timr->it_active = 0;
if (timr->it_interval)
si_private = ++timr->it_requeue_pending;
si_private = ++timr->it_signal_seq;

type = !(timr->it_sigev_notify & SIGEV_THREAD_ID) ? PIDTYPE_TGID : PIDTYPE_PID;
ret = send_sigqueue(timr->sigq, timr->it_pid, type, si_private);
Expand Down Expand Up @@ -366,7 +366,7 @@ static enum hrtimer_restart posix_timer_fn(struct hrtimer *timer)

timr->it_overrun += hrtimer_forward(timer, now, timr->it_interval);
ret = HRTIMER_RESTART;
++timr->it_requeue_pending;
++timr->it_signal_seq;
timr->it_active = 1;
}
}
Expand Down Expand Up @@ -660,7 +660,7 @@ void common_timer_get(struct k_itimer *timr, struct itimerspec64 *cur_setting)
* is a SIGEV_NONE timer move the expiry time forward by intervals,
* so expiry is > now.
*/
if (iv && (timr->it_requeue_pending & REQUEUE_PENDING || sig_none))
if (iv && (timr->it_signal_seq & REQUEUE_PENDING || sig_none))
timr->it_overrun += kc->timer_forward(timr, now);

remaining = kc->timer_remaining(timr, now);
Expand Down Expand Up @@ -861,7 +861,7 @@ void posix_timer_set_common(struct k_itimer *timer, struct itimerspec64 *new_set
timer->it_interval = 0;

/* Prevent reloading in case there is a signal pending */
timer->it_requeue_pending = (timer->it_requeue_pending + 2) & ~REQUEUE_PENDING;
timer->it_signal_seq = (timer->it_signal_seq + 2) & ~REQUEUE_PENDING;
/* Reset overrun accounting */
timer->it_overrun_last = 0;
timer->it_overrun = -1LL;
Expand Down

0 comments on commit cd1e93a

Please sign in to comment.