* [PATCH 2/2] sched: Fix "divide error: 0000" in find_busiest_group
@ 2011-07-19 20:58 Terry Loftin
2011-07-19 21:18 ` Peter Zijlstra
0 siblings, 1 reply; 5+ messages in thread
From: Terry Loftin @ 2011-07-19 20:58 UTC (permalink / raw)
To: linux-kernel, Ingo Molnar, Peter Zijlstra; +Cc: Bob Montgomery
Add a check to sched_avg_update() to detect and reset age_stamp if the
clock value has wrapped. Because __cycles_2_ns() includes an offset
to account for start up time, the clock may not wrap to zero, so use
the current clock value instead.
Signed-off-by: Terry Loftin <terry.loftin@hp.com>
Signed-off-by: Bob Montgomery <bob.montgomery@hp.com>
---
diff --git a/kernel/sched.c b/kernel/sched.c
index 18d38e4..b39cae1 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -1256,6 +1256,8 @@ static void sched_avg_update(struct rq *rq)
{
s64 period = sched_avg_period();
+ if (unlikely(rq->age_stamp > rq->clock))
+ rq->age_stamp = rq->clock;
while ((s64)(rq->clock - rq->age_stamp) > period) {
/*
* Inline assembly required to prevent the compiler
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] sched: Fix "divide error: 0000" in find_busiest_group
2011-07-19 20:58 [PATCH 2/2] sched: Fix "divide error: 0000" in find_busiest_group Terry Loftin
@ 2011-07-19 21:18 ` Peter Zijlstra
2011-07-19 22:21 ` Terry Loftin
0 siblings, 1 reply; 5+ messages in thread
From: Peter Zijlstra @ 2011-07-19 21:18 UTC (permalink / raw)
To: Terry Loftin; +Cc: linux-kernel, Ingo Molnar, Bob Montgomery
On Tue, 2011-07-19 at 14:58 -0600, Terry Loftin wrote:
> Add a check to sched_avg_update() to detect and reset age_stamp if the
> clock value has wrapped. Because __cycles_2_ns() includes an offset
> to account for start up time, the clock may not wrap to zero, so use
> the current clock value instead.
So you're running on a platform (unspecified) where we use a raw
sched_clock() that is buggy. Again, you're fixing symptoms not causes.
> Signed-off-by: Terry Loftin <terry.loftin@hp.com>
> Signed-off-by: Bob Montgomery <bob.montgomery@hp.com>
> ---
> diff --git a/kernel/sched.c b/kernel/sched.c
> index 18d38e4..b39cae1 100644
> --- a/kernel/sched.c
> +++ b/kernel/sched.c
> @@ -1256,6 +1256,8 @@ static void sched_avg_update(struct rq *rq)
> {
> s64 period = sched_avg_period();
>
> + if (unlikely(rq->age_stamp > rq->clock))
> + rq->age_stamp = rq->clock;
> while ((s64)(rq->clock - rq->age_stamp) > period) {
> /*
> * Inline assembly required to prevent the compiler
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] sched: Fix "divide error: 0000" in find_busiest_group
2011-07-19 21:18 ` Peter Zijlstra
@ 2011-07-19 22:21 ` Terry Loftin
2011-07-19 22:33 ` Peter Zijlstra
0 siblings, 1 reply; 5+ messages in thread
From: Terry Loftin @ 2011-07-19 22:21 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: linux-kernel, Ingo Molnar, Bob Montgomery
On 07/19/2011 03:18 PM, Peter Zijlstra wrote:
> On Tue, 2011-07-19 at 14:58 -0600, Terry Loftin wrote:
>> Add a check to sched_avg_update() to detect and reset age_stamp if the
>> clock value has wrapped. Because __cycles_2_ns() includes an offset
>> to account for start up time, the clock may not wrap to zero, so use
>> the current clock value instead.
>
> So you're running on a platform (unspecified) where we use a raw
> sched_clock() that is buggy. Again, you're fixing symptoms not causes.
>
This x86_64. This is the actual cause, unless the rq->clock
value should never roll, in which case, the clock roll is the
actual cause and you can disregard these patches.
-T
>> Signed-off-by: Terry Loftin <terry.loftin@hp.com>
>> Signed-off-by: Bob Montgomery <bob.montgomery@hp.com>
>> ---
>> diff --git a/kernel/sched.c b/kernel/sched.c
>> index 18d38e4..b39cae1 100644
>> --- a/kernel/sched.c
>> +++ b/kernel/sched.c
>> @@ -1256,6 +1256,8 @@ static void sched_avg_update(struct rq *rq)
>> {
>> s64 period = sched_avg_period();
>>
>> + if (unlikely(rq->age_stamp > rq->clock))
>> + rq->age_stamp = rq->clock;
>> while ((s64)(rq->clock - rq->age_stamp) > period) {
>> /*
>> * Inline assembly required to prevent the compiler
>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] sched: Fix "divide error: 0000" in find_busiest_group
2011-07-19 22:21 ` Terry Loftin
@ 2011-07-19 22:33 ` Peter Zijlstra
2011-07-19 22:39 ` Terry Loftin
0 siblings, 1 reply; 5+ messages in thread
From: Peter Zijlstra @ 2011-07-19 22:33 UTC (permalink / raw)
To: Terry Loftin; +Cc: linux-kernel, Ingo Molnar, Bob Montgomery, John Stultz
On Tue, 2011-07-19 at 16:21 -0600, Terry Loftin wrote:
> > So you're running on a platform (unspecified) where we use a raw
> > sched_clock() that is buggy. Again, you're fixing symptoms not causes.
> >
> This x86_64. This is the actual cause, unless the rq->clock
> value should never roll, in which case, the clock roll is the
> actual cause and you can disregard these patches.
Its supposed to roll over on the full 64bit, and I think x86_64 only
suffers this if you have sched_clock_stable set to 1.
So I think the correct fix is disabling that logic for now. John Stultz
was working on some patches to fix __cycles_2_ns().
Something like the below perhaps.
---
arch/x86/kernel/cpu/intel.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 1edf5ba..dba0482 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -91,8 +91,6 @@ static void __cpuinit early_init_intel(struct cpuinfo_x86 *c)
if (c->x86_power & (1 << 8)) {
set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC);
- if (!check_tsc_unstable())
- sched_clock_stable = 1;
}
/*
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] sched: Fix "divide error: 0000" in find_busiest_group
2011-07-19 22:33 ` Peter Zijlstra
@ 2011-07-19 22:39 ` Terry Loftin
0 siblings, 0 replies; 5+ messages in thread
From: Terry Loftin @ 2011-07-19 22:39 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: linux-kernel, Ingo Molnar, Bob Montgomery, John Stultz
On 07/19/2011 04:33 PM, Peter Zijlstra wrote:
> On Tue, 2011-07-19 at 16:21 -0600, Terry Loftin wrote:
>>> So you're running on a platform (unspecified) where we use a raw
>>> sched_clock() that is buggy. Again, you're fixing symptoms not causes.
>>>
>> This x86_64. This is the actual cause, unless the rq->clock
>> value should never roll, in which case, the clock roll is the
>> actual cause and you can disregard these patches.
>
> Its supposed to roll over on the full 64bit, and I think x86_64 only
> suffers this if you have sched_clock_stable set to 1.
>
> So I think the correct fix is disabling that logic for now. John Stultz
> was working on some patches to fix __cycles_2_ns().
>
> Something like the below perhaps.
OK - this would also avoid the problem I came across. Thank you
for your time.
-T
>
> ---
> arch/x86/kernel/cpu/intel.c | 2 --
> 1 files changed, 0 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
> index 1edf5ba..dba0482 100644
> --- a/arch/x86/kernel/cpu/intel.c
> +++ b/arch/x86/kernel/cpu/intel.c
> @@ -91,8 +91,6 @@ static void __cpuinit early_init_intel(struct cpuinfo_x86 *c)
> if (c->x86_power & (1 << 8)) {
> set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
> set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC);
> - if (!check_tsc_unstable())
> - sched_clock_stable = 1;
> }
>
> /*
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-07-19 22:39 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-19 20:58 [PATCH 2/2] sched: Fix "divide error: 0000" in find_busiest_group Terry Loftin
2011-07-19 21:18 ` Peter Zijlstra
2011-07-19 22:21 ` Terry Loftin
2011-07-19 22:33 ` Peter Zijlstra
2011-07-19 22:39 ` Terry Loftin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox