* [PATCH] time: Introduce jiffies64_to_msecs()
@ 2019-02-27 9:38 Li RongQing
2019-02-27 11:18 ` Thomas Gleixner
0 siblings, 1 reply; 3+ messages in thread
From: Li RongQing @ 2019-02-27 9:38 UTC (permalink / raw)
To: netfilter-devel, linux-kernel, sboyd, tglx, john.stultz
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
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
include/linux/jiffies.h | 1 +
kernel/time/time.c | 10 ++++++++++
2 files changed, 11 insertions(+)
diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
index fa928242567d..1b6d31da7cbc 100644
--- a/include/linux/jiffies.h
+++ b/include/linux/jiffies.h
@@ -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)
diff --git a/kernel/time/time.c b/kernel/time/time.c
index 2edb5088a70b..0083eb711fb7 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -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
*
--
2.16.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] time: Introduce jiffies64_to_msecs()
2019-02-27 9:38 [PATCH] time: Introduce jiffies64_to_msecs() Li RongQing
@ 2019-02-27 11:18 ` Thomas Gleixner
2019-02-28 1:29 ` 答复: " Li,Rongqing
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Gleixner @ 2019-02-27 11:18 UTC (permalink / raw)
To: Li RongQing; +Cc: netfilter-devel, linux-kernel, sboyd, john.stultz
On Wed, 27 Feb 2019, Li RongQing wrote:
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* 答复: [PATCH] time: Introduce jiffies64_to_msecs()
2019-02-27 11:18 ` Thomas Gleixner
@ 2019-02-28 1:29 ` Li,Rongqing
0 siblings, 0 replies; 3+ messages in thread
From: Li,Rongqing @ 2019-02-28 1:29 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: netfilter-devel, linux-kernel, sboyd, john.stultz
> -----邮件原件-----
> 发件人: Thomas Gleixner [mailto:tglx@linutronix.de]
> 发送时间: 2019年2月27日 19:18
> 收件人: Li,Rongqing <lirongqing@baidu.com>
> 抄送: netfilter-devel@vger.kernel.org; linux-kernel@vger.kernel.org;
> sboyd@kernel.org; john.stultz@linaro.org
> 主题: Re: [PATCH] time: Introduce jiffies64_to_msecs()
>
> On Wed, 27 Feb 2019, Li RongQing wrote:
>
> > 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-02-28 1:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-27 9:38 [PATCH] time: Introduce jiffies64_to_msecs() Li RongQing
2019-02-27 11:18 ` Thomas Gleixner
2019-02-28 1:29 ` 答复: " Li,Rongqing
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).