All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhaolei <zhaolei@cn.fujitsu.com>
To: Chris Mason <chris.mason@oracle.com>,
	Miao Xie <miaox@cn.fujitsu.com>,
	Linux Btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: Re: [PATCH 01/18] btrfs: Remove u64 conversion for PAGE_CACHE_SIZE
Date: Wed, 31 Mar 2010 12:04:14 +0800	[thread overview]
Message-ID: <4BB2C9BE.6000402@cn.fujitsu.com> (raw)
In-Reply-To: <20100325130230.GG6538@think>

Chris Mason wrote:
> On Thu, Mar 25, 2010 at 08:27:26PM +0800, Miao Xie wrote:
>> From: Zhao Lei <zhaolei@cn.fujitsu.com>
>>
>> We don't need to convert PAGE_CACHE_SIZE to u64 in bit operation.
> 
> For code like this:
> 
> u64 size = (some number that doesn't fit in 32 bits)
> 
> if (size & (PAGE_CACHE_SIZE - 1)) {
> }
> 
> The answer should be the same either way.  But if the code gets
> switched:
> 
> start = size & ~(PAGE_CACHE_SIZE - 1);
> 
> Some arches are going to get the wrong answer here.  We had a few bugs
> like this early on and I went through and casted everything to be
> consistent.  While this patch is correct, I would rather leave the casts
> to avoid subtle problems later on as the code changes.
> 
> -chris

Hello, chris

Thanks for your explain.
I got your meaning.

But at least, we should make code unify:

// with u64:
[root@localhost btrfs]# grep '((u64)PAGE_CACHE_SIZE - 1)' *
compression.c:  WARN_ON(start & ((u64)PAGE_CACHE_SIZE - 1));
extent_io.c:    size_t start_offset = eb->start & ((u64)PAGE_CACHE_SIZE - 1);
extent_io.c:    size_t start_offset = eb->start & ((u64)PAGE_CACHE_SIZE - 1);
extent_io.c:    size_t start_offset = eb->start & ((u64)PAGE_CACHE_SIZE - 1);
extent_io.c:    size_t start_offset = eb->start & ((u64)PAGE_CACHE_SIZE - 1);
extent_io.c:    size_t start_offset = eb->start & ((u64)PAGE_CACHE_SIZE - 1);
extent_io.c:    size_t start_offset = dst->start & ((u64)PAGE_CACHE_SIZE - 1);
extent_io.c:    size_t start_offset = dst->start & ((u64)PAGE_CACHE_SIZE - 1);
extent_io.c:    size_t start_offset = dst->start & ((u64)PAGE_CACHE_SIZE - 1);

// without u64:
[root@localhost btrfs]# grep '(PAGE_CACHE_SIZE - 1)' *
compression.c:                  size_t zero_offset = isize & (PAGE_CACHE_SIZE - 1);
extent_io.c:                    unsigned long offset = (*start) & (PAGE_CACHE_SIZE - 1);
extent_io.c:            size_t zero_offset = last_byte & (PAGE_CACHE_SIZE - 1);
extent_io.c:    pg_offset = i_size & (PAGE_CACHE_SIZE - 1);
extent_io.c:            block_off_start = block_start & (PAGE_CACHE_SIZE - 1);
extent_io.c:            page_offset = block_start & (PAGE_CACHE_SIZE - 1);
extent_io.c:            if ((i == 0 && (eb->start & (PAGE_CACHE_SIZE - 1))) ||
extent_io.c:                 ((eb->start + eb->len) & (PAGE_CACHE_SIZE - 1)))) {
extent_io.c:    size_t offset = start & (PAGE_CACHE_SIZE - 1);
file.c: int offset = pos & (PAGE_CACHE_SIZE - 1);
file.c: if ((pos & (PAGE_CACHE_SIZE - 1))) {
file.c: if ((pos + count) & (PAGE_CACHE_SIZE - 1)) {
file.c:         size_t offset = pos & (PAGE_CACHE_SIZE - 1);
file-item.c:            memcpy(eb_token + ((unsigned long)item & (PAGE_CACHE_SIZE - 1)),
inode.c:                offset = start & (PAGE_CACHE_SIZE - 1);
inode.c:                                (PAGE_CACHE_SIZE - 1);
inode.c:                        ~(PAGE_CACHE_SIZE - 1);
inode.c:        if ((end & (PAGE_CACHE_SIZE - 1)) == 0)

Thanks
Zhaolei

> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 



      reply	other threads:[~2010-03-31  4:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-25 12:27 [PATCH 01/18] btrfs: Remove u64 conversion for PAGE_CACHE_SIZE Miao Xie
2010-03-25 13:02 ` Chris Mason
2010-03-31  4:04   ` Zhaolei [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=4BB2C9BE.6000402@cn.fujitsu.com \
    --to=zhaolei@cn.fujitsu.com \
    --cc=chris.mason@oracle.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=miaox@cn.fujitsu.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 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.