scsi: ufs: requests completion handling
Subsystems (2)
PATCH 2/2 scsi: ufs: requests completion handling
The patch solves the request completion report order. At the current implementation, when multiple requests end at the same interrupt call, the requests reported as completed according to a bitmap scan from the lowest tags to the highest, regardless the requests priority. That cause to a priority unfairness and starvation of requests with a high tags.
SCSI Architecture Model 5 defines 3 task-attributes that are part of each SCSI command, and integrated into each Command UPIU. The task-attribute is for the device usage, it determines the order in which the device prioritizes the requests.
The task-attributes according to their priority are (from high to low):
HEAD OF QUEUE, ORDERED and SIMPLE. There is a queue per task-attribute. Each request is assigned to one of the above sw queues according to its task attribute field.
Requests which are not SCSI commands (native UFS) will be assigned to the lowest priority queue, since there is no much difference between completing it first or last..
When request is completed, we go over the queues (from the queue's highest priority to the lowest) and report the completion.
Requests are removed from the queue in case of command completion or when aborting pending command.
drivers/scsi/ufs/ufs.h +1 -1
@@ -91,7 +91,7 @@ enum { };/* UPIU Task Attributes */ -enum { +enum upiu_task_attr {UPIU_TASK_ATTR_SIMPLE =0x00 ,UPIU_TASK_ATTR_ORDERED =0x01 ,UPIU_TASK_ATTR_HEADQ =0x02 ,
drivers/scsi/ufs/ufshcd.c +116 -20
194 lines not on this page · raw message
drivers/scsi/ufs/ufshcd.h +11 -1
@@ -75,6 +75,13 @@ enum dev_cmd_type { DEV_CMD_TYPE_QUERY = 0x1, }; +enum req_queue_index { +REQS_QUEUE_TASK_ATTR_HEADQ =0 , +REQS_QUEUE_TASK_ATTR_ORDERED =1 , +REQS_QUEUE_TASK_ATTR_SIMPLE =2 , +NUM_OF_REQ_QUEUE , +}; +/** * struct uic_command - UIC command structure * @command: UIC command
@@ -115,7 +122,7 @@ struct ufshcd_lrb {struct utp_upiu_req *ucd_req_ptr;struct utp_upiu_rsp *ucd_rsp_ptr;struct ufshcd_sg_entry *ucd_prdt_ptr; - +struct list_head list;struct scsi_cmnd *cmd;u8 *sense_buffer;unsigned int sense_bufflen;
@@ -123,6 +130,7 @@ struct ufshcd_lrb {int command_type;int task_tag; +enum upiu_task_attr task_attr;unsigned int lun;bool intr_cmd; };
@@ -292,6 +300,8 @@ struct ufs_hba {bool auto_bkops_enabled; +struct list_head reqs_list[NUM_OF_REQ_QUEUE ]; +#ifdef CONFIG_DEBUG_FS struct ufs_stats ufs_stats;struct debugfs_files debugfs_files;
Signature · 2 lines
QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
James Bottomley
maintainerQuoted 5 lines · Raviv Shvili
The patch solves the request completion report order. At the current implementation, when multiple requests end at the same interrupt call, the requests reported as completed according to a bitmap scan from the lowest tags to the highest, regardless the requests priority. That cause to a priority unfairness and starvation of requests with a high tags.
It does? Why? What seems to happen is that you loop over all the pending requests and call done for them. The way SCSI handles done commands is that it queues them to the softirq, so there doesn't look to be any real unfairness problem here.
Quoted 12 lines
SCSI Architecture Model 5 defines 3 task-attributes that are part of each SCSI command, and integrated into each Command UPIU. The task-attribute is for the device usage, it determines the order in which the device prioritizes the requests.
The task-attributes according to their priority are (from high to low):
HEAD OF QUEUE, ORDERED and SIMPLE. There is a queue per task-attribute. Each request is assigned to one of the above sw queues according to its task attribute field.
Requests which are not SCSI commands (native UFS) will be assigned to the lowest priority queue, since there is no much difference between completing it first or last..
Quoted 6 lines
When request is completed, we go over the queues (from the queue's highest priority to the lowest) and report the completion.
Requests are removed from the queue in case of command completion or when aborting pending command.
Since we never use anything other than SIMPLE attributes, this rather looks like a solution in search of a problem.
James
Hi James,
See reply inline
Thanks,
Yaniv
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of James Bottomley
Sent: Thursday, August 29, 2013 12:28 PM
To: Raviv Shvili
Cc: [email protected]; [email protected]; open list:SCSI SUBSYSTEM; open list
Subject: Re: [RFC/PATCH 2/2] scsi: ufs: requests completion handling
Quoted 5 lines · Raviv Shvili
The patch solves the request completion report order. At the current implementation, when multiple requests end at the same interrupt call, the requests reported as completed according to a bitmap scan from the lowest tags to the highest, regardless the requests priority. That cause to a priority unfairness and starvation of requests with a high
tags.
It does? Why? What seems to happen is that you loop over all the pending requests and call done for them. The way SCSI handles done commands is that it queues them to the softirq, so there doesn't look to be any real unfairness problem here.
<yaniv> The unfairness is that currently the loop goes over the tags from 0 to NUTRS(i.e 31), and calls done() at this order, regardless of the task_attribute they hold.
Also, the benefit in performance is that instead of going over NUTRS (32) iteration, we simple call done() only for the exact of completed request (and according to their task_attribute priority).
Scenario: a new HEAD_OF_QUEUE request that is completed during the current loop, will be served only in the next interrupt (since the DOORBELL will be read again only in the next interrupt), and saying it is a high tag, it will be completed lastly. This patch will fix it, as I see that.
Quoted 12 lines
SCSI Architecture Model 5 defines 3 task-attributes that are part of each SCSI command, and integrated into each Command UPIU. The task-attribute is for the device usage, it determines the order in which the device prioritizes the requests.
The task-attributes according to their priority are (from high to low):
HEAD OF QUEUE, ORDERED and SIMPLE. There is a queue per task-attribute. Each request is assigned to one of the above sw queues according to its task attribute field.
Requests which are not SCSI commands (native UFS) will be assigned to the lowest priority queue, since there is no much difference between completing it first or last..
Quoted 5 lines
When request is completed, we go over the queues (from the queue's highest priority to the lowest) and report the completion.
Requests are removed from the queue in case of command completion or when aborting pending command.
Since we never use anything other than SIMPLE attributes, this rather looks like a solution in search of a problem.
James
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html
James Bottomley
maintainerQuoted 29 lines · Yaniv Gardi
Hi James,
See reply inline
Thanks,
Yaniv-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of James Bottomley
Sent: Thursday, August 29, 2013 12:28 PM
To: Raviv Shvili
Cc: [email protected]; [email protected]; open list:SCSI SUBSYSTEM; open list
Subject: Re: [RFC/PATCH 2/2] scsi: ufs: requests completion handlingQuoted 5 lines · Raviv Shvili
The patch solves the request completion report order. At the current implementation, when multiple requests end at the same interrupt call, the requests reported as completed according to a bitmap scan from the lowest tags to the highest, regardless the requests priority. That cause to a priority unfairness and starvation of requests with a high
tags.
It does? Why? What seems to happen is that you loop over all the pending requests and call done for them. The way SCSI handles done commands is that it queues them to the softirq, so there doesn't look to be any real unfairness problem here.
Quoted 9 lines
<yaniv> The unfairness is that currently the loop goes over the tags from 0
to NUTRS(i.e 31), and callsdone()at this order, regardless of thetask_attributethey hold.
Also, the benefit in performance is that instead of going over NUTRS
(32)
iteration, we simple calldone()only for the exact of completed request
(and according to theirtask_attributepriority).
Yes, I know that. But all done does is queue the completion to the softirq. All you get with this is a reordering of that queue. If you can actually measure the performance impact of that, I'd be very surprised. We're talking under a microsecond in a round trip activity that takes tens to hundreds of miliseconds to issue and complete.
Quoted 7 lines
Scenario: a new
HEAD_OF_QUEUErequest that is completed during the current
loop, will be served only in the next interrupt (since the DOORBELL will be
read again only in the next interrupt), and saying it is a high tag, it will
be completed lastly. This patch will fix it, as I see that.
It fixes something that isn't a problem. The softirq won't even be activated until all pending interrupts are serviced, so a command arriving in the middle of processing gets immediately serviced on the next interrupt before the softirq activates.
James
Quoted 33 lines
Quoted 12 lines
SCSI Architecture Model 5 defines 3 task-attributes that are part of each SCSI command, and integrated into each Command UPIU. The task-attribute is for the device usage, it determines the order in which the device prioritizes the requests.
The task-attributes according to their priority are (from high to low):
HEAD OF QUEUE, ORDERED and SIMPLE. There is a queue per task-attribute. Each request is assigned to one of the above sw queues according to its task attribute field.
Requests which are not SCSI commands (native UFS) will be assigned to the lowest priority queue, since there is no much difference between completing it first or last..Quoted 5 lines
When request is completed, we go over the queues (from the queue's highest priority to the lowest) and report the completion.
Requests are removed from the queue in case of command completion or when aborting pending command.
Since we never use anything other than SIMPLE attributes, this rather looks like a solution in search of a problem.
James
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html