Re: [patch v6 02/20] posix-timers: Make signal overrun accounting sensible
From: Frederic Weisbecker
Date: Sat Nov 02 2024 - 18:57:56 EST
Le Sat, Nov 02, 2024 at 08:41:53PM +0100, Thomas Gleixner a écrit :
> On Fri, Nov 01 2024 at 21:36, Thomas Gleixner wrote:
> > On Fri, Nov 01 2024 at 13:51, Frederic Weisbecker wrote:
> >> Le Thu, Oct 31, 2024 at 04:46:25PM +0100, Thomas Gleixner a écrit :
> >>> @@ -1968,15 +1968,9 @@ int send_sigqueue(struct sigqueue *q, st
> >>>
> >>> ret = 0;
> >>> if (unlikely(!list_empty(&q->list))) {
> >>> - /*
> >>> - * If an SI_TIMER entry is already queue just increment
> >>> - * the overrun count.
> >>> - */
> >>> - q->info.si_overrun++;
> >>> result = TRACE_SIGNAL_ALREADY_PENDING;
> >>> goto out;
> >>> }
> >>> - q->info.si_overrun = 0;
> >>
> >> So it's not cleared anymore on signal queue?
> >>
> >> Not sure if it's a big problem but if an interval timer gets a signal with
> >> overruns and then the timer is reset later as non interval, the resulting
> >> upcoming signals will still carry the previous non-zero overruns?
> >
> > Duh. Yes.
> >
> >> However it's better to keep the overrun update on a single place so
> >> perhaps this?
> >>
> >> diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
> >> index 66ed49efc02f..f06c52731d65 100644
> >> --- a/kernel/time/posix-timers.c
> >> +++ b/kernel/time/posix-timers.c
> >> @@ -282,6 +282,8 @@ bool posixtimer_deliver_signal(struct kernel_siginfo *info)
> >> ++timr->it_signal_seq;
> >>
> >> info->si_overrun = timer_overrun_to_int(timr);
> >> + } else {
> >> + info->si_overrun = 0;
> >> }
> >> ret = true;
> >>
> >> Other than that:
> >
> > Let me fold that.
>
> Actually no. info is the siginfo which was allocated by the signal
> delivery code on stack.
>
> collect_signal() copies timer->sigqueue.info into that siginfo
> struct. As timer->sigqueue.info.si_overrun is zero and never written to,
> this else path is pointless.
Good point, thanks for pointing out!