linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mballoc: don't change cpa if cur_distance is equal to new_distance
@ 2011-01-24 17:09 Coly Li
  0 siblings, 0 replies; only message in thread
From: Coly Li @ 2011-01-24 17:09 UTC (permalink / raw)
  To: linux-ext4

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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2011-01-24 16:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-24 17:09 [PATCH] mballoc: don't change cpa if cur_distance is equal to new_distance Coly Li

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).