linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* kernel/timer.c
@ 2003-04-11 13:17 Wojciech Kromer
  2003-04-11 14:38 ` kernel/timer.c Joakim Tjernlund
  0 siblings, 1 reply; 8+ messages in thread
From: Wojciech Kromer @ 2003-04-11 13:17 UTC (permalink / raw)
  To: Linuxppc-Embedded (E-mail)


Anyone knows why tehere is a line:

expire = timespec_to_jiffies(&t) + (t.tv_sec || t.tv_nsec);

in kernel/timer.c sys_nanosleep
It adds additional time tick to expire. If anyone uses small HZ value
(eg 100 which is default for arch-ppc) this causes aditional 10ms delay
when calling nanosleep.


For me ( found by Andrzej Kass)
 it should be:

expire = timespec_to_jiffies(&t) + !(t.tv_sec || t.tv_nsec);
   //^^add extra tick if there is
  // nothing in tv_sec and nothing in tv_nsec


--
* * * * * * * * * * * *
* per pedes ad astra! *
* * * * * * * * * * * *    mailto:krom@dgt-lab.com.pl


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: kernel/timer.c
  2003-04-11 13:17 kernel/timer.c Wojciech Kromer
@ 2003-04-11 14:38 ` Joakim Tjernlund
  2003-04-12  7:07   ` kernel/timer.c Wojciech Kromer
  0 siblings, 1 reply; 8+ messages in thread
From: Joakim Tjernlund @ 2003-04-11 14:38 UTC (permalink / raw)
  To: Wojciech Kromer, Linuxppc-Embedded (E-mail)


> Anyone knows why tehere is a line:
>
> expire = timespec_to_jiffies(&t) + (t.tv_sec || t.tv_nsec);
>
> in kernel/timer.c sys_nanosleep
> It adds additional time tick to expire. If anyone uses small HZ value
> (eg 100 which is default for arch-ppc) this causes aditional 10ms delay
> when calling nanosleep.

Yes, after a quick scan it looks like a bug to me. Anyone else?

>
>
> For me ( found by Andrzej Kass)
>  it should be:
>
> expire = timespec_to_jiffies(&t) + !(t.tv_sec || t.tv_nsec);
>    //^^add extra tick if there is
>   // nothing in tv_sec and nothing in tv_nsec

hmm, why not just:
   expire = timespec_to_jiffies(&t);
if tv_sec and tv_sec are zero, do you need to sleep at all?

    Jocke


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: kernel/timer.c
@ 2003-04-11 21:25 Darin.Johnson
  0 siblings, 0 replies; 8+ messages in thread
From: Darin.Johnson @ 2003-04-11 21:25 UTC (permalink / raw)
  To: linuxppc-embedded


> From: ext Joakim Tjernlund [mailto:joakim.tjernlund@lumentis.se]
> Sent: Friday, April 11, 2003 7:39 AM
>
> hmm, why not just:
>    expire = timespec_to_jiffies(&t);
> if tv_sec and tv_sec are zero, do you need to sleep at all?

Trying to sleep for 0 time periods is difficult in many timer systems,
and this is probably true for Linux also. Ie, time "t" has already
passed by the time this routine is executed, but time "t+1" has not.

The decision is whether to make the delay 1 in this case, or to just
schedule the next ready thread.

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: kernel/timer.c
  2003-04-11 14:38 ` kernel/timer.c Joakim Tjernlund
@ 2003-04-12  7:07   ` Wojciech Kromer
  2003-04-12  8:29     ` kernel/timer.c Joakim Tjernlund
  0 siblings, 1 reply; 8+ messages in thread
From: Wojciech Kromer @ 2003-04-12  7:07 UTC (permalink / raw)
  To: Linuxppc-Embedded (E-mail)


>
>
>hmm, why not just:
>   expire = timespec_to_jiffies(&t);
>if tv_sec and tv_sec are zero, do you need to sleep at all?
>
>    Jocke
>
>
sleep(0) could be defined as:
-schedule to next task if there is any (just call schedule() )
-sleep minimum value (1 jiffie)

default kernel (no timer patches) uses second definition,

there is  special call schedule_timeout(MAX_SCHEDULE_TIMEOUT) which also
calls schedule()




--
* * * * * * * * * * * *
* per pedes ad astra! *
* * * * * * * * * * * *    mailto:krom@dgt-lab.com.pl


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: kernel/timer.c
  2003-04-12  7:07   ` kernel/timer.c Wojciech Kromer
@ 2003-04-12  8:29     ` Joakim Tjernlund
  2003-04-12  9:32       ` kernel/timer.c Wojciech Kromer
  0 siblings, 1 reply; 8+ messages in thread
From: Joakim Tjernlund @ 2003-04-12  8:29 UTC (permalink / raw)
  To: Wojciech Kromer, Linuxppc-Embedded (E-mail), Darin.Johnson


> >hmm, why not just:
> >   expire = timespec_to_jiffies(&t);
> >if tv_sec and tv_sec are zero, do you need to sleep at all?
> >
> >    Jocke
> >
> >
> sleep(0) could be defined as:
> -schedule to next task if there is any (just call schedule() )
> -sleep minimum value (1 jiffie)
>
> default kernel (no timer patches) uses second definition,

No, linux uses the first definition(or whatever schedule_timeout(0) does).
If t is zero then expire also becomes zero.

>
> there is  special call schedule_timeout(MAX_SCHEDULE_TIMEOUT) which also
> calls schedule()
?


  Jocke

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: kernel/timer.c
  2003-04-12  8:29     ` kernel/timer.c Joakim Tjernlund
@ 2003-04-12  9:32       ` Wojciech Kromer
  2003-04-12 10:35         ` kernel/timer.c Joakim Tjernlund
  0 siblings, 1 reply; 8+ messages in thread
From: Wojciech Kromer @ 2003-04-12  9:32 UTC (permalink / raw)
  To: Linuxppc-Embedded (E-mail)


>
>
>>sleep(0) could be defined as:
>>-schedule to next task if there is any (just call schedule() )
>>-sleep minimum value (1 jiffie)
>>
>>default kernel (no timer patches) uses second definition,
>>
>>
>
>No, linux uses the first definition(or whatever schedule_timeout(0) does).
>If t is zero then expire also becomes zero.
>
>
maybe, my  missunderstood

>>there is  special call schedule_timeout(MAX_SCHEDULE_TIMEOUT) which also
>>calls schedule()
>>
>>
see kernel/sched.c



so, anyone knows what linus.t says about adding one jiffie  to every
non-zero expire?

--
* * * * * * * * * * * *
* per pedes ad astra! *
* * * * * * * * * * * *    mailto:krom@dgt-lab.com.pl


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: kernel/timer.c
  2003-04-12  9:32       ` kernel/timer.c Wojciech Kromer
@ 2003-04-12 10:35         ` Joakim Tjernlund
  2003-04-12 12:52           ` kernel/timer.c Joakim Tjernlund
  0 siblings, 1 reply; 8+ messages in thread
From: Joakim Tjernlund @ 2003-04-12 10:35 UTC (permalink / raw)
  To: Wojciech Kromer, Linuxppc-Embedded (E-mail)


> >>sleep(0) could be defined as:
> >>-schedule to next task if there is any (just call schedule() )
> >>-sleep minimum value (1 jiffie)
> >>
> >>default kernel (no timer patches) uses second definition,
> >>
> >>
> >
> >No, linux uses the first definition(or whatever schedule_timeout(0) does).
> >If t is zero then expire also becomes zero.
> >
> >
> maybe, my  missunderstood
>
> so, anyone knows what linus.t says about adding one jiffie  to every
> non-zero expire?

I think this is a bug. It should be enough to round up to nearest jiffie.
Ask on the linux kernel list.

 Jocke

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: kernel/timer.c
  2003-04-12 10:35         ` kernel/timer.c Joakim Tjernlund
@ 2003-04-12 12:52           ` Joakim Tjernlund
  0 siblings, 0 replies; 8+ messages in thread
From: Joakim Tjernlund @ 2003-04-12 12:52 UTC (permalink / raw)
  To: Joakim Tjernlund, Wojciech Kromer, Linuxppc-Embedded (E-mail)


> > so, anyone knows what linus.t says about adding one jiffie  to every
> > non-zero expire?
>
> I think this is a bug. It should be enough to round up to nearest jiffie.
> Ask on the linux kernel list.
>
>  Jocke

Actually, I take that back. It's not a bug. schedule_timeout(x), x > 0 will wait
somewere between x-1 and x jiffies. Therefore one must add an extra
jiffie to make sure that you don't return too early.

     Jocke

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2003-04-12 12:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-04-11 13:17 kernel/timer.c Wojciech Kromer
2003-04-11 14:38 ` kernel/timer.c Joakim Tjernlund
2003-04-12  7:07   ` kernel/timer.c Wojciech Kromer
2003-04-12  8:29     ` kernel/timer.c Joakim Tjernlund
2003-04-12  9:32       ` kernel/timer.c Wojciech Kromer
2003-04-12 10:35         ` kernel/timer.c Joakim Tjernlund
2003-04-12 12:52           ` kernel/timer.c Joakim Tjernlund
  -- strict thread matches above, loose matches on Subject: below --
2003-04-11 21:25 kernel/timer.c Darin.Johnson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).