From: Arjan van de Ven <arjan@infradead.org>
To: Denis Vlasenko <vda@ilport.com.ua>
Cc: linux-os@analogic.com, Jesper Juhl <juhl-lkml@dif.dk>,
ext2-devel@lists.sourceforge.net,
Linux kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] no need to check for NULL before calling kfree() -fs/ext2/
Date: Sun, 27 Mar 2005 16:28:42 +0200 [thread overview]
Message-ID: <1111933722.6297.42.camel@laptopd505.fenrus.org> (raw)
In-Reply-To: <200503271551.18342.vda@ilport.com.ua>
On Sun, 2005-03-27 at 15:51 +0300, Denis Vlasenko wrote:
> > > It's impossible to be otherwise. A call requires
> > > that the return address be written to memory (the stack),
> > > using register indirection (the stack-pointer).
> >
> > and it's a so common pattern that it's optimized to death. Internally a
> > call gets transformed to 2 uops or so, one is push eip, the other is the
> > jmp (which gets then just absorbed by the "what is the next eip" logic,
> > just as a "jmp"s are 0 cycles)
>
> Arjan, you overlook the fact that kfree() contains 'if(!p) return;' too.
> call + test-and-branch can never be faster than test+and+branch
ok so for the non-null case you have
test-nbranch-call-test-nbranch
vs
call-test-nbranch
vs the null case where you get
test-branch
vs
call-test-branch
(I'm using nbranch here as a non-taken branch; it's also a conditional
branch and it has the same misprediction possibility)
in the non-null case with if you have *two* chances for the branch
predictor to go wrong. (and "wrong" can also mean "cold, eg unknown"
here) and always an extra "test-nbranch" sequence, which is probably a
cycle at least
the offset for that is the null-case-without-if where you have an extra
"call", which is also half to a whole cycle.
even in the null case it's dubious if there is gain, it depends on how
the branch predictor happens to feel that day ;)
next prev parent reply other threads:[~2005-03-27 14:28 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-25 22:08 [PATCH] no need to check for NULL before calling kfree() - fs/ext2/ Jesper Juhl
2005-03-25 22:29 ` linux-os
2005-03-25 22:44 ` Jesper Juhl
2005-03-26 7:50 ` Pekka Enberg
2005-03-26 8:32 ` Arjan van de Ven
2005-03-26 23:21 ` [PATCH] no need to check for NULL before calling kfree() -fs/ext2/ linux-os
2005-03-26 23:34 ` Marcin Dalecki
2005-03-27 2:00 ` Horst von Brand
2005-03-27 3:18 ` Marcin Dalecki
2005-03-27 22:12 ` linux-os
2005-03-26 23:54 ` Jesper Juhl
2005-03-27 0:05 ` Lee Revell
2005-03-27 10:55 ` Jesper Juhl
2005-03-27 14:56 ` Paul Jackson
2005-03-27 15:12 ` Jan Engelhardt
2005-03-27 17:40 ` Dave Jones
2005-03-27 18:17 ` Jan Engelhardt
2005-03-27 19:25 ` Pekka Enberg
2005-03-27 22:56 ` Jesper Juhl
2005-03-28 4:53 ` Paul Jackson
2005-03-30 18:57 ` Jesper Juhl
2005-03-28 1:20 ` Horst von Brand
2005-03-28 4:10 ` Paul Jackson
2005-03-28 12:58 ` Geert Uytterhoeven
2005-03-29 2:52 ` Lee Revell
2005-03-29 6:30 ` Pekka Enberg
2005-03-29 7:06 ` Jan Engelhardt
2005-03-29 7:24 ` Pekka J Enberg
2005-03-30 2:44 ` Paul Jackson
2005-03-30 6:13 ` Pekka J Enberg
2005-03-30 6:16 ` Paul Jackson
2005-03-30 7:15 ` P Lavin
2005-03-30 14:20 ` Jesper Juhl
2005-03-30 19:10 ` Jesper Juhl
2005-04-09 2:21 ` Jesper Juhl
2005-03-28 4:07 ` [PATCH] " Paul Jackson
2005-03-27 8:45 ` Arjan van de Ven
2005-03-27 12:51 ` Denis Vlasenko
2005-03-27 14:28 ` Arjan van de Ven [this message]
2005-03-27 23:13 ` [PATCH] no need to check for NULL before calling kfree()-fs/ext2/ linux-os
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=1111933722.6297.42.camel@laptopd505.fenrus.org \
--to=arjan@infradead.org \
--cc=ext2-devel@lists.sourceforge.net \
--cc=juhl-lkml@dif.dk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-os@analogic.com \
--cc=vda@ilport.com.ua \
/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
all inboxes | Powered by JetHome®