All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Moore <paul.moore@hp.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
	netdev@vger.kernel.org, David Miller <davem@davemloft.net>
Subject: Re: [RFC PATCH v1] tun: Cleanup error handling in tun_set_iff()
Date: Fri, 7 Aug 2009 08:23:02 -0400	[thread overview]
Message-ID: <200908070823.03046.paul.moore@hp.com> (raw)
In-Reply-To: <20090807000021.GA1566@gondor.apana.org.au>

On Thursday 06 August 2009 08:00:21 pm Herbert Xu wrote:
> On Thu, Aug 06, 2009 at 02:20:20PM -0400, Paul Moore wrote:
> > The code currently looks something like this:
> >
> > 	err = -ENOMEM;
> > 	buf = alloc(...);
> > 	if (!buf)
> > 		goto label;
> >
> > This means that in the common case where 'alloc()' completes without
> > error we are doing an extra, unnecessary assignment where we set the
> > value in 'err'. Now, if we change this slightly to match what I proposed
> > in the patch:
> >
> > 	buf = alloc(...);
> > 	if (!buf) {
> > 		err = -ENOMEM;
> > 		goto label;
> > 	}
> >
> > We eliminate that extra assignment in the case where 'alloc()' completes
> > without error, which should result in more efficient code (less
> > instructions in the common case).  Am I wrong?  If that is the case I
> > would appreciate an explanation ...
>
> Your style potentially introduces a second jump which may end
> up being worse compared to the extra work on a modern CPU.

Thanks, I hadn't thought of that possibility.  I suppose the impact of a 
second jump is going to depend quite a bit on the hardware it runs on 
(pipeline depth, branch prediction, etc.) and isn't as easy to quantify as I 
had hoped.  Oh well, I appreciate the explanation anyway :)

-- 
paul moore
linux @ hp


  reply	other threads:[~2009-08-07 12:23 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-03 16:12 [RFC PATCH v1] tun: Cleanup error handling in tun_set_iff() Paul Moore
2009-08-04  4:16 ` David Miller
2009-08-05  5:32 ` Eric W. Biederman
2009-08-05 21:38   ` Paul Moore
2009-08-05 23:14     ` Eric W. Biederman
2009-08-06 18:20       ` Paul Moore
2009-08-07  0:00         ` Herbert Xu
2009-08-07 12:23           ` Paul Moore [this message]
2009-08-06 10:10     ` Herbert Xu
2009-08-06 10:21       ` Eric W. Biederman
2009-08-06 13:37         ` Herbert Xu
2009-08-06 14:27           ` Eric W. Biederman
2009-08-06 14:39             ` Herbert Xu
2009-08-06 15:02               ` Eric W. Biederman
2009-08-06 18:09                 ` Paul Moore
2009-08-06 18:41                   ` David Miller
2009-08-07  0:22                 ` Herbert Xu
2009-08-07  3:40                   ` David Miller
2009-08-07  4:22                     ` Eric W. Biederman
2009-08-10  4:52                       ` David Miller

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=200908070823.03046.paul.moore@hp.com \
    --to=paul.moore@hp.com \
    --cc=davem@davemloft.net \
    --cc=ebiederm@xmission.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=netdev@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.