diff mbox series

[1/2] dm-bufio: improve the performance of __dm_bufio_prefetch

Message ID 20250402070934.2387587-1-weilongping@oppo.com (mailing list archive)
State Accepted, archived
Delegated to: Mikulas Patocka
Headers show
Series [1/2] dm-bufio: improve the performance of __dm_bufio_prefetch | expand

Commit Message

LongPing Wei April 2, 2025, 7:09 a.m. UTC
1. call blk_flush_plug when cache hit as the address of the subsequent
 bio is no longer contiguous with the previous bio;
2. skip cond_resched when ioprio class is rt;

Signed-off-by: LongPing Wei <weilongping@oppo.com>
---
 drivers/md/dm-bufio.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Eric Biggers April 2, 2025, 5:43 p.m. UTC | #1
On Wed, Apr 02, 2025 at 03:09:34PM +0800, LongPing Wei wrote:
> 1. call blk_flush_plug when cache hit as the address of the subsequent
>  bio is no longer contiguous with the previous bio;
> 2. skip cond_resched when ioprio class is rt;
> 
> Signed-off-by: LongPing Wei <weilongping@oppo.com>
> ---
>  drivers/md/dm-bufio.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

Looks fine:

Reviewed-by: Eric Biggers <ebiggers@kernel.org>

But I do think the prefetching should be reworked to be along the lines of what
I suggested here:
https://lore.kernel.org/dm-devel/20250327170524.GF1425@sol.localdomain/
Any chance you're interested in helping with that?

It also *might* be the case that the prefetching is no longer helpful and should
just be removed.  Especially if dm-verity will start prefetching the whole hash
tree anyway, as your other patch does.

- Eric
LongPing Wei April 3, 2025, 12:12 a.m. UTC | #2
On 2025/4/3 1:43, Eric Biggers wrote:
> On Wed, Apr 02, 2025 at 03:09:34PM +0800, LongPing Wei wrote:
>> 1. call blk_flush_plug when cache hit as the address of the subsequent
>>   bio is no longer contiguous with the previous bio;
>> 2. skip cond_resched when ioprio class is rt;
>>
>> Signed-off-by: LongPing Wei <weilongping@oppo.com>
>> ---
>>   drivers/md/dm-bufio.c | 5 ++++-
>>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> Looks fine:
> 
> Reviewed-by: Eric Biggers <ebiggers@kernel.org>
> 
> But I do think the prefetching should be reworked to be along the lines of what
> I suggested here:
> https://lore.kernel.org/dm-devel/20250327170524.GF1425@sol.localdomain/
> Any chance you're interested in helping with that?
> 

How about calling verity_prefetch_io directly in verity_map only when
use_bh_wq return true for this dm io? The size of dm io may be a greate
number as dm-verity doesn't set a max io length. Mikulas once mentioned
that there was a problem that caused him to give up doing so. Has that
issue been fixed?

> It also *might* be the case that the prefetching is no longer helpful and should
> just be removed.  Especially if dm-verity will start prefetching the whole hash
> tree anyway, as your other patch does.

It seems that we cannot just removed the prefetching in verity_map as
the cahche in dm-bufio may be shrinked.

> 
> - Eric

LongPing
Christoph Hellwig April 10, 2025, 8:29 a.m. UTC | #3
This commit message is extremtly sparse.  Not helped by the fact that
the series also misses a cover letter.

On Wed, Apr 02, 2025 at 03:09:34PM +0800, LongPing Wei wrote:
> 1. call blk_flush_plug when cache hit as the address of the subsequent
>  bio is no longer contiguous with the previous bio;

As you found out blk_flush_plug is not exported, and that for a good
reason.  This also completely fails to explain why you want to do
this and what the measured benefit is.

> 2. skip cond_resched when ioprio class is rt;

Same here.  Also these look compeltely unrelated and I have no idea
why they are in the same patch.
diff mbox series

Patch

diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
index 9c8ed65cd87e..ec8392fbcf5d 100644
--- a/drivers/md/dm-bufio.c
+++ b/drivers/md/dm-bufio.c
@@ -1981,6 +1981,7 @@  static void __dm_bufio_prefetch(struct dm_bufio_client *c,
 			unsigned short ioprio)
 {
 	struct blk_plug plug;
+	unsigned short ioprio_class = IOPRIO_PRIO_CLASS(ioprio);
 
 	LIST_HEAD(write_list);
 
@@ -1997,6 +1998,7 @@  static void __dm_bufio_prefetch(struct dm_bufio_client *c,
 		if (b) {
 			/* already in cache */
 			cache_put_and_wake(c, b);
+			blk_flush_plug(&plug, false);
 			continue;
 		}
 
@@ -2017,7 +2019,8 @@  static void __dm_bufio_prefetch(struct dm_bufio_client *c,
 				submit_io(b, REQ_OP_READ, ioprio, read_endio);
 			dm_bufio_release(b);
 
-			cond_resched();
+			if (ioprio_class != IOPRIO_CLASS_RT)
+				cond_resched();
 
 			if (!n_blocks)
 				goto flush_plug;