From: Joe Perches <joe@perches.com>
To: yamada.m@jp.panasonic.com, linux-kernel@vger.kernel.org,
sam@ravnborg.org, hpa@zytor.com, john.stultz@linaro.org,
mmarek@suse.cz, hofrat@osadl.org, tglx@linutronix.de,
mingo@kernel.org, joe@perches.com, pjt@google.com,
ahh@google.com
Subject: Re: [tip:timers/core] time: Refactor msecs_to_jiffies
Date: Tue, 19 May 2015 07:03:58 -0700 [thread overview]
Message-ID: <1432044238.2870.148.camel@perches.com> (raw)
In-Reply-To: <tip-ca42aaf0c8616cde6161ea4391dff364efeee46a@git.kernel.org>
On Tue, 2015-05-19 at 06:36 -0700, tip-bot for Nicholas Mc Guire wrote:
> Refactor the msecs_to_jiffies conditional code part in time.c and
> jiffies.h putting it into conditional functions rather than #ifdefs
> to improve readability.
[]
> diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
[]
> +static inline unsigned long _msecs_to_jiffies(const unsigned int m)
> +{
> + return (m + (MSEC_PER_SEC / HZ) - 1) / (MSEC_PER_SEC / HZ);
> +}
> +#elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC)
> +/*
> + * HZ is larger than 1000, and HZ is a nice round multiple of 1000 -
> + * simply multiply with the factor between them.
> + *
> + * But first make sure the multiplication result cannot overflow:
> + */
> +static inline unsigned long _msecs_to_jiffies(const unsigned int m)
> +{
> + if (m > jiffies_to_msecs(MAX_JIFFY_OFFSET))
> + return MAX_JIFFY_OFFSET;
> + return m * (HZ / MSEC_PER_SEC);
> +}
> +#else
> +/*
> + * Generic case - multiply, round and divide. But first check that if
> + * we are doing a net multiplication, that we wouldn't overflow:
> + */
> +static inline unsigned long _msecs_to_jiffies(const unsigned int m)
> +{
> + if (HZ > MSEC_PER_SEC && m > jiffies_to_msecs(MAX_JIFFY_OFFSET))
> + return MAX_JIFFY_OFFSET;
> +
> + return (MSEC_TO_HZ_MUL32 * m + MSEC_TO_HZ_ADJ32)
> + >> MSEC_TO_HZ_SHR32;
> +}
> +#endif
It'd be nicer to remove 1 level of unnecessary tab indentation in
all the _msecs_to_jiffies functions here.
next prev parent reply other threads:[~2015-05-19 14:04 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-18 12:19 [PATCH 1/3 V3] time: move timeconst.h into include/generated Nicholas Mc Guire
2015-05-18 12:19 ` [PATCH 2/3 V3] time: refactor msecs_to_jiffies Nicholas Mc Guire
2015-05-19 13:36 ` [tip:timers/core] time: Refactor msecs_to_jiffies tip-bot for Nicholas Mc Guire
2015-05-19 14:03 ` Joe Perches [this message]
2015-05-19 14:47 ` Nicholas Mc Guire
2015-05-19 15:18 ` Thomas Gleixner
2015-05-19 19:31 ` Nicholas Mc Guire
2015-05-19 15:12 ` Thomas Gleixner
2015-05-18 12:19 ` [PATCH 3/3 V3] time: allow gcc to fold constants when possible Nicholas Mc Guire
2015-05-19 13:37 ` [tip:timers/core] time: Allow " tip-bot for Nicholas Mc Guire
2015-05-19 13:36 ` [tip:timers/core] time: Move timeconst.h into include/generated tip-bot for Nicholas Mc Guire
2015-06-29 23:03 ` Stephen Boyd
2015-06-30 6:52 ` Nicholas Mc Guire
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=1432044238.2870.148.camel@perches.com \
--to=joe@perches.com \
--cc=ahh@google.com \
--cc=hofrat@osadl.org \
--cc=hpa@zytor.com \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=mmarek@suse.cz \
--cc=pjt@google.com \
--cc=sam@ravnborg.org \
--cc=tglx@linutronix.de \
--cc=yamada.m@jp.panasonic.com \
/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
Powered by JetHome