From: "Holden Karau" <holden@pigscanfly.ca>
To: "Phillip Susi" <psusi@cfl.rr.com>
Cc: "Jörn Engel" <joern@wohnheim.fh-wedel.de>,
"Josef Sipek" <jsipek@fsl.cs.sunysb.edu>,
hirofumi@mail.parknet.co.jp, linux-kernel@vger.kernel.org,
"Holden Karau" <holdenk@xandros.com>,
"akpm@osdl.org" <akpm@osdl.org>,
linux-fsdevel@vger.kernel.org,
"Nick Piggin" <nickpiggin@yahoo.com.au>,
"Matthew Wilcox" <matthew@wil.cx>
Subject: Re: [PATCH 1/1] fat: improve sync performance by grouping writes revised again
Date: Wed, 1 Nov 2006 17:17:48 -0500 [thread overview]
Message-ID: <f46018bb0611011417s3c436528w3a394531e94cec68@mail.gmail.com> (raw)
In-Reply-To: <454908F9.80905@cfl.rr.com>
Hi Jörn,
If I do
c_bh = kmalloc(blah);
err= -ENOMEM;
if (!c_bh)
goto error;
//here err = -ENOMEM
... do some stuff...
error:
return err;
It will return -ENOMEM, no? I mean I could set err back to 0 and do
something like:
c_bh = kmalloc(blah);
err= -ENOMEM;
if (!c_bh)
goto error;
err = 0;
... do some stuf...
error:
return err;
At first glance, at least for me, I'd be scratching my head when I
looked at that.
Also given that this error state is to be an exception not the rule,
if what Phillip suggests is correct, than it would actually be a tiney
be slower. So, all in all I'd rather leave it the way it is :-)
On 11/1/06, Phillip Susi <psusi@cfl.rr.com> wrote:
> I think this is getting into micro-optimization, which is usually bad.
> Also moving the assignment of err outside the body of the if only
> results in slightly faster code in the case where there is an error,
> since you can test and _maybe_ conditionally jump directly to the error:
> label if it is not very far away. With the assignment in the body, the
> conditional jump must jump to the assignment followed by an
> unconditional jump to the label.
>
> In other words, the only time this micro optimization will be of benefit
> is if you are erroring out most of the time rather than only under
> exceptional conditions, AND the error label isn't too far away for a
> conditional branch to reach. In other words, just don't do it ;)
>
> Jörn Engel wrote:
> > On Wed, 1 November 2006 13:02:12 -0500, Holden Karau wrote:
> >> On 11/1/06, Jörn Engel <joern@wohnheim.fh-wedel.de> wrote:
> >>> Result would be something like:
> >>> c_bh = kmalloc(...
> >>> err = -ENOMEM;
> >>> if (!c_bh)
> >>> goto error;
> >> That wouldn't work so well since we always return err,
> >
> > I don't quite follow. If the branch is taken, err is -ENOMEM. If the
> > branch is not taken, err is set to 0 with the next instruction.
> >
> > Both methods definitely work. Whether one is preferrable over the
> > other is imo 90% taste and maybe 10% better code on some architecture.
> > So just pick what you prefer.
> >
> > Jörn
> >
>
> -
> 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
>
--
Cell: 613-276-1645
next prev parent reply other threads:[~2006-11-01 22:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-01 16:17 [PATCH 1/1] fat: improve sync performance by grouping writes revised again Holden Karau
2006-11-01 16:47 ` Jörn Engel
2006-11-01 18:02 ` Holden Karau
2006-11-01 20:24 ` Jörn Engel
2006-11-01 20:52 ` Phillip Susi
2006-11-01 22:17 ` Holden Karau [this message]
2006-11-02 10:24 ` historical micro-optimizations (Re: [PATCH 1/1] fat: improve sync performance by grouping writes revised again) Jörn Engel
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=f46018bb0611011417s3c436528w3a394531e94cec68@mail.gmail.com \
--to=holden@pigscanfly.ca \
--cc=akpm@osdl.org \
--cc=hirofumi@mail.parknet.co.jp \
--cc=holdenk@xandros.com \
--cc=joern@wohnheim.fh-wedel.de \
--cc=jsipek@fsl.cs.sunysb.edu \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew@wil.cx \
--cc=nickpiggin@yahoo.com.au \
--cc=psusi@cfl.rr.com \
/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;
as well as URLs for NNTP newsgroup(s).