Re: [PATCH 1/2] scsi_host: add support for request batching

From: Bart Van Assche
Date: Thu May 30 2019 - 13:57:55 EST


On 5/30/19 8:54 AM, Paolo Bonzini wrote:
> On 30/05/19 17:36, Bart Van Assche wrote:
>> On 5/30/19 4:28 AM, Paolo Bonzini wrote:
>>> +static const struct blk_mq_ops scsi_mq_ops_no_commit = {
>>> +ÂÂÂ .get_budgetÂÂÂ = scsi_mq_get_budget,
>>> +ÂÂÂ .put_budgetÂÂÂ = scsi_mq_put_budget,
>>> +ÂÂÂ .queue_rqÂÂÂ = scsi_queue_rq,
>>> +ÂÂÂ .completeÂÂÂ = scsi_softirq_done,
>>> +ÂÂÂ .timeoutÂÂÂ = scsi_timeout,
>>> +#ifdef CONFIG_BLK_DEBUG_FS
>>> +ÂÂÂ .show_rqÂÂÂ = scsi_show_rq,
>>> +#endif
>>> +ÂÂÂ .init_requestÂÂÂ = scsi_mq_init_request,
>>> +ÂÂÂ .exit_requestÂÂÂ = scsi_mq_exit_request,
>>> +ÂÂÂ .initialize_rq_fn = scsi_initialize_rq,
>>> +ÂÂÂ .busyÂÂÂÂÂÂÂ = scsi_mq_lld_busy,
>>> +ÂÂÂ .map_queuesÂÂÂ = scsi_map_queues,
>>> +};
>>> +
>>> +static void scsi_commit_rqs(struct blk_mq_hw_ctx *hctx)
>>> +{
>>> +ÂÂÂ struct request_queue *q = hctx->queue;
>>> +ÂÂÂ struct scsi_device *sdev = q->queuedata;
>>> +ÂÂÂ struct Scsi_Host *shost = sdev->host;
>>> +
>>> +ÂÂÂ shost->hostt->commit_rqs(shost, hctx->queue_num);
>>> +}
>>> +
>>> Â static const struct blk_mq_ops scsi_mq_ops = {
>>> ÂÂÂÂÂ .get_budgetÂÂÂ = scsi_mq_get_budget,
>>> ÂÂÂÂÂ .put_budgetÂÂÂ = scsi_mq_put_budget,
>>> ÂÂÂÂÂ .queue_rqÂÂÂ = scsi_queue_rq,
>>> +ÂÂÂ .commit_rqsÂÂÂ = scsi_commit_rqs,
>>> ÂÂÂÂÂ .completeÂÂÂ = scsi_softirq_done,
>>> ÂÂÂÂÂ .timeoutÂÂÂ = scsi_timeout,
>>> Â #ifdef CONFIG_BLK_DEBUG_FS
>>
>> Hi Paolo,
>>
>> Have you considered to modify the block layer such that a single
>> scsi_mq_ops structure can be used for all SCSI LLD types?
>
> Yes, but I don't think it's possible to do it in a nice way.
> Any adjustment we make to the block layer to fit the SCSI subsystem's
> desires would make all other block drivers uglier, so I chose to confine
> the ugliness here.
>
> The root issue is that the SCSI subsystem is unique in how it sits on
> top of the block layer; this is the famous "adapter" (or "midlayer",
> though that is confusing when talking about SCSI) design that Linux
> usually tries to avoid.

As far as I can see the only impact of defining an empty commit_rqs
callback on the queueing behavior is that blk_mq_make_request() will
queue requests for multiple hwqs on the plug list instead of requests
for a single hwq. The plug list is sorted by hwq before it is submitted
to a block driver. If that helps NVMe performance it should also help
SCSI performance. How about always setting commit_rqs = scsi_commit_rqs
in scsi_mq_ops?

Thanks,

Bart.