From: Nicholas Mc Guire <der.herr@hofr.at>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Nicholas Mc Guire <hofrat@osadl.org>,
Michal Marek <mmarek@suse.cz>,
Masahiro Yamada <yamada.m@jp.panasonic.com>,
Sam Ravnborg <sam@ravnborg.org>, "H. Peter Alvin" <hpa@zytor.com>,
Joe Perches <joe@perches.com>,
John Stultz <john.stultz@linaro.org>,
Andrew Hunter <ahh@google.com>, Paul Turner <pjt@google.com>,
Aaron Sierra <asierra@xes-inc.com>,
Brian Norris <computersforpeace@gmail.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3 V2] time: allow gcc to fold constants when using
Date: Wed, 22 Apr 2015 16:36:18 +0200 [thread overview]
Message-ID: <20150422143618.GA28213@opentech.at> (raw)
In-Reply-To: <alpine.DEB.2.11.1504221356340.13914@nanos>
On Wed, 22 Apr 2015, Thomas Gleixner wrote:
> On Sun, 12 Apr 2015, Nicholas Mc Guire wrote:
> > +extern unsigned long __msecs_to_jiffies(const unsigned int m);
> > +#if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ)
> > +static inline unsigned long _msecs_to_jiffies(const unsigned int m)
> > +{
>
> This should move the comments explaining the logic for each variant as
> well.
should be covered by [PATCH 3/3 V2] time: update msecs_to_jiffies doc and move to kernel-doc
>
> > + return (m + (MSEC_PER_SEC / HZ) - 1) / (MSEC_PER_SEC / HZ);
> > +}
> > +#elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC)
> > +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
> > +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
> > +static inline unsigned long msecs_to_jiffies(const unsigned int m)
> > +{
> > + if (__builtin_constant_p(m)) {
> > + if ((int)m < 0)
> > + return MAX_JIFFY_OFFSET;
> > + return _msecs_to_jiffies(m);
> > + } else
> > + return __msecs_to_jiffies(m);
>
> It'd be nice to have this as two patches:
>
> 1) Factor out the code into inline helpers w/o adding anything
>
> 2) Add the __builtin_constant_p() check
>
so basically 1) is refactoring only and 2) is the actual
change keept at a minimum or what is the intent of this split ?
will cleanup and resubmit - just waiting for some feedback on
the Kbuild change.
thx!
hofrat
next prev parent reply other threads:[~2015-04-22 14:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-12 12:13 [PATCH 0/3 V2] time: use __builtin_constant_p() in msecs_to_jiffies Nicholas Mc Guire
2015-04-12 12:13 ` [PATCH 1/3 V2] time: move timeconst.h into include/generated Nicholas Mc Guire
2015-04-12 21:35 ` Rob Landley
2015-04-12 12:13 ` [PATCH 2/3 V2] time: allow gcc to fold constants when using Nicholas Mc Guire
2015-04-22 12:00 ` Thomas Gleixner
2015-04-22 14:18 ` Joe Perches
2015-04-22 15:12 ` Nicholas Mc Guire
2015-04-22 14:36 ` Nicholas Mc Guire [this message]
2015-04-22 14:44 ` Thomas Gleixner
2015-04-12 12:13 ` [PATCH 3/3 V2] time: update msecs_to_jiffies doc and move to kernel-doc 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=20150422143618.GA28213@opentech.at \
--to=der.herr@hofr.at \
--cc=ahh@google.com \
--cc=asierra@xes-inc.com \
--cc=computersforpeace@gmail.com \
--cc=hofrat@osadl.org \
--cc=hpa@zytor.com \
--cc=joe@perches.com \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.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