linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@gmail.com>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fs/buffer.c: change buffer_busy() to use logical-OR expression
Date: Sun, 24 Oct 2010 02:49:48 +0900	[thread overview]
Message-ID: <1287856188.1681.48.camel@leonhard> (raw)
In-Reply-To: <20101023172107.GQ19804@ZenIV.linux.org.uk>

2010-10-23 (토), 18:21 +0100, Al Viro:
> On Sun, Oct 24, 2010 at 02:06:15AM +0900, Namhyung Kim wrote:
> > Convert bitwise-OR operator to logical-OR in favor of short-circuit
> > evaluation. The end result would be same.
> 
> It'll cost _more_.
> 
> Think of it:
> 	v = atomic_read(...)
> 	w = bh->b_state
> 	w &= constant
> 	v |= w
> 	return v
> vs.
> 	v = atomic_read()
> 	branch to l if not equal to 0
> 	w = bh->b_state
> 	if w & constant is not 0, branch to l
> 	v = 0
> 	return v
> l:	v = 1
> 	return v
> 
> That short-circuit won't win anything here.

I see. It adds expensive branch insns. I just checked that patched code
generated longer code, Cool. But what if I exchange the order of
evaluation, check the bitmask before atomic_read()? Isn't it helpful
either?

Thanks.


-- 
Regards,
Namhyung Kim

      reply	other threads:[~2010-10-23 17:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-23 17:06 [PATCH] fs/buffer.c: change buffer_busy() to use logical-OR expression Namhyung Kim
2010-10-23 17:21 ` Al Viro
2010-10-23 17:49   ` Namhyung Kim [this message]

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=1287856188.1681.48.camel@leonhard \
    --to=namhyung@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@ZenIV.linux.org.uk \
    /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).