mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-16 18:08:20 +00:00
scsi: scsi_debug: Fix cmd duration calculation
In some cases, sdebug_defer::cmpl_ts (completion timestamp) wasn't being properly set when REQ_HIPRI was given. Fix that and improve code to only call ktime_get_boottime_ns() for commands with REQ_HIPRI set as cmpl_ts is only used in that case. Link: https://lore.kernel.org/r/20210304014107.307625-1-dgilbert@interlog.com Signed-off-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
4309ea74b0
commit
771f712ba5
@ -5367,6 +5367,7 @@ static int schedule_resp(struct scsi_cmnd *cmnd, struct sdebug_dev_info *devip,
|
|||||||
{
|
{
|
||||||
bool new_sd_dp;
|
bool new_sd_dp;
|
||||||
bool inject = false;
|
bool inject = false;
|
||||||
|
bool hipri = (cmnd->request->cmd_flags & REQ_HIPRI);
|
||||||
int k, num_in_q, qdepth;
|
int k, num_in_q, qdepth;
|
||||||
unsigned long iflags;
|
unsigned long iflags;
|
||||||
u64 ns_from_boot = 0;
|
u64 ns_from_boot = 0;
|
||||||
@ -5453,7 +5454,7 @@ static int schedule_resp(struct scsi_cmnd *cmnd, struct sdebug_dev_info *devip,
|
|||||||
if (sdebug_host_max_queue)
|
if (sdebug_host_max_queue)
|
||||||
sd_dp->hc_idx = get_tag(cmnd);
|
sd_dp->hc_idx = get_tag(cmnd);
|
||||||
|
|
||||||
if (ndelay > 0 && ndelay < INCLUSIVE_TIMING_MAX_NS)
|
if (hipri)
|
||||||
ns_from_boot = ktime_get_boottime_ns();
|
ns_from_boot = ktime_get_boottime_ns();
|
||||||
|
|
||||||
/* one of the resp_*() response functions is called here */
|
/* one of the resp_*() response functions is called here */
|
||||||
@ -5513,8 +5514,8 @@ static int schedule_resp(struct scsi_cmnd *cmnd, struct sdebug_dev_info *devip,
|
|||||||
kt -= d;
|
kt -= d;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sd_dp->cmpl_ts = ktime_add(ns_to_ktime(ns_from_boot), kt);
|
if (hipri) {
|
||||||
if (cmnd->request->cmd_flags & REQ_HIPRI) {
|
sd_dp->cmpl_ts = ktime_add(ns_to_ktime(ns_from_boot), kt);
|
||||||
spin_lock_irqsave(&sqp->qc_lock, iflags);
|
spin_lock_irqsave(&sqp->qc_lock, iflags);
|
||||||
if (!sd_dp->init_poll) {
|
if (!sd_dp->init_poll) {
|
||||||
sd_dp->init_poll = true;
|
sd_dp->init_poll = true;
|
||||||
@ -5544,8 +5545,8 @@ static int schedule_resp(struct scsi_cmnd *cmnd, struct sdebug_dev_info *devip,
|
|||||||
if (unlikely((sdebug_opts & SDEBUG_OPT_CMD_ABORT) &&
|
if (unlikely((sdebug_opts & SDEBUG_OPT_CMD_ABORT) &&
|
||||||
atomic_read(&sdeb_inject_pending)))
|
atomic_read(&sdeb_inject_pending)))
|
||||||
sd_dp->aborted = true;
|
sd_dp->aborted = true;
|
||||||
sd_dp->cmpl_ts = ns_to_ktime(ns_from_boot);
|
if (hipri) {
|
||||||
if (cmnd->request->cmd_flags & REQ_HIPRI) {
|
sd_dp->cmpl_ts = ns_to_ktime(ns_from_boot);
|
||||||
spin_lock_irqsave(&sqp->qc_lock, iflags);
|
spin_lock_irqsave(&sqp->qc_lock, iflags);
|
||||||
if (!sd_dp->init_poll) {
|
if (!sd_dp->init_poll) {
|
||||||
sd_dp->init_poll = true;
|
sd_dp->init_poll = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user