linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ted Ts'o <tytso@mit.edu>
To: Coly Li <i@coly.li>
Cc: linux-ext4@vger.kernel.org, Alex Tomas <alex@clusterfs.com>,
	Theodore Tso <tytso@google.com>
Subject: Re: [PATCH 2/5] mballoc: remove unncessary mb_find_buddy()
Date: Thu, 24 Feb 2011 14:07:08 -0500	[thread overview]
Message-ID: <20110224190708.GV2924@thunk.org> (raw)
In-Reply-To: <4D4E2961.6020007@coly.li>

Added to the ext4 patch queue, thanks!!

      	     	  	       - Ted

On Sun, Feb 06, 2011 at 12:53:53PM +0800, Coly Li wrote:
> In __mb_check_buddy(), look at the bellowed code,
> 
>  591         fstart = -1;
>  592         buddy = mb_find_buddy(e4b, 0, &max);
>  593         for (i = 0; i < max; i++) {
>  594                 if (!mb_test_bit(i, buddy)) {
>  595                         MB_CHECK_ASSERT(i >= e4b->bd_info->bb_first_free);
>  596                         if (fstart == -1) {
>  597                                 fragments++;
>  598                                 fstart = i;
>  599                         }
>  600                         continue;
>  601                 }
>  602                 fstart = -1;
>  603                 /* check used bits only */
>  604                 for (j = 0; j < e4b->bd_blkbits + 1; j++) {
>  605                         buddy2 = mb_find_buddy(e4b, j, &max2);
>  606                         k = i >> j;
>  607                         MB_CHECK_ASSERT(k < max2);
>  608                         MB_CHECK_ASSERT(mb_test_bit(k, buddy2));
>  609                 }
>  610         }
>  611         MB_CHECK_ASSERT(!EXT4_MB_GRP_NEED_INIT(e4b->bd_info));
>  612         MB_CHECK_ASSERT(e4b->bd_info->bb_fragments == fragments);
>  613
>  614         grp = ext4_get_group_info(sb, e4b->bd_group);
>  615         buddy = mb_find_buddy(e4b, 0, &max);
> 
> On line 592, buddy is fetched by mb_find_buddy() with order 0, between
> line 593 to line 615, buddy is not changed, therefore there is
> no need to fetch buddy again from mb_find_buddy() with order 0 again.
> 
> We can safely remove the second mb_find_buddy() on line 615.
> 
> Signed-off-by: Coly Li <bosong.ly@taobao.com>
> Cc: Alex Tomas <alex@clusterfs.com>
> Cc: Theodore Tso <tytso@google.com>

      reply	other threads:[~2011-02-24 19:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-06  4:53 [PATCH 2/5] mballoc: remove unncessary mb_find_buddy() Coly Li
2011-02-24 19:07 ` Ted Ts'o [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=20110224190708.GV2924@thunk.org \
    --to=tytso@mit.edu \
    --cc=alex@clusterfs.com \
    --cc=i@coly.li \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@google.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).