lkml.org 
[lkml]   [2008]   [Jul]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] posix-timers: Do not modify an already queued timer signal
On 07/17, Mark McLoughlin wrote:
>
> On Wed, 2008-07-16 at 20:21 +0400, Oleg Nesterov wrote:
> > On 07/16, Mark McLoughlin wrote:
> > >
> > > When a timer fires, posix_timer_event() zeroes out its
> > > pre-allocated siginfo structure, initialises it and then
> > > queues up the signal with send_sigqueue().
> > >
> > > However, we may have previously queued up this signal, in
> > > which case we only want to increment si_overrun and
> > > re-initialising the siginfo structure is incorrect.
> >
> > Quoting Roland McGrath:
> > >
> > > I'm not clear on how the already-queued case could ever happen. Do we
> > > really need that check at all? It shouldn't be possible for the timer to
> > > be firing when it's already queued, because it won't have been reloaded.
> > > It only reloads via do_schedule_next_timer after it's dequeued, or because
> > > a 1 return value said it never was queued.
>
> The app can reload the timer itself before the signal has been dequeued
> via signalfd ...

Indeed! Thanks Mark.

Thomas, Roland, could you take a look?


> > If we need this fix, perhaps it is better to modify posix_timer_event()
> > to check !list_empty()?
>
> Yeah, I had considered that, but it's a tad more invasive. See below.
>
> I mainly don't like this patch

Agreed, this one looks worse.


I forgot (if ever knew ;) this code completely, but can't we make a simpler
fix? posix_timer_event() can check list_empty() lockless,

posix_timer_event()
{
if (!list_emtpy(sigq->list))
return 0;

... fill and send ->sigq...
}

When the signal will be dequeued, schedule_next_timer() should afaics
set ->it_overrun_last which is copied to ->si_overrun then. Or we can
increment timr->it_overrun before return if I misread hrtimer_forward().

What do you think?


Another possible fix... we can change sys_timer_settime() to do
sigqueue_free() and re-alloc ->sigq when it is pending. Not that
I like this very much though.

Oleg.



\
 
 \ /
  Last update: 2008-07-17 15:55    [W:0.102 / U:0.300 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site