public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2 1/3] block: Requeue req as head if driver touched it
@ 2022-11-14 15:29 Christian Löhle
  2022-11-16 12:52 ` Ulf Hansson
  0 siblings, 1 reply; 2+ messages in thread
From: Christian Löhle @ 2022-11-14 15:29 UTC (permalink / raw)
  To: ulf.hansson@linaro.org, axboe@kernel.dk,
	linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-block@vger.kernel.org
  Cc: Avri Altman, adrian.hunter@intel.com, vincent.whitchurch@axis.com

In case the driver set RQF_DONTPREP flag, requeue the request as head as
it is likely that the backing storage already had a request to an
adjacent region, so getting the requeued request out as soon as possible
may give us some performance benefit.

The are various reasons a driver may requeue a request
(and therefore RQF_DONTPREP being set).
One reason may be that the driver or the hardware cannot satisfy
the block layer alignment/sizes.

This for example is the case with mmcblk with a host driver that
cannot deal with multiple block transfers.
Consider a request for lba 42 for one page so 4K or 8 blocks.
mmcblk will do a single block request for lba 42 and requeue for
the rest if the host can only perform single block transfers.
In this case the device only delivered 512 bytes of data at lba 42,
but may have performed a readahead itself for the following lbas,
or do an 'implicit' readahead as it only deals with larger block
size mappings itself.
In that case it would be beneificial if the request for lba 43 and
the rest of the remaining blocks follow immediately after the initial
lba 42 request.
Requeueing already partially processed requests as head preserves the
intended request order (unless the driver has a queue of its own)
and therefore mitigates this problem .

Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
---
-v2: Extended commit message with example use case, no code change

 block/blk-mq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 33292c01875d..d863c826fb23 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1429,7 +1429,7 @@ static void blk_mq_requeue_work(struct work_struct *work)
 		 * merge.
 		 */
 		if (rq->rq_flags & RQF_DONTPREP)
-			blk_mq_request_bypass_insert(rq, false, false);
+			blk_mq_request_bypass_insert(rq, true, false);
 		else
 			blk_mq_sched_insert_request(rq, true, false, false);
 	}
-- 
2.37.3
Hyperstone GmbH | Reichenaustr. 39a  | 78467 Konstanz
Managing Director: Dr. Jan Peter Berns.
Commercial register of local courts: Freiburg HRB381782


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

* Re: [PATCHv2 1/3] block: Requeue req as head if driver touched it
  2022-11-14 15:29 [PATCHv2 1/3] block: Requeue req as head if driver touched it Christian Löhle
@ 2022-11-16 12:52 ` Ulf Hansson
  0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2022-11-16 12:52 UTC (permalink / raw)
  To: Christian Löhle
  Cc: axboe@kernel.dk, linux-mmc@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
	Avri Altman, adrian.hunter@intel.com, vincent.whitchurch@axis.com

On Mon, 14 Nov 2022 at 16:29, Christian Löhle <CLoehle@hyperstone.com> wrote:
>
> In case the driver set RQF_DONTPREP flag, requeue the request as head as
> it is likely that the backing storage already had a request to an
> adjacent region, so getting the requeued request out as soon as possible
> may give us some performance benefit.
>
> The are various reasons a driver may requeue a request
> (and therefore RQF_DONTPREP being set).
> One reason may be that the driver or the hardware cannot satisfy
> the block layer alignment/sizes.
>
> This for example is the case with mmcblk with a host driver that
> cannot deal with multiple block transfers.
> Consider a request for lba 42 for one page so 4K or 8 blocks.
> mmcblk will do a single block request for lba 42 and requeue for
> the rest if the host can only perform single block transfers.
> In this case the device only delivered 512 bytes of data at lba 42,
> but may have performed a readahead itself for the following lbas,
> or do an 'implicit' readahead as it only deals with larger block
> size mappings itself.
> In that case it would be beneificial if the request for lba 43 and
> the rest of the remaining blocks follow immediately after the initial
> lba 42 request.
> Requeueing already partially processed requests as head preserves the
> intended request order (unless the driver has a queue of its own)
> and therefore mitigates this problem .
>
> Signed-off-by: Christian Loehle <cloehle@hyperstone.com>

Thanks for updating the commit message!

Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>

As I said for v1, this seems reasonable to me, but I am deferring to
Jens to get his opinion. Beyond that, I will have a look at pacth2 and
patch3 too.

Kind regards
Uffe

> ---
> -v2: Extended commit message with example use case, no code change
>
>  block/blk-mq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 33292c01875d..d863c826fb23 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -1429,7 +1429,7 @@ static void blk_mq_requeue_work(struct work_struct *work)
>                  * merge.
>                  */
>                 if (rq->rq_flags & RQF_DONTPREP)
> -                       blk_mq_request_bypass_insert(rq, false, false);
> +                       blk_mq_request_bypass_insert(rq, true, false);
>                 else
>                         blk_mq_sched_insert_request(rq, true, false, false);
>         }
> --
> 2.37.3
> Hyperstone GmbH | Reichenaustr. 39a  | 78467 Konstanz
> Managing Director: Dr. Jan Peter Berns.
> Commercial register of local courts: Freiburg HRB381782
>

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

end of thread, other threads:[~2022-11-16 12:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-14 15:29 [PATCHv2 1/3] block: Requeue req as head if driver touched it Christian Löhle
2022-11-16 12:52 ` Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox