public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Andi Kleen <ak@suse.de>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH] Replace XFS bit functions with Linux functions
Date: Tue, 2 Oct 2007 10:55:25 +0100	[thread overview]
Message-ID: <20071002095525.GA25405@infradead.org> (raw)
In-Reply-To: <200710021010.58284.ak@suse.de>

On Tue, Oct 02, 2007 at 10:10:58AM +0200, Andi Kleen wrote:
> 
> XFS had some own functions to find high and low bits.
> 
> This patch replaces them with a call to the respective Linux functions.
> The semantics of the Linux functions differ a little, but i checked
> all call sites that they can deal with that. I think all callers 
> are ok; but i added a few more asserts for the 0 case (where Linux
> and old XFS differ) just to make it easy to detect mistakes.
> 
> The resulting xfs.ko is about 500 bytes smaller on x86-64
> 
> This is similar to the patch Eric sent some days ago, but does
> it more efficiently imho. It replaces his patch.
> 
> I wasn't able to do a full XFS QA run over this unfortunately; but did careful
> review.

The patch looks like it's against mainline, so there might be some
problems applying it to the xfs tree.  At least some of the touched
functions have changed names and maybe content aswell.

>  	while (fields) {
> -		f = (xfs_sb_field_t)xfs_lowbit64((__uint64_t)fields);
> +		f = (xfs_sb_field_t)find_first_bit((unsigned long *)&fields,64);

I don't think we should add the case here but rather pass the fields
varialble as an unsigned long to start with.

> @@ -1428,11 +1428,11 @@ xfs_mod_sb(xfs_trans_t *tp, __int64_t fi
>  
>  	/* find modified range */
>  
> -	f = (xfs_sb_field_t)xfs_lowbit64((__uint64_t)fields);
> +	f = (xfs_sb_field_t)find_first_bit((unsigned long *)&fields, 64);
>  	ASSERT((1LL << f) & XFS_SB_MOD_BITS);
>  	first = xfs_sb_info[f].offset;
>  
> -	f = (xfs_sb_field_t)xfs_highbit64((__uint64_t)fields);
> +	f = (xfs_sb_field_t)fls64((__uint64_t)fields) - 1;

Same here.

> +/* All callers check for 0 arguments already; so no -1 handling */
> +static inline int xfs_rtlobit(unsigned long v)
> +{
> +	return find_first_bit(&v, 32);
> +}
> +
> +#define	XFS_RTLOBIT(w)  xfs_rtlobit(w)

I think just a

#define	XFS_RTLOBIT(w)	find_first_bit(&(w), 32)

should be fine.  Or make it just an inline, but not both a macro an
an inline.

  reply	other threads:[~2007-10-02  9:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-02  8:10 [PATCH] Replace XFS bit functions with Linux functions Andi Kleen
2007-10-02  9:55 ` Christoph Hellwig [this message]
2007-10-02 10:11   ` Andi Kleen
2007-10-02 12:59 ` David Chinner
2007-10-02 13:35   ` Andi Kleen
2007-10-02 16:37 ` Russell Cattelan
2007-10-03 17:58   ` Andi Kleen
2007-10-03 18:20     ` Russell Cattelan

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=20071002095525.GA25405@infradead.org \
    --to=hch@infradead.org \
    --cc=ak@suse.de \
    --cc=xfs@oss.sgi.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