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

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.