linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Coly Li <i@coly.li>
To: linux-ext4@vger.kernel.org
Subject: [PATCH] mballoc: don't change cpa if cur_distance is equal to new_distance
Date: Tue, 25 Jan 2011 01:09:12 +0800	[thread overview]
Message-ID: <4D3DB238.80804@coly.li> (raw)

In ext4_mb_check_group_pa(), cur_distance is selected to return only when it's smaller than new_distance, this is 
unreasonable. If cur_distance is equal to new_distance, current code will return new_distance to update cpa from 
ext4_mb_use_preallocated(), which is unnecessary and a wast of CPU cycles.

This patch makes new_distance to return only when it's smaller then cur_distance, which avoids unnecessary cpa update in 
ext4_mb_use_preallocated().

Signed-off-by: Coly Li <bosong.ly@taobao.com>
---
  fs/ext4/mballoc.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 851f49b..5f564d7 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -3188,7 +3188,7 @@ ext4_mb_check_group_pa(ext4_fsblk_t goal_block,
  	cur_distance = abs(goal_block - cpa->pa_pstart);
  	new_distance = abs(goal_block - pa->pa_pstart);

-	if (cur_distance < new_distance)
+	if (cur_distance <= new_distance)
  		return cpa;

  	/* drop the previous reference */
-- 
Coly Li

                 reply	other threads:[~2011-01-24 16:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=4D3DB238.80804@coly.li \
    --to=i@coly.li \
    --cc=linux-ext4@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 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).