linux-um archives
 help / color / mirror / Atom feed
From: Blaisorblade <blaisorblade@yahoo.it>
To: Nikola Ciprich <nikola.ciprich@linuxbox.cz>
Cc: Jeff Dike <jdike@addtoit.com>,
	user-mode-linux-devel@lists.sourceforge.net
Subject: Re: [uml-devel] SKAS mode not working, x86_64 SMP host, x86_64	guest , problems with noprocmm
Date: Wed, 18 Oct 2006 01:39:55 +0200	[thread overview]
Message-ID: <200610180139.55496.blaisorblade@yahoo.it> (raw)
In-Reply-To: <1161116486.2709.15.camel@nik-nb>

On Tuesday 17 October 2006 22:21, Nikola Ciprich wrote:
> Hi guys,
> thanks for suggestions. Now I've been able to track the problem, and it
> seems to be arch/um/sys-x86_64/delay.c, function __const_udelay.
> halt process hangs at drivers/md/md.c, function md_notify_reboot(...):
> it never gets after the mdelay(1000*1) line, however according to my
> printk's I've added it seems that this function is being executed
> periodically, but it's certainly because of some overflow.
> I've noticed that it's being called with usecs value of 4294000, and
> I've also noticed following comment at include/linux/delay.h:
> /*
>  * Using udelay() for intervals greater than a few milliseconds can
>  * risk overflow for high loops_per_jiffy (high bogomips) machines. The
>  * mdelay() provides a wrapper to prevent this.  For delays greater
>  * than MAX_UDELAY_MS milliseconds, the wrapper is used.  Architecture
>  * specific values can be defined in asm-???/delay.h as an override.
>  * The 2nd mdelay() definition ensures GCC will optimize away the
>  * while loop for the common cases where n <= MAX_UDELAY_MS  --  Paul G.
>  */
> So maybe calling __const_udelay with such high value is problem? When I
> print value of n, it's always some big value (like 3419150745), so it
> seems that this variable is overflowing). When I compare um-i386 and
> um-x86_64 implementation of __const_udelay, it turns that difference
> between them is that i386 version uses plain unsigned ints, while x86_64
> version uses unsigned longs. So I've tried to change longs to ints (yup,
> it's certainly brain damaged, but I just wanted to try) and things seem
> to started working.

You really changed long to int? In this case, you may only have introduced a 
bigger overflow.
Jeff, I remember vaguely a recent (>=2.6.17) patch about udelay fixing a 
misbehaviour, would you please complete my recollection and verify the 
interaction with this?

Also, since we take __const_udelay and __udelay() from asm/arch/delay.h:
(for i386):
#define udelay(n) (__builtin_constant_p(n) ? \
        ((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 0x10c6ul)) : \
        __udelay(n))

#define ndelay(n) (__builtin_constant_p(n) ? \
       ((n) > 20000 ? __bad_ndelay() : __const_udelay((n) * 5ul)) : \
       __ndelay(n))

We then do _not_ take these definitions:
arch/i386/lib/delay.c:

void __udelay(unsigned long usecs)
{
        __const_udelay(usecs * 0x000010c7); /* 2**32 / 1000000 (rounded up) */
}

void __ndelay(unsigned long nsecs)
{
        __const_udelay(nsecs * 0x00005); /* 2**32 / 1000000000 (rounded up) */
}

instead for us __udelay and __const_udelay match, which is not likely to help 
at all. Their code is correct because the asm "mull" call divides the 
obtained product by 2^32 by throwing away the 32 low bits (i.e. EAX, since 
the mull result is in EDX:EAX), and the meaning of this is to do the division 
only at the very end (to improve accuracy).

This bug is here at least since 2.6.16.
Suggested solution:
1) have _our own_ delay.h, to avoid depending on subarchs' changes
2) first avoid playing so complex tricks, then maybe copy their implementation 
(note it is slightly different already among x86 and x86_64).

> But I'm sure this is not the right solution, so what 
> do You guys suggest? And also is really i386 variant safely implemented?

> thanks a lot!
> nik.

-- 
Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!".
Paolo Giarrusso, aka Blaisorblade
http://www.user-mode-linux.org/~blaisorblade
Chiacchiera con i tuoi amici in tempo reale! 
 http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com 


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

  parent reply	other threads:[~2006-10-17 23:40 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-30 16:30 [uml-devel] SKAS mode not working, x86_64 SMP host, x86_64 guest, problems with noprocmm Nikola Ciprich
2006-09-30 21:49 ` Jeff Dike
2006-09-30 22:11   ` Nikola Ciprich
2006-09-30 23:57     ` Jeff Dike
2006-10-01  0:04       ` Nikola Ciprich
2006-10-01  0:08       ` Nikola Ciprich
2006-10-01  0:19         ` Nikola Ciprich
2006-10-01  0:45           ` Nikola Ciprich
2006-10-01 15:08             ` [uml-devel] SKAS mode not working, x86_64 SMP host, x86_64 guest , " Blaisorblade
2006-10-01 15:25       ` [uml-devel] SKAS mode not working, x86_64 SMP host, x86_64 guest, " Blaisorblade
2006-10-01 15:51         ` Nikola Ciprich
2006-10-01 21:00           ` Nikola Ciprich
2006-10-05 11:33             ` Blaisorblade
2006-10-08 11:04               ` Blaisorblade
2006-10-08 19:08                 ` Nikola Ciprich
2006-10-08 19:30                   ` Blaisorblade
2006-10-08 20:01                     ` Nikola Ciprich
2006-10-14  0:23                       ` Blaisorblade
2006-10-14  9:23                         ` Nikola Ciprich
2006-10-15 17:35                           ` [uml-devel] SKAS mode not working, x86_64 SMP host, x86_64 guest , " Blaisorblade
2006-10-16 15:02                           ` [uml-devel] SKAS mode not working, x86_64 SMP host, x86_64 guest, " Jeff Dike
     [not found]                             ` <1161116486.2709.15.camel@nik-nb>
2006-10-17 23:39                               ` Blaisorblade [this message]
2006-10-18  7:40                                 ` [uml-devel] SKAS mode not working, x86_64 SMP host, x86_64 guest , " Nikola Ciprich
2006-10-18 18:56                                 ` Jeff Dike
2006-10-05 20:14           ` [uml-devel] SKAS mode not working, x86_64 SMP host, x86_64 guest, " Blaisorblade
2006-10-07 14:27             ` Nikola Ciprich

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=200610180139.55496.blaisorblade@yahoo.it \
    --to=blaisorblade@yahoo.it \
    --cc=jdike@addtoit.com \
    --cc=nikola.ciprich@linuxbox.cz \
    --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