From: "Alexander van Heukelum" <heukelum@fastmail.fm>
To: "Andi Kleen" <andi@firstfloor.org>
Cc: "Andi Kleen" <andi@firstfloor.org>,
"Jeremy Fitzhardinge" <jeremy@goop.org>,
"Alexander van Heukelum" <heukelum@mailshack.com>,
"Ingo Molnar" <mingo@elte.hu>,
"Thomas Gleixner" <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
"LKML" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] x86: merge the simple bitops and move them to bitops.h
Date: Fri, 14 Mar 2008 23:01:18 +0100 [thread overview]
Message-ID: <1205532078.32744.1242485965@webmail.messagingengine.com> (raw)
In-Reply-To: <20080314214205.GW2522@one.firstfloor.org>
On Fri, 14 Mar 2008 22:42:05 +0100, "Andi Kleen" <andi@firstfloor.org>
said:
> On Fri, Mar 14, 2008 at 10:33:29PM +0100, Alexander van Heukelum wrote:
> > static inline int fls64(__u64 x)
> > {
> > __u32 h = x >> 32;
> > if (h)
> > return fls(h) + 32;
> > return fls(x);
> > }
> >
> > I just wanted to move the 64-bit version to that header, with some
> > ifdefs to select the right one.
>
> That's still far more than the single 64bit instruction fls64 uses
I agree that it should end up using bsr. It would look like this in
the end, I guess. Might be familiar.
#if BITS_PER_LONG == 32
static inline int fls64(__u64 x)
{
__u32 h = x >> 32;
if (h)
return __fls(h) + 33;
return fls(x);
}
#else
static inline int fls64(__u64 x)
{
if (x == 0)
return 0;
return __fls(x) + 1;
}
#endif
> > In fact I just found out that it only had an effect for 64 bit
> > machines. Still, setting it unconditionally feels wrong.
>
> I don't think your feeling is correct.
This is the only reason that this define exists. With another
name it would be fine. HWEIGHT_USE_MULTIPLIER?
> > > > x86_64 has a mysterious inline function set_bit_string, which is
> > > > only used by pci-calgary_64.c and pci-gart_64.c. Not sure what to
> > > > do with it.
> > >
> > > It's generic and could really live in linux/bitops.h
> >
> > It could. But it is a trivial (slow?) implementation. Probably fine
>
> It is this way because the callers in 95+% of all cases only
> set a single bit. For that case it is not slow.
And my feeling is that this is exactly the reason why this is
not a good version for a generic implementation in bitops.h. But
I don't care much.
Greetings,
Alexander
> -Andi
--
Alexander van Heukelum
heukelum@fastmail.fm
--
http://www.fastmail.fm - Accessible with your email software
or over the web
next prev parent reply other threads:[~2008-03-14 22:01 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-12 20:01 [PATCH] x86: merge the simple bitops and move them to bitops.h Alexander van Heukelum
2008-03-14 18:07 ` Jeremy Fitzhardinge
2008-03-14 19:43 ` Alexander van Heukelum
2008-03-14 19:55 ` Andi Kleen
2008-03-14 21:33 ` Alexander van Heukelum
2008-03-14 21:42 ` Andi Kleen
2008-03-14 22:01 ` Alexander van Heukelum [this message]
2008-03-14 22:18 ` Andi Kleen
2008-03-15 17:54 ` Alexander van Heukelum
2008-03-15 19:19 ` K8, EFFICEON and CORE2 support the cmovxx instructions Alexander van Heukelum
2008-03-15 20:18 ` H. Peter Anvin
2008-03-15 21:06 ` Alexander van Heukelum
2008-03-15 21:11 ` Willy Tarreau
2008-03-16 13:16 ` [PATCH] x86: K8, GEODE_LX, CRUSOE, " Alexander van Heukelum
2008-03-21 12:38 ` Ingo Molnar
2008-03-14 20:35 ` [PATCH v2] x86: merge the simple bitops and move them to bitops.h Alexander van Heukelum
2008-03-14 23:30 ` Randy Dunlap
2008-03-15 12:04 ` [PATCH v3] " Alexander van Heukelum
2008-03-21 12:35 ` Ingo Molnar
2008-03-14 21:15 ` [PATCH] " Jeremy Fitzhardinge
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=1205532078.32744.1242485965@webmail.messagingengine.com \
--to=heukelum@fastmail.fm \
--cc=andi@firstfloor.org \
--cc=heukelum@mailshack.com \
--cc=hpa@zytor.com \
--cc=jeremy@goop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.