From: Thomas Gleixner <tglx@linutronix.de>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Segher Boessenkool <segher@kernel.crashing.org>,
linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
john stultz <johnstul@us.ibm.com>
Subject: Re: [PATCH] Prevent the loop in timespec_add_ns() to be optimised away
Date: Thu, 28 Feb 2008 22:58:49 +0100 (CET) [thread overview]
Message-ID: <alpine.LFD.1.00.0802282257490.3111@apollo.tec.linutronix.de> (raw)
In-Reply-To: <20080227154341.824efe3c.akpm@linux-foundation.org>
On Wed, 27 Feb 2008, Andrew Morton wrote:
> On Fri, 22 Feb 2008 22:40:45 +0100
> Segher Boessenkool <segher@kernel.crashing.org> wrote:
>
> > ...since some architectures don't support __udivdi3() (and
> > we don't want to use that, anyway).
> >
> > Signed-off-by: Segher Boessenkool <segher@kernel.crashing.org>
> > ---
> > include/linux/time.h | 4 ++++
> > 1 files changed, 4 insertions(+), 0 deletions(-)
> >
> > diff --git a/include/linux/time.h b/include/linux/time.h
> > index 2091a19..d32ef0a 100644
> > --- a/include/linux/time.h
> > +++ b/include/linux/time.h
> > @@ -174,6 +174,10 @@ static inline void timespec_add_ns(struct timespec *a, u64 ns)
> > {
> > ns += a->tv_nsec;
> > while(unlikely(ns >= NSEC_PER_SEC)) {
> > + /* The following asm() prevents the compiler from
> > + * optimising this loop into a modulo operation. */
> > + asm("" : "+r"(ns));
> > +
> > ns -= NSEC_PER_SEC;
> > a->tv_sec++;
> > }
>
> It's pretty sad that we need to turn this into a loop just because of the
> __udivdi3() thing.
>
> otoh, it's rarely occurring, and it could be that the number of times it
> loops is usually 1 (if it wasn't zero), so perhaps a loop is faster than a
> divide anyway.
>
> This code is probably too large to be inlined.
>
> I queued this patch as needed-in-2.6.25, to-be-merged-via-Thomas.
Are you going to send it or should I grab it from the mailing list
myself ?
Thanks,
tglx
next prev parent reply other threads:[~2008-02-28 22:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-22 21:40 Segher Boessenkool
2008-02-27 23:43 ` Andrew Morton
2008-02-28 21:58 ` Thomas Gleixner [this message]
2008-02-28 22:13 ` Andrew Morton
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=alpine.LFD.1.00.0802282257490.3111@apollo.tec.linutronix.de \
--to=tglx@linutronix.de \
--cc=akpm@linux-foundation.org \
--cc=johnstul@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=segher@kernel.crashing.org \
/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