linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] fs: optimize mpage_bio_submit()
@ 2010-05-29  1:19 Changli Gao
  2010-05-29 12:47 ` Borislav Petkov
  0 siblings, 1 reply; 4+ messages in thread
From: Changli Gao @ 2010-05-29  1:19 UTC (permalink / raw)
  To: Alexander Viro; +Cc: linux-fsdevel, linux-kernel, Changli Gao

optimize mpage_bio_submit()

check rw, then initialize bio->bi_end_io.

Signed-off-by: Changli Gao <xiaosuo@gmail.com>
----
 fs/mpage.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/fs/mpage.c b/fs/mpage.c
index 94ff0d1..632681c 100644
--- a/fs/mpage.c
+++ b/fs/mpage.c
@@ -85,9 +85,7 @@ static void mpage_end_io_write(struct bio *bio, int err)
 
 static struct bio *mpage_bio_submit(int rw, struct bio *bio)
 {
-	bio->bi_end_io = mpage_end_io_read;
-	if (rw == WRITE)
-		bio->bi_end_io = mpage_end_io_write;
+	bio->bi_end_io = rw != WRITE ? mpage_end_io_read : mpage_end_io_write;
 	submit_bio(rw, bio);
 	return NULL;
 }

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] fs: optimize mpage_bio_submit()
  2010-05-29  1:19 [PATCH 2/2] fs: optimize mpage_bio_submit() Changli Gao
@ 2010-05-29 12:47 ` Borislav Petkov
  2010-05-29 13:33   ` Changli Gao
  0 siblings, 1 reply; 4+ messages in thread
From: Borislav Petkov @ 2010-05-29 12:47 UTC (permalink / raw)
  To: Changli Gao; +Cc: Alexander Viro, linux-fsdevel, linux-kernel

From: Changli Gao <xiaosuo@gmail.com>
Date: Sat, May 29, 2010 at 09:19:26AM +0800

> optimize mpage_bio_submit()
> 
> check rw, then initialize bio->bi_end_io.
> 
> Signed-off-by: Changli Gao <xiaosuo@gmail.com>
> ----
>  fs/mpage.c |    4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> diff --git a/fs/mpage.c b/fs/mpage.c
> index 94ff0d1..632681c 100644
> --- a/fs/mpage.c
> +++ b/fs/mpage.c
> @@ -85,9 +85,7 @@ static void mpage_end_io_write(struct bio *bio, int err)
>  
>  static struct bio *mpage_bio_submit(int rw, struct bio *bio)
>  {
> -	bio->bi_end_io = mpage_end_io_read;
> -	if (rw == WRITE)
> -		bio->bi_end_io = mpage_end_io_write;
> +	bio->bi_end_io = rw != WRITE ? mpage_end_io_read : mpage_end_io_write;
>  	submit_bio(rw, bio);
>  	return NULL;

ok, can you sincerely tell me that your change makes the code more
readable? And have you checked to see what the compiler actually
"optimizes"?

original code:

	movq	$mpage_end_io_read, %rdx	#, tmp65
	movq	$mpage_end_io_write, %rax	#, tmp64
	cmpl	$1, %edi	#, rw
	cmovne	%rdx, %rax	# tmp65,, tmp64
	movq	%rax, 80(%rsi)	# tmp64, <variable>.bi_end_io
	.loc 1 91 0
	call	submit_bio	#

your change:

	movq	$mpage_end_io_read, %rdx	#, tmp63
	movq	$mpage_end_io_write, %rax	#, iftmp.561
	cmpl	$1, %edi	#, rw
	cmovne	%rdx, %rax	# tmp63,, iftmp.561
	movq	%rax, 80(%rsi)	# iftmp.561, <variable>.bi_end_io
	.loc 1 90 0
	call	submit_bio	#

so that change does nothing except obfuscating the source a bit more so
that you get more headaches whenever you look at it.

-- 
Regards/Gruss,
    Boris.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] fs: optimize mpage_bio_submit()
  2010-05-29 12:47 ` Borislav Petkov
@ 2010-05-29 13:33   ` Changli Gao
  2010-05-29 13:43     ` Borislav Petkov
  0 siblings, 1 reply; 4+ messages in thread
From: Changli Gao @ 2010-05-29 13:33 UTC (permalink / raw)
  To: Borislav Petkov, Changli Gao, Alexander Viro, linux-fsdevel,
	linux-kernel

On Sat, May 29, 2010 at 8:47 PM, Borislav Petkov <bp@alien8.de> wrote:
>
> ok, can you sincerely tell me that your change makes the code more
> readable? And have you checked to see what the compiler actually
> "optimizes"?
>
> original code:
>
>        movq    $mpage_end_io_read, %rdx        #, tmp65
>        movq    $mpage_end_io_write, %rax       #, tmp64
>        cmpl    $1, %edi        #, rw
>        cmovne  %rdx, %rax      # tmp65,, tmp64
>        movq    %rax, 80(%rsi)  # tmp64, <variable>.bi_end_io
>        .loc 1 91 0
>        call    submit_bio      #
>
> your change:
>
>        movq    $mpage_end_io_read, %rdx        #, tmp63
>        movq    $mpage_end_io_write, %rax       #, iftmp.561
>        cmpl    $1, %edi        #, rw
>        cmovne  %rdx, %rax      # tmp63,, iftmp.561
>        movq    %rax, 80(%rsi)  # iftmp.561, <variable>.bi_end_io
>        .loc 1 90 0
>        call    submit_bio      #
>
> so that change does nothing except obfuscating the source a bit more so
> that you get more headaches whenever you look at it.
>

Oh, I didn't check the asm code. Compiler is smarter than I thought.
Thanks for your explaining.


-- 
Regards,
Changli Gao(xiaosuo@gmail.com)
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] fs: optimize mpage_bio_submit()
  2010-05-29 13:33   ` Changli Gao
@ 2010-05-29 13:43     ` Borislav Petkov
  0 siblings, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2010-05-29 13:43 UTC (permalink / raw)
  To: Changli Gao; +Cc: Alexander Viro, linux-fsdevel, linux-kernel

From: Changli Gao <xiaosuo@gmail.com>
Date: Sat, May 29, 2010 at 09:33:02PM +0800

> Compiler is smarter than I thought.

Not as much as we would like to though :)

-- 
Regards/Gruss,
    Boris.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-05-29 13:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-29  1:19 [PATCH 2/2] fs: optimize mpage_bio_submit() Changli Gao
2010-05-29 12:47 ` Borislav Petkov
2010-05-29 13:33   ` Changli Gao
2010-05-29 13:43     ` Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).