public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Nishanth Aravamudan <nacc@us.ibm.com>
To: john stultz <johnstul@us.ibm.com>
Cc: lkml <linux-kernel@vger.kernel.org>,
	albert@users.sourceforge.net, paulus@samba.org,
	schwidefsky@de.ibm.com, mahuja@us.ibm.com, donf@us.ibm.com,
	mpm@selenic.com, benh@kernel.crashing.org
Subject: Re: [RFC][PATCH] new timeofday-based soft-timer subsystem
Date: Tue, 3 May 2005 14:47:07 -0700	[thread overview]
Message-ID: <20050503214707.GE3372@us.ibm.com> (raw)
In-Reply-To: <20050503170224.GA2776@us.ibm.com>

On 03.05.2005 [10:02:24 -0700], Nishanth Aravamudan wrote:
> On 29.04.2005 [16:35:46 -0700], Nishanth Aravamudan wrote:
> > * john stultz <johnstul@us.ibm.com> [2005-0429 15:45:47 -0700]:
> > 
> > > All,
> > >         This patch implements the architecture independent portion of
> > > the time of day subsystem. For a brief description on the rework, see
> > > here: http://lwn.net/Articles/120850/ (Many thanks to the LWN team for
> > > that clear writeup!)
> > 
> > I have been working closely with John to re-work the soft-timer subsytem
> > to use the new timeofday() subsystem. The following patch attempts to
> > being this process. I would greatly appreciate any comments.
> 
> I am not sure if anyone has looked at this patch closely, but I have
> noticed one issue: My code assumes that all the rounding will be done
> internally (rounding up on addition to find to the nearest
> timerinterval); however, current interfaces do much of the rounding
> before passing on structures on to the soft-timer subsystem, because the
> jiffies-based one always rounds down.

A for instance: sys_nanosleep() assumes (correctly) that the
jiffies-based soft-timer subsystem rounds down, so it rounds up (twice).
But since I now round-up internally, that is not necessary. Fix
sys_nanosleep() to do this right.

Still todo: change restart->arg0 to be a pointer to an nsec_t.

diff -urpN 2.6.12-rc2-tod/kernel/timer.c 2.6.12-rc2-tod-timer/kernel/timer.c
--- 2.6.12-rc2-tod/kernel/timer.c	2005-05-02 12:59:04.000000000 -0700
+++ 2.6.12-rc2-tod-timer/kernel/timer.c	2005-05-03 09:13:43.000000000 -0700
@@ -1141,21 +1311,21 @@ asmlinkage long sys_gettid(void)
 
 static long __sched nanosleep_restart(struct restart_block *restart)
 {
-	unsigned long expire = restart->arg0, now = jiffies;
+	nsec_t expire = restart->arg0, now = do_monotonic_clock();
 	struct timespec __user *rmtp = (struct timespec __user *) restart->arg1;
 	long ret;
 
 	/* Did it expire while we handled signals? */
-	if (!time_after(expire, now))
+	if (now > expire)
 		return 0;
 
-	current->state = TASK_INTERRUPTIBLE;
-	expire = schedule_timeout(expire - now);
+	set_current_state(TASK_INTERRUPTIBLE);
+	expire = schedule_timeout_nsecs(expire - now);
 
 	ret = 0;
 	if (expire) {
 		struct timespec t;
-		jiffies_to_timespec(expire, &t);
+		t = ns2timespec(expire);
 
 		ret = -ERESTART_RESTARTBLOCK;
 		if (rmtp && copy_to_user(rmtp, &t, sizeof(t)))
@@ -1168,7 +1338,7 @@ static long __sched nanosleep_restart(st
 asmlinkage long sys_nanosleep(struct timespec __user *rqtp, struct timespec __user *rmtp)
 {
 	struct timespec t;
-	unsigned long expire;
+	nsec_t expire;
 	long ret;
 
 	if (copy_from_user(&t, rqtp, sizeof(t)))
@@ -1177,20 +1347,20 @@ asmlinkage long sys_nanosleep(struct tim
 	if ((t.tv_nsec >= 1000000000L) || (t.tv_nsec < 0) || (t.tv_sec < 0))
 		return -EINVAL;
 
-	expire = timespec_to_jiffies(&t) + (t.tv_sec || t.tv_nsec);
-	current->state = TASK_INTERRUPTIBLE;
-	expire = schedule_timeout(expire);
+	expire = timespec2ns(&t);
+	set_current_state(TASK_INTERRUPTIBLE);
+	expire = schedule_timeout_nsecs(expire);
 
 	ret = 0;
 	if (expire) {
 		struct restart_block *restart;
-		jiffies_to_timespec(expire, &t);
+		t = ns2timespec(expire);
 		if (rmtp && copy_to_user(rmtp, &t, sizeof(t)))
 			return -EFAULT;
 
 		restart = &current_thread_info()->restart_block;
 		restart->fn = nanosleep_restart;
-		restart->arg0 = jiffies + expire;
+		restart->arg0 = do_monotonic_clock() + expire;
 		restart->arg1 = (unsigned long) rmtp;
 		ret = -ERESTART_RESTARTBLOCK;
 	}



  parent reply	other threads:[~2005-05-03 21:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-29 22:45 [RFC][PATCH (1/4)] new timeofday core subsystem (v A4) john stultz
2005-04-29 22:46 ` [RFC][PATCH (2/4)] new timeofday arch specific hooks " john stultz
2005-04-29 22:47   ` [RFC][PATCH (3/4)] new timeofday arch specific timesource drivers " john stultz
2005-04-29 22:48     ` [RFC][PATCH (4/4)] new timeofday vsyscall proof of concept " john stultz
2005-05-02 21:13   ` [RFC][PATCH (2/4)] new timeofday arch specific hooks " Pavel Machek
2005-05-02 21:28     ` john stultz
2005-04-29 23:35 ` [RFC][PATCH] new timeofday-based soft-timer subsystem Nishanth Aravamudan
2005-05-02 18:41   ` Darren Hart
2005-05-03 17:02   ` Nishanth Aravamudan
2005-05-03 17:22     ` Chris Friesen
2005-05-03 18:07       ` Nish Aravamudan
2005-05-03 21:47     ` Nishanth Aravamudan [this message]
2005-04-29 23:44 ` [RFC][PATCH (1/4)] new timeofday core subsystem (v A4) john stultz
2005-04-29 23:50 ` Benjamin Herrenschmidt
2005-04-30  0:33   ` john stultz

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=20050503214707.GE3372@us.ibm.com \
    --to=nacc@us.ibm.com \
    --cc=albert@users.sourceforge.net \
    --cc=benh@kernel.crashing.org \
    --cc=donf@us.ibm.com \
    --cc=johnstul@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mahuja@us.ibm.com \
    --cc=mpm@selenic.com \
    --cc=paulus@samba.org \
    --cc=schwidefsky@de.ibm.com \
    /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