All of lore.kernel.org
 help / color / mirror / Atom feed
* [KJ] [PATCH] 19/34: include/jiffies: add usecs_to_jiffies() function
@ 2005-01-25 23:37 Nishanth Aravamudan
  2005-01-26  2:51 ` [KJ] Re: [PATCH] 19/34: include/jiffies: add usecs_to_jiffies() Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: Nishanth Aravamudan @ 2005-01-25 23:37 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1171 bytes --]

Hi,

Please consider applying.

Description: Add a usecs_to_jiffies() function. This will be used in one of my
subsequent patches. With the potential for dynamic HZ values much higher than
1000, we may need to consider times as small as usecs in terms of jiffies.
We have msecs_to_jiffies(), jiffies_to_msecs() and jiffies_to_usecs(), but no
usecs_to_jiffies(). Please check my math.

Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>

--- 2.6.11-rc2-kj-v/include/linux/jiffies.h	2005-01-24 09:34:19.000000000 -0800
+++ 2.6.11-rc2-kj/include/linux/jiffies.h	2005-01-25 13:01:56.000000000 -0800
@@ -287,6 +287,19 @@ static inline unsigned long msecs_to_jif
 #endif
 }
 
+static inline unsigned long usecs_to_jiffies(const unsigned int u)
+{
+	if (u > jiffies_to_usecs(MAX_JIFFY_OFFSET))
+		return MAX_JIFFY_OFFSET;
+#if HZ <= 1000 && !(1000 % HZ)
+	return (u + (1000000 / HZ) - 1000) / (1000000 / HZ);
+#elif HZ > 1000 && !(HZ % 1000)
+	return u * (HZ / 1000000);
+#else
+	return (u * HZ + 999999) / 1000000;
+#endif
+}
+
 /*
  * The TICK_NSEC - 1 rounds up the value to the next resolution.  Note
  * that a remainder subtract here would not do the right thing as the

[-- Attachment #2: Type: text/plain, Size: 167 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* [KJ] Re: [PATCH] 19/34: include/jiffies: add usecs_to_jiffies()
@ 2005-01-26  2:51 ` Andrew Morton
  2005-01-26 17:36     ` [KJ] " Nishanth Aravamudan
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2005-01-26  2:51 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 193 bytes --]

Nishanth Aravamudan <nacc@us.ibm.com> wrote:
>
> Please consider applying.
> 
>  Description: Add a usecs_to_jiffies() function.

Please cc linux-kernel on things which aren't utterly trivial?

[-- Attachment #2: Type: text/plain, Size: 167 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* [PATCH 19/34]: include/jiffies: add usecs_to_jiffies() function
  2005-01-26  2:51 ` [KJ] Re: [PATCH] 19/34: include/jiffies: add usecs_to_jiffies() Andrew Morton
@ 2005-01-26 17:36     ` Nishanth Aravamudan
  0 siblings, 0 replies; 6+ messages in thread
From: Nishanth Aravamudan @ 2005-01-26 17:36 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, kernel-janitors

On Tue, Jan 25, 2005 at 06:51:00PM -0800, Andrew Morton wrote:
> Nishanth Aravamudan <nacc@us.ibm.com> wrote:
> >
> > Please consider applying.
> > 
> >  Description: Add a usecs_to_jiffies() function.
> 
> Please cc linux-kernel on things which aren't utterly trivial?

Sorry, Andrew, I actually meant to, but forgot to change the CC line. Sorry for
the noise directly to you.

-Nish

Description: Add a usecs_to_jiffies() function. This will be used in one of my
subsequent patches. With the potential for dynamic HZ values much higher than
1000, we may need to consider times as small as usecs in terms of jiffies.
We have msecs_to_jiffies(), jiffies_to_msecs() and jiffies_to_usecs(), but no
usecs_to_jiffies(). Please check my math.

Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>

--- 2.6.11-rc2-kj-v/include/linux/jiffies.h	2005-01-24 09:34:19.000000000 -0800
+++ 2.6.11-rc2-kj/include/linux/jiffies.h	2005-01-25 13:01:56.000000000 -0800
@@ -287,6 +287,19 @@ static inline unsigned long msecs_to_jif
 #endif
 }
 
+static inline unsigned long usecs_to_jiffies(const unsigned int u)
+{
+	if (u > jiffies_to_usecs(MAX_JIFFY_OFFSET))
+		return MAX_JIFFY_OFFSET;
+#if HZ <= 1000 && !(1000 % HZ)
+	return (u + (1000000 / HZ) - 1000) / (1000000 / HZ);
+#elif HZ > 1000 && !(HZ % 1000)
+	return u * (HZ / 1000000);
+#else
+	return (u * HZ + 999999) / 1000000;
+#endif
+}
+
 /*
  * The TICK_NSEC - 1 rounds up the value to the next resolution.  Note
  * that a remainder subtract here would not do the right thing as the

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

* [KJ] [PATCH 19/34]: include/jiffies: add usecs_to_jiffies() function
@ 2005-01-26 17:36     ` Nishanth Aravamudan
  0 siblings, 0 replies; 6+ messages in thread
From: Nishanth Aravamudan @ 2005-01-26 17:36 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1525 bytes --]

On Tue, Jan 25, 2005 at 06:51:00PM -0800, Andrew Morton wrote:
> Nishanth Aravamudan <nacc@us.ibm.com> wrote:
> >
> > Please consider applying.
> > 
> >  Description: Add a usecs_to_jiffies() function.
> 
> Please cc linux-kernel on things which aren't utterly trivial?

Sorry, Andrew, I actually meant to, but forgot to change the CC line. Sorry for
the noise directly to you.

-Nish

Description: Add a usecs_to_jiffies() function. This will be used in one of my
subsequent patches. With the potential for dynamic HZ values much higher than
1000, we may need to consider times as small as usecs in terms of jiffies.
We have msecs_to_jiffies(), jiffies_to_msecs() and jiffies_to_usecs(), but no
usecs_to_jiffies(). Please check my math.

Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>

--- 2.6.11-rc2-kj-v/include/linux/jiffies.h	2005-01-24 09:34:19.000000000 -0800
+++ 2.6.11-rc2-kj/include/linux/jiffies.h	2005-01-25 13:01:56.000000000 -0800
@@ -287,6 +287,19 @@ static inline unsigned long msecs_to_jif
 #endif
 }
 
+static inline unsigned long usecs_to_jiffies(const unsigned int u)
+{
+	if (u > jiffies_to_usecs(MAX_JIFFY_OFFSET))
+		return MAX_JIFFY_OFFSET;
+#if HZ <= 1000 && !(1000 % HZ)
+	return (u + (1000000 / HZ) - 1000) / (1000000 / HZ);
+#elif HZ > 1000 && !(HZ % 1000)
+	return u * (HZ / 1000000);
+#else
+	return (u * HZ + 999999) / 1000000;
+#endif
+}
+
 /*
  * The TICK_NSEC - 1 rounds up the value to the next resolution.  Note
  * that a remainder subtract here would not do the right thing as the

[-- Attachment #2: Type: text/plain, Size: 167 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* Re: [KJ] [PATCH 19/34]: include/jiffies: add usecs_to_jiffies()
  2005-01-26 17:36     ` [KJ] " Nishanth Aravamudan
  (?)
@ 2005-01-26 17:55     ` walter harms
  -1 siblings, 0 replies; 6+ messages in thread
From: walter harms @ 2005-01-26 17:55 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1195 bytes --]


hi Nish,
do we need jiffies_to_msecs() at all ?

milli is 10E-3   micro is 10E-6
i would say:
#define jiffies_to_msecs(VAL) jiffies_to_usecs(1000*VAL)

I have no idea about the range of VAL but uint is ~ 1E9.
is anyone using something like 1E6 ms = 1E3s to wait ?
if not we kan simply drop jiffies_to_msecs() (and back).

re,
   walter




Nishanth Aravamudan wrote:
> On Tue, Jan 25, 2005 at 06:51:00PM -0800, Andrew Morton wrote:
> 
>>Nishanth Aravamudan <nacc@us.ibm.com> wrote:
>>
>>>Please consider applying.
>>>
>>> Description: Add a usecs_to_jiffies() function.
>>
>>Please cc linux-kernel on things which aren't utterly trivial?
> 
> 
> Sorry, Andrew, I actually meant to, but forgot to change the CC line. Sorry for
> the noise directly to you.
> 
> -Nish
> 
> Description: Add a usecs_to_jiffies() function. This will be used in one of my
> subsequent patches. With the potential for dynamic HZ values much higher than
> 1000, we may need to consider times as small as usecs in terms of jiffies.
> We have msecs_to_jiffies(), jiffies_to_msecs() and jiffies_to_usecs(), but no
> usecs_to_jiffies(). Please check my math.
> 
> Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
> 
>

[-- Attachment #2: Type: text/plain, Size: 167 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* Re: [KJ] [PATCH 19/34]: include/jiffies: add usecs_to_jiffies()
  2005-01-26 17:36     ` [KJ] " Nishanth Aravamudan
  (?)
  (?)
@ 2005-01-26 18:04     ` Nish Aravamudan
  -1 siblings, 0 replies; 6+ messages in thread
From: Nish Aravamudan @ 2005-01-26 18:04 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 745 bytes --]

On Wed, 26 Jan 2005 18:55:51 +0100, walter harms <wharms@bfs.de> wrote:
> 
> hi Nish,
> do we need jiffies_to_msecs() at all ?
> 
> milli is 10E-3   micro is 10E-6
> i would say:
> #define jiffies_to_msecs(VAL) jiffies_to_usecs(1000*VAL)

I am not sure that would work as expected. It would be better to:

#define jiffies_to_msecs(VAL) (jiffies_to_usecs(VAL) / 1000)
#define msecs_to_jiffies(VAL) (usecs_to_jiffies(VAL * 1000))
 
> I have no idea about the range of VAL but uint is ~ 1E9.
> is anyone using something like 1E6 ms = 1E3s to wait ?
> if not we kan simply drop jiffies_to_msecs() (and back).

I would rather see the macro get pushed in and then deal with
optimizing code :) One little tiny itty-bit step at a time, Walter ;)

-Nish

[-- Attachment #2: Type: text/plain, Size: 167 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors

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

end of thread, other threads:[~2005-01-27  2:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-25 23:37 [KJ] [PATCH] 19/34: include/jiffies: add usecs_to_jiffies() function Nishanth Aravamudan
2005-01-26  2:51 ` [KJ] Re: [PATCH] 19/34: include/jiffies: add usecs_to_jiffies() Andrew Morton
2005-01-26 17:36   ` [PATCH 19/34]: include/jiffies: add usecs_to_jiffies() function Nishanth Aravamudan
2005-01-26 17:36     ` [KJ] " Nishanth Aravamudan
2005-01-26 17:55     ` [KJ] [PATCH 19/34]: include/jiffies: add usecs_to_jiffies() walter harms
2005-01-26 18:04     ` Nish Aravamudan

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.