All of lore.kernel.org
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: Steven Whitehouse <swhiteho@redhat.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [RFC] __ffs64()
Date: Wed, 22 Apr 2009 22:46:33 +0200	[thread overview]
Message-ID: <20090422204633.GE570@1wt.eu> (raw)
In-Reply-To: <1240415192.29604.90.camel@localhost.localdomain>

Hi Steve,

On Wed, Apr 22, 2009 at 04:46:32PM +0100, Steven Whitehouse wrote:
> Hi,
> 
> I'd like to add a new bitop, __ffs64() which I need in order to fix a
> bug in GFS2. The question is, where should it go?
> 
> On 64 bit arches, __ffs64() would be a synonym for __ffs(), but on 32
> bit arches it degenerates to a conditional plus a call to __ffs(). I'm
> assuming that there would not be a lot of point in optimising this
> operation on 32 bit arches even if such an instruction was available, so
> that I should do something like the below patch.
> 
> Does that seem reasonable, or should I give it a separate header file
> under asm-generic/bitops/ like some of the similar operations? It looks
> like I'd have to touch a lot of other files if I were to go that route,

While I have no reply to your questions above, I have one minor comment :

> +/**
> + * __ffs64 - find first set bit in a 64 bit word
> + * @word: The 64 bit word
> + *
> + * On 64 bit arches this is a synomyn for __ffs
> + */

IMHO you should remind here that the result is undefined when word==0
and the caller must check against it first.

> +static inline unsigned long __ffs64(u64 word)
> +{
> +#if BITS_PER_LONG == 32
> +	if (((u32)word) == 0UL)
> +		return __ffs((u32)(word >> 32)) + 32;
> +#elif BITS_PER_LONG != 64
> +#error BITS_PER_LONG not 32 or 64
> +#endif
> +	return __ffs((unsigned long)word);
> +}
> +
>  #ifdef __KERNEL__
>  #ifdef CONFIG_GENERIC_FIND_FIRST_BIT

Regards,
Willy


  reply	other threads:[~2009-04-22 20:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-22 15:46 [RFC] __ffs64() Steven Whitehouse
2009-04-22 20:46 ` Willy Tarreau [this message]
2009-04-22 20:59 ` Christoph Lameter
2009-04-23  8:22   ` Steven Whitehouse
2009-04-23  9:07     ` Benny Halevy

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=20090422204633.GE570@1wt.eu \
    --to=w@1wt.eu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=swhiteho@redhat.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 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.