scsi: scsi_debug: Improve command duration calculation
authorDouglas Gilbert <dgilbert@interlog.com>
Tue, 21 Apr 2020 15:14:21 +0000 (11:14 -0400)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 5 May 2020 03:06:20 +0000 (23:06 -0400)
commita2aede970a8e12cadb8be779066cd64e6dd37e82
tree1ca979de5fd96f1730f0773c4c1ea55b4420281e
parent67da413f26afc7522250bf5c9231f6711a9e7dfd
scsi: scsi_debug: Improve command duration calculation

Previously the code did the work implied by the given SCSI command and
after that it waited for a timer based on the user specified command
duration to be exhausted before informing the mid-level that the command
was complete. For short command durations, the time to complete the work
implied by the SCSI command could be significant compared to the user
specified command duration.

For example a WRITE of 128 blocks (say 512 bytes each) on a machine that
can copy from main memory to main memory at a rate of 10 GB/sec will take
around 6.4 microseconds to do that copy.  If the user specified a command
duration of 5 microseconds (ndelay=5000), should the driver do a further
delay of 5 microseconds after the copy or return immediately because 6.4 >
5 ?

The action prior to this patch was to always do the timer based
delay. After this patch, for ndelay values less than 1 millisecond, this
driver will complete the command immediately.  And in the case where the
user specified delay was 7 microseconds, a timer delay of 600 nanoseconds
will be set ((7 - 6.4) * 1000).

Link: https://lore.kernel.org/r/20200421151424.32668-6-dgilbert@interlog.com
Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/scsi_debug.c