* Re: hrtimer possible issue
[not found] <510E58C2.9010207@ravellosystems.com>
@ 2013-02-04 10:12 ` Thomas Gleixner
2013-02-04 11:22 ` Leonid Shatz
0 siblings, 1 reply; 5+ messages in thread
From: Thomas Gleixner @ 2013-02-04 10:12 UTC (permalink / raw)
To: Izik Eidus; +Cc: linux-kernel, Andrea Arcangeli, Leonid Shatz
On Sun, 3 Feb 2013, Izik Eidus wrote:
> Hi,
>
> it seems like hrtimer_enqueue_reprogram contain a race which could result in
> timer.base switch during unlock/lock sequence.
>
> See the code at __hrtimer_start_range_ns where it calls
> hrtimer_enqueue_reprogram. The later is releasing lock protecting the timer
> base for a short time and timer base switch can occur from a different CPU
> thread. Later when __hrtimer_start_range_ns calls unlock_hrtimer_base, a base
> switch could have happened and this causes the bug
>
> Try to start the same hrtimer from two different threads in kernel running
> each one on a different CPU. Eventually one of the calls will cause timer base
> switch while another thread is not expecting it.
>
> This can happen in virtualized environment where one thread can be delayed by
> lower hypervisor, and due to time delay a different CPU is taking care of
> missed timer start and runs the timer start logic on its own.
Nice analysis.
> This simple patch (just to give example of a fix) refactor this function to
> get rid of unneeded lock which immediately was followed by the unlock (with
> possible undesired base switch).
>
> (Both the bug and the fixed were found/patched by Leonid Shatz)
The patch got mangled by your mail client and it is missing the proper
Signed-off-by annotation in the patch description. See
Documentation/SubmittingPatches.
Can you please resend ?
Thanks,
tglx
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: hrtimer possible issue
2013-02-04 10:12 ` hrtimer possible issue Thomas Gleixner
@ 2013-02-04 11:22 ` Leonid Shatz
2013-02-05 10:20 ` Thomas Gleixner
0 siblings, 1 reply; 5+ messages in thread
From: Leonid Shatz @ 2013-02-04 11:22 UTC (permalink / raw)
To: 'Thomas Gleixner', 'Izik Eidus'
Cc: linux-kernel, 'Andrea Arcangeli', Mike Rapoport
I assume the race can also happen between hrtimer cancel and start. In both
cases timer base switch can happen.
Izik, please check if you can arrange the patch in the standard format (do
we need to do it against latest kernel version?)
Leonid Shatz
> -----Original Message-----
> From: Thomas Gleixner [mailto:tglx@linutronix.de]
> Sent: Monday, February 04, 2013 12:13 PM
> To: Izik Eidus
> Cc: linux-kernel@vger.kernel.org; Andrea Arcangeli; Leonid Shatz
> Subject: Re: hrtimer possible issue
>
> On Sun, 3 Feb 2013, Izik Eidus wrote:
>
> > Hi,
> >
> > it seems like hrtimer_enqueue_reprogram contain a race which could
> > result in timer.base switch during unlock/lock sequence.
> >
> > See the code at __hrtimer_start_range_ns where it calls
> > hrtimer_enqueue_reprogram. The later is releasing lock protecting the
> > timer base for a short time and timer base switch can occur from a
> > different CPU thread. Later when __hrtimer_start_range_ns calls
> > unlock_hrtimer_base, a base switch could have happened and this causes
> > the bug
> >
> > Try to start the same hrtimer from two different threads in kernel
> > running each one on a different CPU. Eventually one of the calls will
> > cause timer base switch while another thread is not expecting it.
> >
> > This can happen in virtualized environment where one thread can be
> > delayed by lower hypervisor, and due to time delay a different CPU is
> > taking care of missed timer start and runs the timer start logic on its
own.
>
> Nice analysis.
>
> > This simple patch (just to give example of a fix) refactor this
> > function to get rid of unneeded lock which immediately was followed by
> > the unlock (with possible undesired base switch).
> >
> > (Both the bug and the fixed were found/patched by Leonid Shatz)
>
> The patch got mangled by your mail client and it is missing the proper
Signed-
> off-by annotation in the patch description. See
> Documentation/SubmittingPatches.
>
> Can you please resend ?
>
> Thanks,
>
> tglx
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: hrtimer possible issue
2013-02-04 11:22 ` Leonid Shatz
@ 2013-02-05 10:20 ` Thomas Gleixner
2013-02-05 10:21 ` Izik Eidus
2013-02-05 10:34 ` Mike Rapoport
0 siblings, 2 replies; 5+ messages in thread
From: Thomas Gleixner @ 2013-02-05 10:20 UTC (permalink / raw)
To: Leonid Shatz
Cc: 'Izik Eidus', linux-kernel, 'Andrea Arcangeli',
Mike Rapoport
On Mon, 4 Feb 2013, Leonid Shatz wrote:
> I assume the race can also happen between hrtimer cancel and start. In both
> cases timer base switch can happen.
>
> Izik, please check if you can arrange the patch in the standard format (do
> we need to do it against latest kernel version?)
Yes please.
Thanks,
tglx
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: hrtimer possible issue
2013-02-05 10:20 ` Thomas Gleixner
@ 2013-02-05 10:21 ` Izik Eidus
2013-02-05 10:34 ` Mike Rapoport
1 sibling, 0 replies; 5+ messages in thread
From: Izik Eidus @ 2013-02-05 10:21 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Leonid Shatz, linux-kernel, 'Andrea Arcangeli',
Mike Rapoport
On 02/05/2013 12:20 PM, Thomas Gleixner wrote:
> On Mon, 4 Feb 2013, Leonid Shatz wrote:
>
>> I assume the race can also happen between hrtimer cancel and start. In both
>> cases timer base switch can happen.
>>
>> Izik, please check if you can arrange the patch in the standard format (do
>> we need to do it against latest kernel version?)
> Yes please.
But I sent it already yasterday with git-send-email and checkpatch.pl :-)
> Thanks,
>
> tglx
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: hrtimer possible issue
2013-02-05 10:20 ` Thomas Gleixner
2013-02-05 10:21 ` Izik Eidus
@ 2013-02-05 10:34 ` Mike Rapoport
1 sibling, 0 replies; 5+ messages in thread
From: Mike Rapoport @ 2013-02-05 10:34 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: Leonid Shatz, Izik Eidus, linux-kernel, Andrea Arcangeli
Thomas,
On Tue, Feb 5, 2013 at 12:20 PM, Thomas Gleixner <tglx@linutronix.de> wrote:
> On Mon, 4 Feb 2013, Leonid Shatz wrote:
>
>> I assume the race can also happen between hrtimer cancel and start. In both
>> cases timer base switch can happen.
>>
>> Izik, please check if you can arrange the patch in the standard format (do
>> we need to do it against latest kernel version?)
>
> Yes please.
The patch is here: https://patchwork.kernel.org/patch/2091501/
> Thanks,
>
> tglx
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-02-05 10:39 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <510E58C2.9010207@ravellosystems.com>
2013-02-04 10:12 ` hrtimer possible issue Thomas Gleixner
2013-02-04 11:22 ` Leonid Shatz
2013-02-05 10:20 ` Thomas Gleixner
2013-02-05 10:21 ` Izik Eidus
2013-02-05 10:34 ` Mike Rapoport
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.