xfs
[Top] [All Lists]

Re: [PATCHv2 8/10] xfs: avoid repeated pointer dereferences

To: Alex Elder <aelder@xxxxxxx>
Subject: Re: [PATCHv2 8/10] xfs: avoid repeated pointer dereferences
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Mon, 12 Apr 2010 16:56:44 +1000
Cc: xfs@xxxxxxxxxxx
In-reply-to: <1270852242.7840.158.camel@doink>
References: <1270852242.7840.158.camel@doink>
User-agent: Mutt/1.5.20 (2009-06-14)
On Fri, Apr 09, 2010 at 05:30:42PM -0500, Alex Elder wrote:
> In xlog_find_cycle_start() use a local variable for some repeated
> operations rather than constantly updating the memory location
> whose address is passed in.

Won't the compiler optimise that out for us? i.e. does the dissassembly
of the function look any better before and after this change?

> Signed-off-by: Alex Elder <aelder@xxxxxxx>
> 
> ---
> fs/xfs/xfs_log_recover.c |   83 
> ++++++++++++++++++++++++-----------------------
>  fs/xfs/xfs_log_recover.c |   26 ++++++++++++++------------
>  1 file changed, 14 insertions(+), 12 deletions(-)
> 
> Index: b/fs/xfs/xfs_log_recover.c
> ===================================================================
> --- a/fs/xfs/xfs_log_recover.c
> +++ b/fs/xfs/xfs_log_recover.c
> @@ -354,26 +354,28 @@ xlog_find_cycle_start(
>  {
>       xfs_caddr_t     offset;
>       xfs_daddr_t     mid_blk;
> +     xfs_daddr_t     end_blk;
>       uint            mid_cycle;
>       int             error;
>  
> -     mid_blk = BLK_AVG(first_blk, *last_blk);
> -     while (mid_blk != first_blk && mid_blk != *last_blk) {
> +     ASSERT(last_blk != NULL);
> +     end_blk = *last_blk;

FWIW, there is no need for that ASSERT there - the machine will
panic on the very next line, anyway....

Cheers,

Dave.
-- 
Dave Chinner
david@xxxxxxxxxxxxx

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