time: Introduce jiffies64_to_msecs()
Subsystems (2)
PATCH 1/1 time: Introduce jiffies64_to_msecs()
there is a similar helper in net/netfilter/nf_tables_api.c, this maybe become a common request someday.
and avoid to call div_64 at some condition
--- include/linux/jiffies.h | 1 + kernel/time/time.c | 10 ++++++++++ 2 files changed, 11 insertions(+)
include/linux/jiffies.h +1 -0
@@ -297,6 +297,7 @@ static inline u64 jiffies_to_nsecs(const unsigned long j) }extern u64 jiffies64_to_nsecs (u64 j); +extern u64 jiffies64_to_msecs (u64 j);extern unsigned long __msecs_to_jiffies (const unsigned int m);#if HZ <=MSEC_PER_SEC && !(MSEC_PER_SEC %HZ )
kernel/time/time.c +10 -0
@@ -719,6 +719,16 @@ u64 jiffies64_to_nsecs(u64 j) }EXPORT_SYMBOL (jiffies64_to_nsecs); +u64 jiffies64_to_msecs (const u64 j) +{ +#if HZ <=MSEC_PER_SEC && !(MSEC_PER_SEC %HZ ) +return (MSEC_PER_SEC /HZ ) * j; +#else +return div_u64 (j *HZ_TO_MSEC_NUM ,HZ_TO_MSEC_DEN ); +#endif +} +EXPORT_SYMBOL (jiffies64_to_msecs); +/** * nsecs_to_jiffies64 - Convert nsecs in u64 to jiffies64 *
Signature · 1 line
2.16.2
Quoted 2 lines · Li RongQing
there is a similar helper in
net/netfilter/nf_tables_api.c, this maybe become a common request someday.
Maybe is not a really good justification for adding that. At least you should provide a patch which replaces the instance in the netfilter code.
Thanks,
tglx
Quoted 12 lines
-----邮件原件-----
发件人: Thomas Gleixner [mailto:[email protected]]
发送时间: 2019年2月27日 19:18
收件人: Li,Rongqing <[email protected]>
抄送: [email protected]; [email protected]; [email protected]; [email protected]
主题: Re: [PATCH] time: Introducejiffies64_to_msecs()On Wed, 27 Feb 2019, Li RongQing wrote:
Quoted 8 lines
Quoted 2 lines
there is a similar helper in
net/netfilter/nf_tables_api.c, this maybe become a common request someday.Maybe is not a really good justification for adding that. At least you should provide a patch which replaces the instance in the netfilter code.
Thanks,
OK, I will send V2
Thanks
-rongqing