All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Dike <jdike@addtoit.com>
To: Nix <nix@esperi.org.uk>
Cc: Thomas Gleixner <tglx@timesys.com>,
	linux-kernel Mailing List <linux-kernel@vger.kernel.org>,
	user-mode-linux-devel@lists.sourceforge.net
Subject: Re: [uml-devel] [2.6.24.x] UML select()/poll() oversleeping reproducibly (was	Re: g_timeout_add)
Date: Mon, 17 Mar 2008 15:34:15 -0400	[thread overview]
Message-ID: <20080317193415.GA12234@c2.user-mode-linux.org> (raw)
In-Reply-To: <87y78kx640.fsf_-_@hades.wkstn.nix>

Below is the same patch with another kluge, which cuts down the
requested sleep by 10% in hopes of getting the actual sleep closer to
what's wanted.

This is unusable in anything resembling mainline, but I'd like to see
how your various systems react to it.  I'm getting very close to the
sleeps I asked for (with slight undersleeping, which is a bug).

       	       	   Jeff

-- 
Work email - jdike at linux dot intel dot com

Index: linux-2.6.22/arch/um/os-Linux/time.c
===================================================================
--- linux-2.6.22.orig/arch/um/os-Linux/time.c	2008-02-18 11:53:51.000000000 -0500
+++ linux-2.6.22/arch/um/os-Linux/time.c	2008-03-17 15:11:51.000000000 -0400
@@ -58,12 +58,17 @@ static inline long long timeval_to_ns(co
 long long disable_timer(void)
 {
 	struct itimerval time = ((struct itimerval) { { 0, 0 }, { 0, 0 } });
+	int remain, max = UM_NSEC_PER_SEC / UM_HZ;
 
 	if (setitimer(ITIMER_VIRTUAL, &time, &time) < 0)
 		printk(UM_KERN_ERR "disable_timer - setitimer failed, "
 		       "errno = %d\n", errno);
 
-	return timeval_to_ns(&time.it_value);
+	remain = timeval_to_ns(&time.it_value);
+	if (remain > max)
+		remain = max;
+
+	return remain;
 }
 
 long long os_nsecs(void)
@@ -126,6 +131,8 @@ void idle_sleep(unsigned long long nsecs
 	 */
 	if (nsecs == 0)
 		nsecs = UM_NSEC_PER_SEC / UM_HZ;
+
+	nsecs = nsecs * 9 / 10;
 	ts = ((struct timespec) { .tv_sec	= nsecs / UM_NSEC_PER_SEC,
 				  .tv_nsec	= nsecs % UM_NSEC_PER_SEC });
 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

WARNING: multiple messages have this Message-ID (diff)
From: Jeff Dike <jdike@addtoit.com>
To: Nix <nix@esperi.org.uk>
Cc: clowncoder <vincent-perrier@club-internet.fr>,
	user-mode-linux-devel@lists.sourceforge.net,
	linux-kernel Mailing List <linux-kernel@vger.kernel.org>,
	Thomas Gleixner <tglx@timesys.com>
Subject: Re: [2.6.24.x] UML select()/poll() oversleeping reproducibly (was Re: [uml-devel] g_timeout_add)
Date: Mon, 17 Mar 2008 15:34:15 -0400	[thread overview]
Message-ID: <20080317193415.GA12234@c2.user-mode-linux.org> (raw)
In-Reply-To: <87y78kx640.fsf_-_@hades.wkstn.nix>

Below is the same patch with another kluge, which cuts down the
requested sleep by 10% in hopes of getting the actual sleep closer to
what's wanted.

This is unusable in anything resembling mainline, but I'd like to see
how your various systems react to it.  I'm getting very close to the
sleeps I asked for (with slight undersleeping, which is a bug).

       	       	   Jeff

-- 
Work email - jdike at linux dot intel dot com

Index: linux-2.6.22/arch/um/os-Linux/time.c
===================================================================
--- linux-2.6.22.orig/arch/um/os-Linux/time.c	2008-02-18 11:53:51.000000000 -0500
+++ linux-2.6.22/arch/um/os-Linux/time.c	2008-03-17 15:11:51.000000000 -0400
@@ -58,12 +58,17 @@ static inline long long timeval_to_ns(co
 long long disable_timer(void)
 {
 	struct itimerval time = ((struct itimerval) { { 0, 0 }, { 0, 0 } });
+	int remain, max = UM_NSEC_PER_SEC / UM_HZ;
 
 	if (setitimer(ITIMER_VIRTUAL, &time, &time) < 0)
 		printk(UM_KERN_ERR "disable_timer - setitimer failed, "
 		       "errno = %d\n", errno);
 
-	return timeval_to_ns(&time.it_value);
+	remain = timeval_to_ns(&time.it_value);
+	if (remain > max)
+		remain = max;
+
+	return remain;
 }
 
 long long os_nsecs(void)
@@ -126,6 +131,8 @@ void idle_sleep(unsigned long long nsecs
 	 */
 	if (nsecs == 0)
 		nsecs = UM_NSEC_PER_SEC / UM_HZ;
+
+	nsecs = nsecs * 9 / 10;
 	ts = ((struct timespec) { .tv_sec	= nsecs / UM_NSEC_PER_SEC,
 				  .tv_nsec	= nsecs % UM_NSEC_PER_SEC });
 

  parent reply	other threads:[~2008-03-17 19:34 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-13 19:57 [uml-devel] g_timeout_add clowncoder
2008-02-14  0:38 ` Jeff Dike
2008-02-14 22:16   ` clowncoder
2008-02-15 16:02     ` Jeff Dike
2008-02-15 17:39       ` clowncoder
2008-02-15 18:46         ` Jeff Dike
2008-03-14 23:01           ` [uml-devel] [2.6.24.x] UML select()/poll() oversleeping reproducibly (was Re: g_timeout_add) Nix
2008-03-14 23:01             ` [2.6.24.x] UML select()/poll() oversleeping reproducibly (was Re: [uml-devel] g_timeout_add) Nix
2008-03-17 16:27             ` [uml-devel] [2.6.24.x] UML select()/poll() oversleeping reproducibly (was g_timeout_add) Jeff Dike
2008-03-17 16:27               ` [2.6.24.x] UML select()/poll() oversleeping reproducibly (was Re: [uml-devel] g_timeout_add) Jeff Dike
2008-03-17 17:03             ` [uml-devel] [2.6.24.x] UML select()/poll() oversleeping reproducibly (was g_timeout_add) Jeff Dike
2008-03-17 17:03               ` [2.6.24.x] UML select()/poll() oversleeping reproducibly (was Re: [uml-devel] g_timeout_add) Jeff Dike
2008-03-17 19:34             ` Jeff Dike [this message]
2008-03-17 19:34               ` Jeff Dike
2008-03-17 21:08               ` [uml-devel] [2.6.24.x] UML select()/poll() oversleeping reproducibly Nix
2008-03-17 21:08                 ` Nix
2008-03-18 17:00                 ` [uml-devel] " Jeff Dike
2008-03-18 17:00                   ` Jeff Dike
2008-03-18 19:39                   ` [uml-devel] " Nix
2008-03-18 19:39                     ` Nix
2008-03-19 22:14                   ` [uml-devel] " Nix
2008-03-19 22:14                     ` Nix
2008-02-21 22:02   ` [uml-devel] Timeout in the select clowncoder

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=20080317193415.GA12234@c2.user-mode-linux.org \
    --to=jdike@addtoit.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nix@esperi.org.uk \
    --cc=tglx@timesys.com \
    --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 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.