2011-02-09 08:30:55

by Jan Beulich

[permalink] [raw]
Subject: [PATCH] fix jiffy calculations in calibrate_delay_direct to handle overflow

Fixes a hang when booting as dom0 under Xen, when jiffies can be
quite large by the time the kernel init gets this far.

Signed-off-by: Tim Deegan <[email protected]>

!time_after() -> time_before_eq() as per suggestion from Jiri Slaby.

Signed-off-by: Jan Beulich <[email protected]>
Cc: Jiri Slaby <[email protected]>
Cc: Jeremy Fitzhardinge <[email protected]>

---
init/calibrate.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

--- 2.6.38-rc4/init/calibrate.c
+++ 2.6.38-rc4-calibrate-jiffy-overflow/init/calibrate.c
@@ -66,7 +66,7 @@ static unsigned long __cpuinit calibrate
pre_start = 0;
read_current_timer(&start);
start_jiffies = jiffies;
- while (jiffies <= (start_jiffies + 1)) {
+ while (time_before_eq(jiffies, start_jiffies + 1)) {
pre_start = start;
read_current_timer(&start);
}
@@ -74,8 +74,8 @@ static unsigned long __cpuinit calibrate

pre_end = 0;
end = post_start;
- while (jiffies <=
- (start_jiffies + 1 + DELAY_CALIBRATION_TICKS)) {
+ while (time_before_eq(jiffies, start_jiffies + 1 +
+ DELAY_CALIBRATION_TICKS)) {
pre_end = end;
read_current_timer(&end);
}



2011-02-09 09:21:51

by Jiri Slaby

[permalink] [raw]
Subject: Re: [PATCH] fix jiffy calculations in calibrate_delay_direct to handle overflow

On 02/09/2011 09:31 AM, Jan Beulich wrote:
> Fixes a hang when booting as dom0 under Xen, when jiffies can be
> quite large by the time the kernel init gets this far.

As I wrote this might happen if the boot till this point takes ~ 5
minutes because we start at -5 minutes.

That said, is this a candidate for stable? (If so, please CC stable.)

> Signed-off-by: Tim Deegan <[email protected]>
>
> !time_after() -> time_before_eq() as per suggestion from Jiri Slaby.
>
> Signed-off-by: Jan Beulich <[email protected]>
> Cc: Jiri Slaby <[email protected]>
> Cc: Jeremy Fitzhardinge <[email protected]>
>
> ---
> init/calibrate.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> --- 2.6.38-rc4/init/calibrate.c
> +++ 2.6.38-rc4-calibrate-jiffy-overflow/init/calibrate.c
> @@ -66,7 +66,7 @@ static unsigned long __cpuinit calibrate
> pre_start = 0;
> read_current_timer(&start);
> start_jiffies = jiffies;
> - while (jiffies <= (start_jiffies + 1)) {
> + while (time_before_eq(jiffies, start_jiffies + 1)) {
> pre_start = start;
> read_current_timer(&start);
> }
> @@ -74,8 +74,8 @@ static unsigned long __cpuinit calibrate
>
> pre_end = 0;
> end = post_start;
> - while (jiffies <=
> - (start_jiffies + 1 + DELAY_CALIBRATION_TICKS)) {
> + while (time_before_eq(jiffies, start_jiffies + 1 +
> + DELAY_CALIBRATION_TICKS)) {
> pre_end = end;
> read_current_timer(&end);
> }

thanks,
--
js
suse labs

2011-02-09 09:43:31

by Jan Beulich

[permalink] [raw]
Subject: Re: [PATCH] fix jiffy calculations in calibrate_delay_direct to handle overflow

>>> On 09.02.11 at 10:21, Jiri Slaby <[email protected]> wrote:
> On 02/09/2011 09:31 AM, Jan Beulich wrote:
>> Fixes a hang when booting as dom0 under Xen, when jiffies can be
>> quite large by the time the kernel init gets this far.
>
> As I wrote this might happen if the boot till this point takes ~ 5
> minutes because we start at -5 minutes.
>
> That said, is this a candidate for stable? (If so, please CC stable.)

Honestly, I'm not certain (given that mainline Xen Dom0 support
is still only in its beginnings).

Jan

2011-02-09 09:53:41

by Jiri Slaby

[permalink] [raw]
Subject: Re: [PATCH] fix jiffy calculations in calibrate_delay_direct to handle overflow

On 02/09/2011 10:44 AM, Jan Beulich wrote:
>>>> On 09.02.11 at 10:21, Jiri Slaby <[email protected]> wrote:
>> On 02/09/2011 09:31 AM, Jan Beulich wrote:
>>> Fixes a hang when booting as dom0 under Xen, when jiffies can be
>>> quite large by the time the kernel init gets this far.
>>
>> As I wrote this might happen if the boot till this point takes ~ 5
>> minutes because we start at -5 minutes.
>>
>> That said, is this a candidate for stable? (If so, please CC stable.)
>
> Honestly, I'm not certain (given that mainline Xen Dom0 support
> is still only in its beginnings).

What about other VMs? If I run few non-kvm qemu VMs (kvm presets lpj) on
a busy dual-core machine, this will be a problem too, right?

regards,
--
js
suse labs

2011-02-09 13:18:09

by Jan Beulich

[permalink] [raw]
Subject: Re: [PATCH] fix jiffy calculations in calibrate_delay_direct to handle overflow

>>> On 09.02.11 at 10:53, Jiri Slaby <[email protected]> wrote:
> On 02/09/2011 10:44 AM, Jan Beulich wrote:
>>>>> On 09.02.11 at 10:21, Jiri Slaby <[email protected]> wrote:
>>> On 02/09/2011 09:31 AM, Jan Beulich wrote:
>>>> Fixes a hang when booting as dom0 under Xen, when jiffies can be
>>>> quite large by the time the kernel init gets this far.
>>>
>>> As I wrote this might happen if the boot till this point takes ~ 5
>>> minutes because we start at -5 minutes.
>>>
>>> That said, is this a candidate for stable? (If so, please CC stable.)
>>
>> Honestly, I'm not certain (given that mainline Xen Dom0 support
>> is still only in its beginnings).
>
> What about other VMs? If I run few non-kvm qemu VMs (kvm presets lpj) on
> a busy dual-core machine, this will be a problem too, right?

Yes, quite possible indeed.

Jan

2011-02-09 18:48:06

by Jeremy Fitzhardinge

[permalink] [raw]
Subject: Re: [PATCH] fix jiffy calculations in calibrate_delay_direct to handle overflow

On 02/09/2011 05:18 AM, Jan Beulich wrote:
>>>> On 09.02.11 at 10:53, Jiri Slaby <[email protected]> wrote:
>> On 02/09/2011 10:44 AM, Jan Beulich wrote:
>>>>>> On 09.02.11 at 10:21, Jiri Slaby <[email protected]> wrote:
>>>> On 02/09/2011 09:31 AM, Jan Beulich wrote:
>>>>> Fixes a hang when booting as dom0 under Xen, when jiffies can be
>>>>> quite large by the time the kernel init gets this far.
>>>> As I wrote this might happen if the boot till this point takes ~ 5
>>>> minutes because we start at -5 minutes.
>>>>
>>>> That said, is this a candidate for stable? (If so, please CC stable.)
>>> Honestly, I'm not certain (given that mainline Xen Dom0 support
>>> is still only in its beginnings).
>> What about other VMs? If I run few non-kvm qemu VMs (kvm presets lpj) on
>> a busy dual-core machine, this will be a problem too, right?
> Yes, quite possible indeed.

Seems like stable material since it 1) has fixed a real bug, and 2) is
the right way to do things anyway. It just hasn't been seen to fix a
bug in a stable kernel, so perhaps not. If it were any more complex
then wouldn't push it.

J

2011-02-09 20:54:33

by Linus Torvalds

[permalink] [raw]
Subject: Re: [PATCH] fix jiffy calculations in calibrate_delay_direct to handle overflow

On Wed, Feb 9, 2011 at 12:31 AM, Jan Beulich <[email protected]> wrote:
> Fixes a hang when booting as dom0 under Xen, when jiffies can be
> quite large by the time the kernel init gets this far.
>
> Signed-off-by: Tim Deegan <[email protected]>
>
> !time_after() -> time_before_eq() as per suggestion from Jiri Slaby.
>
> Signed-off-by: Jan Beulich <[email protected]>
> Cc: Jiri Slaby <[email protected]>
> Cc: Jeremy Fitzhardinge <[email protected]>

So I have nothing against the patch, but the changelog is broken.

Is Tim the original author? If so, why wasn't that noted? I'm just
guessing from that random signed-off line in the middle of the thing.

Please guys, don't drop authorship attributions, or alternatively
don't confuse me with odd random sign-off lines in the middle of the
message.

Linus

2011-02-10 08:47:39

by Jan Beulich

[permalink] [raw]
Subject: Re: [PATCH] fix jiffy calculations in calibrate_delay_direct to handle overflow

>>> On 09.02.11 at 21:54, Linus Torvalds <[email protected]> wrote:
> On Wed, Feb 9, 2011 at 12:31 AM, Jan Beulich <[email protected]> wrote:
>> Fixes a hang when booting as dom0 under Xen, when jiffies can be
>> quite large by the time the kernel init gets this far.
>>
>> Signed-off-by: Tim Deegan <[email protected]>
>>
>> !time_after() -> time_before_eq() as per suggestion from Jiri Slaby.
>>
>> Signed-off-by: Jan Beulich <[email protected]>
>> Cc: Jiri Slaby <[email protected]>
>> Cc: Jeremy Fitzhardinge <[email protected]>
>
> So I have nothing against the patch, but the changelog is broken.
>
> Is Tim the original author? If so, why wasn't that noted? I'm just
> guessing from that random signed-off line in the middle of the thing.

Indeed, I forgot to add the From: line. I'm sorry about that; I'll
resubmit.

Jan