19/34: include/jiffies: add usecs_to_jiffies() function
PATCH 1/1 19/34: include/jiffies: add usecs_to_jiffies() function
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.
include/linux/jiffies.h +13 -0
@@ -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
_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors
[KJ] Re: [PATCH] 19/34: include/jiffies: add usecs_to_jiffies()
Quoted 4 lines · Nishanth Aravamudan
Please consider applying.
Description: Add a
usecs_to_jiffies()function.
Please cc linux-kernel on things which aren't utterly trivial?
_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 19/34 : include/jiffies: add usecs_to_jiffies() function
Quoted 7 lines · Andrew Morton
Quoted 4 lines · Nishanth Aravamudan
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.
include/linux/jiffies.h +13 -0
@@ -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
_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors
Re: [KJ] [PATCH 19/34]: include/jiffies: add usecs_to_jiffies()
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
Quoted 16 lines · Nishanth Aravamudan
Quoted 7 lines · Andrew Morton
Quoted 3 lines · Nishanth Aravamudan
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
Quoted 9 lines
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 havemsecs_to_jiffies(),jiffies_to_msecs()andjiffies_to_usecs(), but nousecs_to_jiffies(). Please check my math.Signed-off-by Nishanth Aravamudan <[email protected]>
_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors
Re: [KJ] [PATCH 19/34]: include/jiffies: add usecs_to_jiffies()
In reply to Nishanth AravamudanQuoted 7 lines · walter harms
hi Nish,
do we needjiffies_to_msecs()at all ?milli is 10E-3 micro is 10E-6
i would say:
#definejiffies_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))
Quoted 3 lines
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
_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors