public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: Yinghai Lu <yhlu.kernel@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Christoph Lameter <clameter@sgi.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Adrian Bunk <bunk@stusta.de>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: free_pages_check
Date: Mon, 07 Jan 2008 21:44:47 -0800	[thread overview]
Message-ID: <47830DCF.3080306@zytor.com> (raw)
In-Reply-To: <200801081434.14723.nickpiggin@yahoo.com.au>

Nick Piggin wrote:
> On Tuesday 08 January 2008 13:43, Yinghai Lu wrote:
>> wonder why free_pages_check mm/page_alloc.c is using bit OR than logical OR
>>
>> @@ -450,9 +450,9 @@ static inline void __free_one_page(struc
>>
>>  static inline int free_pages_check(struct page *page)
>>  {
>> -       if (unlikely(page_mapcount(page) |
>> -               (page->mapping != NULL)  |
>> -               (page_count(page) != 0)  |
>> +       if (unlikely(page_mapcount(page) ||
>> +               (page->mapping != NULL)  ||
>> +               (page_count(page) != 0)  ||
>>                 (page->flags & (
>>                         1 << PG_lru     |
>>                         1 << PG_private |
> 
> Because the positive case is extremely rare, so there is no benefit (nor
> any correctness requirement) for short-circuit evaluation, and we don't
> want to have all the branches that it involves. I think it is 3 more
> conditional jumps.

Depends on how smart the compiler is.  If the page_() functions are 
inlines or macros, there is only one pointer reference involved and it 
should be able to do that transformation.  Whether or not gcc is that 
smart is another matter.

	-hpa


  reply	other threads:[~2008-01-08  5:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-08  2:43 free_pages_check Yinghai Lu
2008-01-08  3:08 ` free_pages_check Andrew Morton
2008-01-08  3:34 ` free_pages_check Nick Piggin
2008-01-08  5:44   ` H. Peter Anvin [this message]
2008-01-08  7:44     ` free_pages_check Nick Piggin

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=47830DCF.3080306@zytor.com \
    --to=hpa@zytor.com \
    --cc=akpm@linux-foundation.org \
    --cc=bunk@stusta.de \
    --cc=clameter@sgi.com \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nickpiggin@yahoo.com.au \
    --cc=yhlu.kernel@gmail.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