All of lore.kernel.org
 help / color / mirror / Atom feed
* Floating point problems on UML - help needed
@ 2011-08-17 20:58 Richard Weinberger
  2011-08-18  6:29 ` [uml-devel] " Stanislav Meduna
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Weinberger @ 2011-08-17 20:58 UTC (permalink / raw)
  To: linux-kernel; +Cc: user-mode-linux-devel, gunnarlindroth

[-- Attachment #1: Type: text/plain, Size: 913 bytes --]

Hi,

Gunnar reported that some Java program does not work proper within 
UserModeLinux.
After looking closer at the problem I was able to reduce it to a small C 
program. (Program is attached.)

It looks like FPU registers get sometimes lost after switching between 
two or more threads.
It also happens not always, that's why my test program contains a 
infinite loop. After a few million iterations the program abort()s.

I can reproduce the issue on both x86 and x86_64, the host's or UML's 
kernel version does not matter.
I've tested 2.6.18 to 3.1-rc2.

Interestingly the problem occurs not on my old Pentium 4 machines.
One P4 has HT the other not.
Only "newer" CPUs are affected.

First I thought it's a race in _switch_to(), but adding 
unblock/block_signals() did not help.
Currently I'm running out of ideas.
I'm not an expert in this area of UML. :-(

Any idea what goes wrong here?

Thanks,
//richard

[-- Attachment #2: fpu-test.c --]
[-- Type: text/x-csrc, Size: 447 bytes --]

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>

static int xxx(float f)
{
	if(f <= 0.0){
		printf("wrong f!: %f\n", f);
		return -1;
	}

	return 0;
}

static void *fun(void *arg)
{
	float f = 5.0;

	for(;;){
		if(xxx(f) < 0)
			abort();
	}

	return NULL;
}

int main()
{
	pthread_t t1, t2;

	pthread_create(&t1, NULL, fun, NULL);
	pthread_create(&t2, NULL, fun, NULL);

	pthread_join(t1, NULL);
	pthread_join(t2, NULL);

	return 0;
}

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

* Re: [uml-devel] Floating point problems on UML - help needed
  2011-08-17 20:58 Floating point problems on UML - help needed Richard Weinberger
@ 2011-08-18  6:29 ` Stanislav Meduna
  2011-08-18 10:45   ` Richard Weinberger
  0 siblings, 1 reply; 4+ messages in thread
From: Stanislav Meduna @ 2011-08-18  6:29 UTC (permalink / raw)
  To: Richard Weinberger; +Cc: linux-kernel, gunnarlindroth, user-mode-linux-devel

On 17.08.2011 22:58, Richard Weinberger wrote:

> It looks like FPU registers get sometimes lost after switching between
> two or more threads.

This is probably a bug in UML I reported nearly three years ago.
For me mode=skas0 worked aruond the issue.

http://thread.gmane.org/gmane.linux.uml.devel/11824/focus=11840

You might try the patch posted in
http://thread.gmane.org/gmane.linux.uml.devel/12158
(I don't have the environment to test it anymore)

Regards
-- 
                                     Stano

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

* Re: [uml-devel] Floating point problems on UML - help needed
  2011-08-18  6:29 ` [uml-devel] " Stanislav Meduna
@ 2011-08-18 10:45   ` Richard Weinberger
  2011-08-18 11:36     ` Ingo van Lil
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Weinberger @ 2011-08-18 10:45 UTC (permalink / raw)
  To: Stanislav Meduna
  Cc: linux-kernel, gunnarlindroth, user-mode-linux-devel, inguin

Am 18.08.2011 08:29, schrieb Stanislav Meduna:
> On 17.08.2011 22:58, Richard Weinberger wrote:
>
>> It looks like FPU registers get sometimes lost after switching between
>> two or more threads.
>
> This is probably a bug in UML I reported nearly three years ago.
> For me mode=skas0 worked aruond the issue.
>
> http://thread.gmane.org/gmane.linux.uml.devel/11824/focus=11840
>
> You might try the patch posted in
> http://thread.gmane.org/gmane.linux.uml.devel/12158
> (I don't have the environment to test it anymore)

Cool, saving the FP registers explicitly on each task switch solves the 
issue.
Do you know why Ingo's patch was never applied?
Ingo?

Thanks,
//richard

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

* Re: [uml-devel] Floating point problems on UML - help needed
  2011-08-18 10:45   ` Richard Weinberger
@ 2011-08-18 11:36     ` Ingo van Lil
  0 siblings, 0 replies; 4+ messages in thread
From: Ingo van Lil @ 2011-08-18 11:36 UTC (permalink / raw)
  To: Richard Weinberger
  Cc: Stanislav Meduna, linux-kernel, gunnarlindroth, user-mode-linux-devel

On 18/08/2011 12:45, Richard Weinberger wrote:

>> You might try the patch posted in
>> http://thread.gmane.org/gmane.linux.uml.devel/12158
>> (I don't have the environment to test it anymore)
>
> Cool, saving the FP registers explicitly on each task switch solves the
> issue.
> Do you know why Ingo's patch was never applied?
> Ingo?

I don't know why it was never applied, I guess it just slipped between 
the cracks. I've been using the patch for several months back in 2009, 
and it reliably fixed the observed problems.

My employer switched from UML to QEMU/KVM since then, so I eventually 
lost interest.

Cheers,
Ingo

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

end of thread, other threads:[~2011-08-18 11:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-17 20:58 Floating point problems on UML - help needed Richard Weinberger
2011-08-18  6:29 ` [uml-devel] " Stanislav Meduna
2011-08-18 10:45   ` Richard Weinberger
2011-08-18 11:36     ` Ingo van Lil

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.