All of lore.kernel.org
 help / color / mirror / Atom feed
* cpufreq: weird bug in set_time_scale
@ 2007-10-11 15:55 Langsdorf, Mark
  2007-10-11 17:43 ` Keir Fraser
  0 siblings, 1 reply; 6+ messages in thread
From: Langsdorf, Mark @ 2007-10-11 15:55 UTC (permalink / raw)
  To: xen-devel

On my test machine, in set_time_scale(),
the following code:
	ts->mul_frac = div_frac(MILLISECS(1000), tps32);
crashes with a division by zero error if 
tps32 == 1000000000d.  Unfortunately, tps32 is
often that value.

Does anyone know why this happens?  I've 
resolved it temporarily by checking for
tps32 == 1000000000 and changing the 
value slightly (101000010d works fine
on my test machine), but I'm not sure 
if that's the approved approach for Xen.

-Mark Langsdorf
Operating System Research Center
AMD

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: cpufreq: weird bug in set_time_scale
  2007-10-11 15:55 cpufreq: weird bug in set_time_scale Langsdorf, Mark
@ 2007-10-11 17:43 ` Keir Fraser
  2007-10-11 18:14   ` Jean Pihet
  0 siblings, 1 reply; 6+ messages in thread
From: Keir Fraser @ 2007-10-11 17:43 UTC (permalink / raw)
  To: Langsdorf, Mark, xen-devel

That's my code. I'll take a look!

 K.

On 11/10/07 16:55, "Langsdorf, Mark" <mark.langsdorf@amd.com> wrote:

> On my test machine, in set_time_scale(),
> the following code:
> ts->mul_frac = div_frac(MILLISECS(1000), tps32);
> crashes with a division by zero error if
> tps32 == 1000000000d.  Unfortunately, tps32 is
> often that value.
> 
> Does anyone know why this happens?  I've
> resolved it temporarily by checking for
> tps32 == 1000000000 and changing the
> value slightly (101000010d works fine
> on my test machine), but I'm not sure
> if that's the approved approach for Xen.
> 
> -Mark Langsdorf
> Operating System Research Center
> AMD
> 
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: cpufreq: weird bug in set_time_scale
  2007-10-11 17:43 ` Keir Fraser
@ 2007-10-11 18:14   ` Jean Pihet
  2007-10-11 18:31     ` Keir Fraser
  0 siblings, 1 reply; 6+ messages in thread
From: Jean Pihet @ 2007-10-11 18:14 UTC (permalink / raw)
  To: xen-devel; +Cc: Langsdorf, Mark

Hi,

The problem is in divl instruction which throws a 'Floating point exception'. 
In the case below the dividend and the divisor are equal. Is that allowed by 
the instruction?

On the ARM code that we are currently implementing, there is no crash =;-) but 
the result is 0, which does not seem correct.

Should the assert in div_frac be changed to avoid weird results or crash?

Regards,
Jean

On Thursday 11 October 2007 19:43:08 Keir Fraser wrote:
> That's my code. I'll take a look!
>
>  K.
>
> On 11/10/07 16:55, "Langsdorf, Mark" <mark.langsdorf@amd.com> wrote:
> > On my test machine, in set_time_scale(),
> > the following code:
> > ts->mul_frac = div_frac(MILLISECS(1000), tps32);
> > crashes with a division by zero error if
> > tps32 == 1000000000d.  Unfortunately, tps32 is
> > often that value.
> >
> > Does anyone know why this happens?  I've
> > resolved it temporarily by checking for
> > tps32 == 1000000000 and changing the
> > value slightly (101000010d works fine
> > on my test machine), but I'm not sure
> > if that's the approved approach for Xen.
> >
> > -Mark Langsdorf
> > Operating System Research Center
> > AMD
> >
> >
> >
> > _______________________________________________
> > Xen-devel mailing list
> > Xen-devel@lists.xensource.com
> > http://lists.xensource.com/xen-devel
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: cpufreq: weird bug in set_time_scale
  2007-10-11 18:14   ` Jean Pihet
@ 2007-10-11 18:31     ` Keir Fraser
  2007-10-11 18:48       ` Jean Pihet
  2007-10-11 19:45       ` Langsdorf, Mark
  0 siblings, 2 replies; 6+ messages in thread
From: Keir Fraser @ 2007-10-11 18:31 UTC (permalink / raw)
  To: Jean Pihet, xen-devel; +Cc: Langsdorf, Mark

Yep, that case is not acceptable for the DIV instruction, because it causes
overflow of the quotient. It's fixed by xen-unstable changeset 16098.

It's a one-char fix: the loop on (tps32 < MILLISECS(1000)) needs to be
(tps32 <= MILLISECS(1000)).

 -- Keir

On 11/10/07 19:14, "Jean Pihet" <jpihet@mvista.com> wrote:

> Hi,
> 
> The problem is in divl instruction which throws a 'Floating point exception'.
> In the case below the dividend and the divisor are equal. Is that allowed by
> the instruction?
> 
> On the ARM code that we are currently implementing, there is no crash =;-) but
> the result is 0, which does not seem correct.
> 
> Should the assert in div_frac be changed to avoid weird results or crash?
> 
> Regards,
> Jean
> 
> On Thursday 11 October 2007 19:43:08 Keir Fraser wrote:
>> That's my code. I'll take a look!
>> 
>>  K.
>> 
>> On 11/10/07 16:55, "Langsdorf, Mark" <mark.langsdorf@amd.com> wrote:
>>> On my test machine, in set_time_scale(),
>>> the following code:
>>> ts->mul_frac = div_frac(MILLISECS(1000), tps32);
>>> crashes with a division by zero error if
>>> tps32 == 1000000000d.  Unfortunately, tps32 is
>>> often that value.
>>> 
>>> Does anyone know why this happens?  I've
>>> resolved it temporarily by checking for
>>> tps32 == 1000000000 and changing the
>>> value slightly (101000010d works fine
>>> on my test machine), but I'm not sure
>>> if that's the approved approach for Xen.
>>> 
>>> -Mark Langsdorf
>>> Operating System Research Center
>>> AMD
>>> 
>>> 
>>> 
>>> _______________________________________________
>>> Xen-devel mailing list
>>> Xen-devel@lists.xensource.com
>>> http://lists.xensource.com/xen-devel
>> 
>> _______________________________________________
>> Xen-devel mailing list
>> Xen-devel@lists.xensource.com
>> http://lists.xensource.com/xen-devel
> 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: cpufreq: weird bug in set_time_scale
  2007-10-11 18:31     ` Keir Fraser
@ 2007-10-11 18:48       ` Jean Pihet
  2007-10-11 19:45       ` Langsdorf, Mark
  1 sibling, 0 replies; 6+ messages in thread
From: Jean Pihet @ 2007-10-11 18:48 UTC (permalink / raw)
  To: Keir Fraser; +Cc: xen-devel, Langsdorf, Mark

Keir,

On Thursday 11 October 2007 20:31:53 Keir Fraser wrote:
> Yep, that case is not acceptable for the DIV instruction, because it causes
> overflow of the quotient. It's fixed by xen-unstable changeset 16098.
>
> It's a one-char fix: the loop on (tps32 < MILLISECS(1000)) needs to be
> (tps32 <= MILLISECS(1000)).
Indeed that nicely fixes the problem.

>
>  -- Keir

Thanks,
Jean

>
> On 11/10/07 19:14, "Jean Pihet" <jpihet@mvista.com> wrote:
> > Hi,
> >
> > The problem is in divl instruction which throws a 'Floating point
> > exception'. In the case below the dividend and the divisor are equal. Is
> > that allowed by the instruction?
> >
> > On the ARM code that we are currently implementing, there is no crash
> > =;-) but the result is 0, which does not seem correct.
> >
> > Should the assert in div_frac be changed to avoid weird results or crash?
> >
> > Regards,
> > Jean
> >
> > On Thursday 11 October 2007 19:43:08 Keir Fraser wrote:
> >> That's my code. I'll take a look!
> >>
> >>  K.
> >>
> >> On 11/10/07 16:55, "Langsdorf, Mark" <mark.langsdorf@amd.com> wrote:
> >>> On my test machine, in set_time_scale(),
> >>> the following code:
> >>> ts->mul_frac = div_frac(MILLISECS(1000), tps32);
> >>> crashes with a division by zero error if
> >>> tps32 == 1000000000d.  Unfortunately, tps32 is
> >>> often that value.
> >>>
> >>> Does anyone know why this happens?  I've
> >>> resolved it temporarily by checking for
> >>> tps32 == 1000000000 and changing the
> >>> value slightly (101000010d works fine
> >>> on my test machine), but I'm not sure
> >>> if that's the approved approach for Xen.
> >>>
> >>> -Mark Langsdorf
> >>> Operating System Research Center
> >>> AMD
> >>>
> >>>
> >>>
> >>> _______________________________________________
> >>> Xen-devel mailing list
> >>> Xen-devel@lists.xensource.com
> >>> http://lists.xensource.com/xen-devel
> >>
> >> _______________________________________________
> >> Xen-devel mailing list
> >> Xen-devel@lists.xensource.com
> >> http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: cpufreq: weird bug in set_time_scale
  2007-10-11 18:31     ` Keir Fraser
  2007-10-11 18:48       ` Jean Pihet
@ 2007-10-11 19:45       ` Langsdorf, Mark
  1 sibling, 0 replies; 6+ messages in thread
From: Langsdorf, Mark @ 2007-10-11 19:45 UTC (permalink / raw)
  To: Keir Fraser, Jean Pihet, xen-devel

> Yep, that case is not acceptable for the DIV instruction, 
> because it causes overflow of the quotient. It's fixed
> by xen-unstable changeset 16098.
> 
> It's a one-char fix: the loop on (tps32 < MILLISECS(1000))
> needs to be (tps32 <= MILLISECS(1000)).

Thanks, that fixed it.

-Mark Langsdorf
Operating System Research Center
AMD

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-10-11 19:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-11 15:55 cpufreq: weird bug in set_time_scale Langsdorf, Mark
2007-10-11 17:43 ` Keir Fraser
2007-10-11 18:14   ` Jean Pihet
2007-10-11 18:31     ` Keir Fraser
2007-10-11 18:48       ` Jean Pihet
2007-10-11 19:45       ` Langsdorf, Mark

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.