Re: [PATCH] Lazy FPU save/restore

Anthony Liguori
2007-02-18T22:55:39Z

Avi Kivity wrote:
> Avi Kivity wrote:
>>>
>>> I'll have to try and setup a 64 bit system. I cannot reproduce on
>>> my 32bit system with your test program.
>>
>> It may be related to 64-bit (as that uses sse for floating point), or
>> to the fact that I use ssh on a remote host, which causes more
>> context switches. I'll try to reproduce on 32 bits with my setup.
>>
>
> It doesn't reproduce on a 32-bit host. However, it does reproduce on
> a 32-bit guest on a 64-bit host, and on a 32-bit user load running in
> a 64-bit guest on a 64-bit host.

Thanks, I'll setup a 64 bit partition and start debugging. I'm a bit
confused though, I thought CR0.TS even covers SIMD instructions?

I'll take a look at Xen and see if it's doing something else.

Regards,

Anthony Liguori

> I'm attaching an updated test program which makes it easier to spot
> the failures. You only need to run it on the guest, although running
> it on the host as well increases the failure rate significantly.
>
> ------------------------------------------------------------------------
>
>
> #include <stdio.h>
> #include <math.h>
>
> double test_fpu_once()
> {
> int i;
> double f = 0;
>
> for (i = 0; i < 10000000; ++i)
> f += 1 / (1.0 + i);
> return f;
> }
>
> void test_fpu()
> {
> double a, b;
> int runs;
>
> runs = 0;
> a = test_fpu_once();
> while (1) {
> b = test_fpu_once();
> if (fabs(a - b) > 1e-9)
> printf("error: %20.16f -> %20.16f\n", a, b);
> a = b;
> if (++runs % 100 == 0)
> printf("runs: %8d\n", runs);
> }
> }
>
> int main(int ac, char **av)
> {
> test_fpu();
> return 0;
> }