[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LFD.2.00.1009081143200.2477@localhost6.localdomain6>
Date: Wed, 8 Sep 2010 11:51:13 +0200 (CEST)
From: Thomas Gleixner <tglx@...utronix.de>
To: Joakim Tjernlund <joakim.tjernlund@...nsmode.se>
cc: Eric Dumazet <eric.dumazet@...il.com>, linux-kernel@...r.kernel.org
Subject: Re: slow nanosleep?
On Wed, 8 Sep 2010, Joakim Tjernlund wrote:
> Eric Dumazet <eric.dumazet@...il.com> wrote on 2010/09/08 10:24:49:
> >
> > Le mercredi 08 septembre 2010 à 10:04 +0200, Joakim Tjernlund a écrit :
> >
> > > That makes litte difference:
> > > root@...alhost ~ # ./nanosleep
> > > nanosleep
> > > req:0 :0
> > > tv_res:0 :112
> > >
> >
> > Here, result is 30 (with prctl())
> > instead of 95 (without)
>
> On x86 I notice a difference:
> 7 vs 57.
> however select is still faster: 2
> The system call OH seems to be bigger for nanosleep than
> for select and on my ppc is is about 112 us. Can anything
> be done about that?
Hmm, the only reason I can see is that select calls finally
schedule_hrtimeout_range_clock() which optimizes the expiry = 0 case
while nanosleep does not. So the difference is only visiable when the
relative timeout is 0. For timeouts > 0 nanosleep and select should
behave the same way.
Thanks,
tglx
---
kernel/hrtimer.c | 3 +++
1 file changed, 3 insertions(+)
Index: linux-2.6/kernel/hrtimer.c
===================================================================
--- linux-2.6.orig/kernel/hrtimer.c
+++ linux-2.6/kernel/hrtimer.c
@@ -1609,6 +1609,9 @@ SYSCALL_DEFINE2(nanosleep, struct timesp
if (!timespec_valid(&tu))
return -EINVAL;
+ if (!tu.tv_sec && !tu.tv_usec)
+ return 0;
+
return hrtimer_nanosleep(&tu, rmtp, HRTIMER_MODE_REL, CLOCK_MONOTONIC);
}
Powered by blists - more mailing lists