All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext4: reuse order and buddy in mb_mark_used when buddy split
@ 2022-06-06 15:51 Jinke Han
  0 siblings, 0 replies; 4+ messages in thread
From: Jinke Han @ 2022-06-06 15:51 UTC (permalink / raw)
  To: tytso, adilger.kernel; +Cc: linux-ext4, linux-kernel, lei.rao, hanjinke

From: hanjinke <hanjinke.666@bytedance.com>

After each buddy split, mb_mark_used will search the proper order
for the block which may consume some loop in mb_find_order_for_block.
In fact, we can reuse the oder and buddy generated by the buddy split.

Reviewed by: lei.rao@intel.com
Signed-off-by: hanjinke <hanjinke.666@bytedance.com>
---
 fs/ext4/mballoc.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 9f12f29bc346..c7ac6b269dd8 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -1933,6 +1933,7 @@ static int mb_mark_used(struct ext4_buddy *e4b, struct ext4_free_extent *ex)
 	unsigned ret = 0;
 	int len0 = len;
 	void *buddy;
+	bool split = false;
 
 	BUG_ON(start + len > (e4b->bd_sb->s_blocksize << 3));
 	BUG_ON(e4b->bd_group != ex->fe_group);
@@ -1957,12 +1958,16 @@ static int mb_mark_used(struct ext4_buddy *e4b, struct ext4_free_extent *ex)
 
 	/* let's maintain buddy itself */
 	while (len) {
-		ord = mb_find_order_for_block(e4b, start);
+		if (!split)
+			ord = mb_find_order_for_block(e4b, start);
 
 		if (((start >> ord) << ord) == start && len >= (1 << ord)) {
 			/* the whole chunk may be allocated at once! */
 			mlen = 1 << ord;
-			buddy = mb_find_buddy(e4b, ord, &max);
+			if (!split)
+				buddy = mb_find_buddy(e4b, ord, &max);
+			else
+				split = false;
 			BUG_ON((start >> ord) >= max);
 			mb_set_bit(start >> ord, buddy);
 			e4b->bd_info->bb_counters[ord]--;
@@ -1989,6 +1994,7 @@ static int mb_mark_used(struct ext4_buddy *e4b, struct ext4_free_extent *ex)
 		mb_clear_bit(cur + 1, buddy);
 		e4b->bd_info->bb_counters[ord]++;
 		e4b->bd_info->bb_counters[ord]++;
+		split = true;
 	}
 	mb_set_largest_free_order(e4b->bd_sb, e4b->bd_info);
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ext4: reuse order and buddy in mb_mark_used when buddy split
  2022-06-06 15:53 Jinke Han
  2022-06-21  2:40 ` hanjinke
@ 2022-07-08  3:19 ` Theodore Ts'o
  1 sibling, 0 replies; 4+ messages in thread
From: Theodore Ts'o @ 2022-07-08  3:19 UTC (permalink / raw)
  To: adilger.kernel, hanjinke.666
  Cc: Theodore Ts'o, linux-kernel, lei.rao, linux-ext4

On Mon, 6 Jun 2022 23:53:05 +0800, Jinke Han wrote:
> From: hanjinke <hanjinke.666@bytedance.com>
> 
> After each buddy split, mb_mark_used will search the proper order
> for the block which may consume some loop in mb_find_order_for_block.
> In fact, we can reuse the oder and buddy generated by the buddy split.
> 
> Reviewed by: lei.rao@intel.com
> 
> [...]

Applied, thanks!

[1/1] ext4: reuse order and buddy in mb_mark_used when buddy split
      commit: 08779aaa3f63ccb5cb3a2b78135132231677085e

Best regards,
-- 
Theodore Ts'o <tytso@mit.edu>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ext4: reuse order and buddy in mb_mark_used when buddy split
  2022-06-06 15:53 Jinke Han
@ 2022-06-21  2:40 ` hanjinke
  2022-07-08  3:19 ` Theodore Ts'o
  1 sibling, 0 replies; 4+ messages in thread
From: hanjinke @ 2022-06-21  2:40 UTC (permalink / raw)
  To: tytso, adilger.kernel; +Cc: linux-ext4, linux-kernel, lei.rao

hi, friendly pinging...

在 2022/6/6 下午11:53, Jinke Han 写道:
> From: hanjinke <hanjinke.666@bytedance.com>
> 
> After each buddy split, mb_mark_used will search the proper order
> for the block which may consume some loop in mb_find_order_for_block.
> In fact, we can reuse the oder and buddy generated by the buddy split.
> 
> Reviewed by: lei.rao@intel.com
> Signed-off-by: hanjinke <hanjinke.666@bytedance.com>
> ---
>   fs/ext4/mballoc.c | 10 ++++++++--
>   1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index 9f12f29bc346..c7ac6b269dd8 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -1933,6 +1933,7 @@ static int mb_mark_used(struct ext4_buddy *e4b, struct ext4_free_extent *ex)
>   	unsigned ret = 0;
>   	int len0 = len;
>   	void *buddy;
> +	bool split = false;
>   
>   	BUG_ON(start + len > (e4b->bd_sb->s_blocksize << 3));
>   	BUG_ON(e4b->bd_group != ex->fe_group);
> @@ -1957,12 +1958,16 @@ static int mb_mark_used(struct ext4_buddy *e4b, struct ext4_free_extent *ex)
>   
>   	/* let's maintain buddy itself */
>   	while (len) {
> -		ord = mb_find_order_for_block(e4b, start);
> +		if (!split)
> +			ord = mb_find_order_for_block(e4b, start);
>   
>   		if (((start >> ord) << ord) == start && len >= (1 << ord)) {
>   			/* the whole chunk may be allocated at once! */
>   			mlen = 1 << ord;
> -			buddy = mb_find_buddy(e4b, ord, &max);
> +			if (!split)
> +				buddy = mb_find_buddy(e4b, ord, &max);
> +			else
> +				split = false;
>   			BUG_ON((start >> ord) >= max);
>   			mb_set_bit(start >> ord, buddy);
>   			e4b->bd_info->bb_counters[ord]--;
> @@ -1989,6 +1994,7 @@ static int mb_mark_used(struct ext4_buddy *e4b, struct ext4_free_extent *ex)
>   		mb_clear_bit(cur + 1, buddy);
>   		e4b->bd_info->bb_counters[ord]++;
>   		e4b->bd_info->bb_counters[ord]++;
> +		split = true;
>   	}
>   	mb_set_largest_free_order(e4b->bd_sb, e4b->bd_info);
>   

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] ext4: reuse order and buddy in mb_mark_used when buddy split
@ 2022-06-06 15:53 Jinke Han
  2022-06-21  2:40 ` hanjinke
  2022-07-08  3:19 ` Theodore Ts'o
  0 siblings, 2 replies; 4+ messages in thread
From: Jinke Han @ 2022-06-06 15:53 UTC (permalink / raw)
  To: tytso, adilger.kernel; +Cc: linux-ext4, linux-kernel, lei.rao, hanjinke

From: hanjinke <hanjinke.666@bytedance.com>

After each buddy split, mb_mark_used will search the proper order
for the block which may consume some loop in mb_find_order_for_block.
In fact, we can reuse the oder and buddy generated by the buddy split.

Reviewed by: lei.rao@intel.com
Signed-off-by: hanjinke <hanjinke.666@bytedance.com>
---
 fs/ext4/mballoc.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 9f12f29bc346..c7ac6b269dd8 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -1933,6 +1933,7 @@ static int mb_mark_used(struct ext4_buddy *e4b, struct ext4_free_extent *ex)
 	unsigned ret = 0;
 	int len0 = len;
 	void *buddy;
+	bool split = false;
 
 	BUG_ON(start + len > (e4b->bd_sb->s_blocksize << 3));
 	BUG_ON(e4b->bd_group != ex->fe_group);
@@ -1957,12 +1958,16 @@ static int mb_mark_used(struct ext4_buddy *e4b, struct ext4_free_extent *ex)
 
 	/* let's maintain buddy itself */
 	while (len) {
-		ord = mb_find_order_for_block(e4b, start);
+		if (!split)
+			ord = mb_find_order_for_block(e4b, start);
 
 		if (((start >> ord) << ord) == start && len >= (1 << ord)) {
 			/* the whole chunk may be allocated at once! */
 			mlen = 1 << ord;
-			buddy = mb_find_buddy(e4b, ord, &max);
+			if (!split)
+				buddy = mb_find_buddy(e4b, ord, &max);
+			else
+				split = false;
 			BUG_ON((start >> ord) >= max);
 			mb_set_bit(start >> ord, buddy);
 			e4b->bd_info->bb_counters[ord]--;
@@ -1989,6 +1994,7 @@ static int mb_mark_used(struct ext4_buddy *e4b, struct ext4_free_extent *ex)
 		mb_clear_bit(cur + 1, buddy);
 		e4b->bd_info->bb_counters[ord]++;
 		e4b->bd_info->bb_counters[ord]++;
+		split = true;
 	}
 	mb_set_largest_free_order(e4b->bd_sb, e4b->bd_info);
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-07-08  3:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-06 15:51 [PATCH] ext4: reuse order and buddy in mb_mark_used when buddy split Jinke Han
2022-06-06 15:53 Jinke Han
2022-06-21  2:40 ` hanjinke
2022-07-08  3:19 ` Theodore Ts'o

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.