fs: optimize mpage_bio_submit()
PATCH 2/2 fs: optimize mpage_bio_submit()
optimize mpage_bio_submit()
check rw, then initialize bio->bi_end_io.
----
fs/mpage.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
fs/mpage.c +1 -3
@@ -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 ; }
From: Changli Gao <[email protected]>
Date: Sat, May 29, 2010 at 09:19:26AM +0800
Quoted 13 lines
optimize
mpage_bio_submit()check rw, then initialize
bio->bi_end_io.Signed-off-by Changli Gao <[email protected]>----
fs/mpage.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)fs/mpage.c +0
-0
fs/mpage.c static void mpage_end_io_write(struct bio *bio, int err) · line 90
Quoted 9 lines
fs/mpage.c +1
-3@@ -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.
Signature · 2 lines
Regards/Gruss,
Boris.Quoted 25 lines · Borislav Petkov
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 #
Quoted 3 lines
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.
Signature · 6 lines
Regards, Changli Gao([email protected]) -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Changli Gao <[email protected]>
Date: Sat, May 29, 2010 at 09:33:02PM +0800
Quoted 1 line
Compiler is smarter than I thought.
Not as much as we would like to though :)
Signature · 2 lines
Regards/Gruss,
Boris.