public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Richard Weinberger <richard@nod.at>
To: linux-kernel@vger.kernel.org
Cc: user-mode-linux-devel@lists.sourceforge.net, gunnarlindroth@hotmail.com
Subject: Floating point problems on UML - help needed
Date: Wed, 17 Aug 2011 22:58:23 +0200	[thread overview]
Message-ID: <4E4C2B6F.7000800@nod.at> (raw)

[-- 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;
}

             reply	other threads:[~2011-08-17 20:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-17 20:58 Richard Weinberger [this message]
2011-08-18  6:29 ` [uml-devel] Floating point problems on UML - help needed Stanislav Meduna
2011-08-18 10:45   ` Richard Weinberger
2011-08-18 11:36     ` Ingo van Lil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E4C2B6F.7000800@nod.at \
    --to=richard@nod.at \
    --cc=gunnarlindroth@hotmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=user-mode-linux-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox