From: Pablo Neira Ayuso <pablo@netfilter.org>
To: tglx@linutronix.de
Cc: Li RongQing <lirongqing@baidu.com>,
netfilter-devel@vger.kernel.org, linux-kernel@vger.kernel.org,
sboyd@kernel.org, john.stultz@linaro.org
Subject: Re: [PATCH][v2] time: Introduce jiffies64_to_msecs()
Date: Fri, 8 Mar 2019 16:55:43 +0100 [thread overview]
Message-ID: <20190308155543.si2nqqm6j2otq27r@salvia> (raw)
In-Reply-To: <1551330806-12502-1-git-send-email-lirongqing@baidu.com>
On Thu, Feb 28, 2019 at 01:13:26PM +0800, Li RongQing wrote:
> there is a similar helper in net/netfilter/nf_tables_api.c,
> this maybe become a common request someday, so move it to
> time.c
>
> Signed-off-by: Zhang Yu <zhangyu31@baidu.com>
> Signed-off-by: Li RongQing <lirongqing@baidu.com>
Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
This is touching kernel/time.c bits, which is far from my realm.
What should I do with this? I can just place it in nf-next.git if I
get an ACK to do so. Otherwise, please just take this if this looks
good to you.
Thanks!
> ---
> v1-->v2: using jiffies64_to_msecs in nf_tables_api.c
>
> include/linux/jiffies.h | 1 +
> kernel/time/time.c | 10 ++++++++++
> net/netfilter/nf_tables_api.c | 4 +---
> 3 files changed, 12 insertions(+), 3 deletions(-)
>
> 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
> *
> diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
> index e1a88ba2249e..8763b2798788 100644
> --- a/net/netfilter/nf_tables_api.c
> +++ b/net/netfilter/nf_tables_api.c
> @@ -3184,9 +3184,7 @@ static int nf_msecs_to_jiffies64(const struct nlattr *nla, u64 *result)
>
> static __be64 nf_jiffies64_to_msecs(u64 input)
> {
> - u64 ms = jiffies64_to_nsecs(input);
> -
> - return cpu_to_be64(div_u64(ms, NSEC_PER_MSEC));
> + return cpu_to_be64(jiffies64_to_msecs(input));
> }
>
> static int nf_tables_fill_set(struct sk_buff *skb, const struct nft_ctx *ctx,
> --
> 2.16.2
>
next prev parent reply other threads:[~2019-03-08 15:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-28 5:13 [PATCH][v2] time: Introduce jiffies64_to_msecs() Li RongQing
2019-03-08 15:55 ` Pablo Neira Ayuso [this message]
2019-03-08 16:52 ` John Stultz
2019-04-08 21:29 ` Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190308155543.si2nqqm6j2otq27r@salvia \
--to=pablo@netfilter.org \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lirongqing@baidu.com \
--cc=netfilter-devel@vger.kernel.org \
--cc=sboyd@kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).