xfs
[Top] [All Lists]

Re: [PATCH 23/28] xfs: byteswap constants instead of variables

To: Alex Elder <aelder@xxxxxxx>
Subject: Re: [PATCH 23/28] xfs: byteswap constants instead of variables
From: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Date: Thu, 7 Jul 2011 12:28:24 -0400
Cc: Christoph Hellwig <hch@xxxxxxxxxxxxx>, xfs@xxxxxxxxxxx
In-reply-to: <1310055860.1980.23.camel@doink>
References: <20110707110535.205001532@xxxxxxxxxxxxxxxxxxxxxx> <20110707110645.046387162@xxxxxxxxxxxxxxxxxxxxxx> <1310055860.1980.23.camel@doink>
User-agent: Mutt/1.5.21 (2010-09-15)
On Thu, Jul 07, 2011 at 11:24:20AM -0500, Alex Elder wrote:
> On Thu, 2011-07-07 at 07:05 -0400, Christoph Hellwig wrote:
> > Micro-optimize various comparisms by always byteswapping the constant
> > instead of the variable, which allows to do the swap at compile instead
> > of runtime.
> > 
> > Signed-off-by: Christoph Hellwig <hch@xxxxxx>
> 
> Ha!!!  You missed one!  File "fs/xfs/xfs_dir2_node.c"
> lines 412-413 (after applying this patch):
> 
>   ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC);

I left a few where we are doing the same byteswap a little later again,
but this one doesn't seem to fall into the category.  Oh, I see why now:
my grep only found the _MAGIC and the byteswap on the same line.

> Also, xfs_magics[] in "fs/xfs/xfs_btree.c" could be
> initialized with the pre-byte-swapped versions of
> the constants (and the array should be given static
> scope as well).

Yeah, but let's keep this patch simple for now.

<Prev in Thread] Current Thread [Next in Thread>