[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z8zJQtzLIliTNe2e@pavilion.home>
Date: Sat, 8 Mar 2025 23:48:34 +0100
From: Frederic Weisbecker <frederic@...nel.org>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: LKML <linux-kernel@...r.kernel.org>,
Anna-Maria Behnsen <anna-maria@...utronix.de>,
Benjamin Segall <bsegall@...gle.com>,
Eric Dumazet <edumazet@...gle.com>,
Andrey Vagin <avagin@...nvz.org>,
Pavel Tikhomirov <ptikhomirov@...tuozzo.com>,
Peter Zijlstra <peterz@...radead.org>
Subject: Re: [patch V2 08/17] posix-timers: Rework timer removal
Le Sat, Mar 08, 2025 at 09:34:06AM +0100, Thomas Gleixner a écrit :
> On Sat, Mar 08 2025 at 00:03, Frederic Weisbecker wrote:
> > Le Sun, Mar 02, 2025 at 08:36:56PM +0100, Thomas Gleixner a écrit :
> >> --- a/include/linux/posix-timers.h
> >> +++ b/include/linux/posix-timers.h
> >> @@ -240,6 +240,13 @@ static inline void posixtimer_sigqueue_p
> >>
> >> posixtimer_putref(tmr);
> >> }
> >> +
> >> +static inline bool posixtimer_valid(const struct k_itimer *timer)
> >> +{
> >> + unsigned long val = (unsigned long)timer->it_signal;
> >> +
> >> + return !(val & 0x1UL);
> >> +}
> >> #else /* CONFIG_POSIX_TIMERS */
> >> static inline void posixtimer_sigqueue_getref(struct sigqueue *q) { }
> >> static inline void posixtimer_sigqueue_putref(struct sigqueue *q) { }
> >> --- a/kernel/signal.c
> >> +++ b/kernel/signal.c
> >> @@ -2092,7 +2092,7 @@ static inline void posixtimer_sig_ignore
> >> * from a non-periodic timer, then just drop the reference
> >> * count. Otherwise queue it on the ignored list.
> >> */
> >> - if (tmr->it_signal && tmr->it_sig_periodic)
> >> + if (posixtimer_valid(tmr) && tmr->it_sig_periodic)
> >> hlist_add_head(&tmr->ignored_list, &tsk->signal->ignored_posix_timers);
> >> else
> >> posixtimer_putref(tmr);
> >> --- a/kernel/time/posix-timers.c
> >> +++ b/kernel/time/posix-timers.c
> >> @@ -279,7 +279,7 @@ static bool __posixtimer_deliver_signal(
> >> * since the signal was queued. In either case, don't rearm and
> >> * drop the signal.
> >> */
> >> - if (timr->it_signal_seq != timr->it_sigqueue_seq || WARN_ON_ONCE(!timr->it_signal))
> >> + if (timr->it_signal_seq != timr->it_sigqueue_seq || !posixtimer_valid(timr))
> >
> > Hmm, should it still warn here? ie: WARN_ON_ONCE(!posixtimer_valid(timr)) ?
>
> No, because the timer is invalidated early now.
But the signal can only be queued before posix_timer_delete(). So
if the bit 0 of it_signal has been reset, it_signal_seq must have been
incremented along, right?
And if so then timr->it_signal_seq == timr->it_sigqueue_seq must imply
posixtimer_valid(). And if not we should warn. Or am I missing something?
Thanks.
>
> Thanks,
>
> tglx
Powered by blists - more mailing lists