All of lore.kernel.org
 help / color / mirror / Atom feed
* [timer] max timeout
@ 2001-05-23 14:28 sebastien person
  2001-05-23 14:38 ` Andi Kleen
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: sebastien person @ 2001-05-23 14:28 UTC (permalink / raw)
  To: liste noyau linux

Hi,

is there a max timeout to respect when I use mod_timer ? or add_timer ?

Is it bad to do the following call ?

	mod_timer(&timer, jiffies+(0.1*HZ));

that might fire the timer 1/10 second later.

Thanks.

sebastien person

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

* Re: [timer] max timeout
  2001-05-23 14:28 [timer] max timeout sebastien person
@ 2001-05-23 14:38 ` Andi Kleen
  2001-05-23 14:58 ` Andrzej Krzysztofowicz
  2001-05-25 20:58 ` george anzinger
  2 siblings, 0 replies; 7+ messages in thread
From: Andi Kleen @ 2001-05-23 14:38 UTC (permalink / raw)
  To: sebastien person; +Cc: liste noyau linux

On Wed, May 23, 2001 at 04:28:01PM +0200, sebastien person wrote:
> Is it bad to do the following call ?
> 
> 	mod_timer(&timer, jiffies+(0.1*HZ));

Yes very bad. gcc will generate a floating point add for that, corrupting
the user process' floating point context. 


-Andi


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

* Re: [timer] max timeout
  2001-05-23 14:28 [timer] max timeout sebastien person
  2001-05-23 14:38 ` Andi Kleen
@ 2001-05-23 14:58 ` Andrzej Krzysztofowicz
  2001-05-25  8:24   ` sebastien person
  2001-05-25 20:58 ` george anzinger
  2 siblings, 1 reply; 7+ messages in thread
From: Andrzej Krzysztofowicz @ 2001-05-23 14:58 UTC (permalink / raw)
  To: sebastien person; +Cc: liste noyau linux

"sebastien person wrote:"
> Is it bad to do the following call ?
> 
> 	mod_timer(&timer, jiffies+(0.1*HZ));

Yes, it is bad. Don't use floating point in the kernel if you don't need.

> that might fire the timer 1/10 second later.

HZ/10 is much better ...

-- 
=======================================================================
  Andrzej M. Krzysztofowicz               ankry@mif.pg.gda.pl
  phone (48)(58) 347 14 61
Faculty of Applied Phys. & Math.,   Technical University of Gdansk

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

* Re: [timer] max timeout
  2001-05-23 14:58 ` Andrzej Krzysztofowicz
@ 2001-05-25  8:24   ` sebastien person
  0 siblings, 0 replies; 7+ messages in thread
From: sebastien person @ 2001-05-25  8:24 UTC (permalink / raw)
  To: ankry, liste noyau linux

Le Wed, 23 May 2001 16:58:15 +0200 (MET DST)
Andrzej Krzysztofowicz <ankry@pg.gda.pl> a ecrit :

> "sebastien person wrote:"
> > Is it bad to do the following call ?
> > 
> > 	mod_timer(&timer, jiffies+(0.1*HZ));
> 
> Yes, it is bad. Don't use floating point in the kernel if you don't
need.

So, there is a good solution to fire the timer after 100 ms ?
And is there any max limitation on the expires value ?

e.g. what is the biggest time period we could have between timer call and
the execution of the timer function ?



> 
> > that might fire the timer 1/10 second later.
> 
> HZ/10 is much better ...
> 
> -- 
> =======================================================================
>   Andrzej M. Krzysztofowicz               ankry@mif.pg.gda.pl
>   phone (48)(58) 347 14 61
> Faculty of Applied Phys. & Math.,   Technical University of Gdansk
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel"
in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [timer] max timeout
  2001-05-23 14:28 [timer] max timeout sebastien person
  2001-05-23 14:38 ` Andi Kleen
  2001-05-23 14:58 ` Andrzej Krzysztofowicz
@ 2001-05-25 20:58 ` george anzinger
  2001-05-25 21:26   ` Mark Frazer
  2 siblings, 1 reply; 7+ messages in thread
From: george anzinger @ 2001-05-25 20:58 UTC (permalink / raw)
  To: sebastien person; +Cc: liste noyau linux

sebastien person wrote:
> 
> Hi,
> 
> is there a max timeout to respect when I use mod_timer ? or add_timer ?
> 
> Is it bad to do the following call ?
> 
>         mod_timer(&timer, jiffies+(0.1*HZ));
> 
> that might fire the timer 1/10 second later.
> 
> Thanks.
> 
More than enough on the fp.  Now the other question.  

The time value is in jiffies (aka 1/Hz sec.).  The max value (in a 32
bit system) is 0x7ffffff.  This value is added to the current value of
jiffies to get the the absolute timer expire time.  While the value is
unsigned (and thus you could go higher) the compare code (timer_before()
and timer_after()) depend on the subtraction (of jiffies from expire) to
be of the correct sign.  To insure this you must keep the timeout values
sign clear (or if you don't like to think of an unsigned as having a
sign, then the highest order bit must be zero).

George

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

* Re: [timer] max timeout
  2001-05-25 20:58 ` george anzinger
@ 2001-05-25 21:26   ` Mark Frazer
  2001-05-25 21:45     ` Horst von Brand
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Frazer @ 2001-05-25 21:26 UTC (permalink / raw)
  To: liste noyau linux

george anzinger <george@mvista.com> [01/05/25 17:04]:
> More than enough on the fp.  Now the other question.  
> 
> The time value is in jiffies (aka 1/Hz sec.).  The max value (in a 32
> bit system) is 0x7ffffff.  This value is added to the current value of
> jiffies to get the the absolute timer expire time.  While the value is
> unsigned (and thus you could go higher) the compare code (timer_before()
> and timer_after()) depend on the subtraction (of jiffies from expire) to
> be of the correct sign.  To insure this you must keep the timeout values
> sign clear (or if you don't like to think of an unsigned as having a
> sign, then the highest order bit must be zero).
> 
> George

The output of `find . -type f | xargs grep 'jiffies +'` would suggest
that there are a few latent bugs as jiffies grows to values near the
top of its range.  I guess this hasn't turned up as 0x7fffffff / (100 *
3600 * 24) = 248.55.



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

* Re: [timer] max timeout
  2001-05-25 21:26   ` Mark Frazer
@ 2001-05-25 21:45     ` Horst von Brand
  0 siblings, 0 replies; 7+ messages in thread
From: Horst von Brand @ 2001-05-25 21:45 UTC (permalink / raw)
  To: Mark Frazer; +Cc: linux-kernel

Mark Frazer <mark@somanetworks.com> said:

[...]

> The output of `find . -type f | xargs grep 'jiffies +'` would suggest
> that there are a few latent bugs as jiffies grows to values near the
> top of its range.  I guess this hasn't turned up as 0x7fffffff / (100 *
> 3600 * 24) = 248.55.

There were patches floating around a _long_ time ago (2.1-ish AFAIR) that
allowed you to start your system at any jiffy. Many people checked out what
happens on jiffie rollover then. Might be a good idea to do that again...
-- 
Dr. Horst H. von Brand                       mailto:vonbrand@inf.utfsm.cl
Departamento de Informatica                     Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria              +56 32 654239
Casilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513

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

end of thread, other threads:[~2001-05-25 21:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-05-23 14:28 [timer] max timeout sebastien person
2001-05-23 14:38 ` Andi Kleen
2001-05-23 14:58 ` Andrzej Krzysztofowicz
2001-05-25  8:24   ` sebastien person
2001-05-25 20:58 ` george anzinger
2001-05-25 21:26   ` Mark Frazer
2001-05-25 21:45     ` Horst von Brand

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.