diff --git a/scst/include/scst.h b/scst/include/scst.h index 4aecce44c..0cb988777 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -1813,10 +1813,7 @@ struct scst_tgt { /** * struct scst_lat_stat_entry - SCST command processing latency data - * @last_update: Time of last update of this data structure in 100 ns. * @count: Number of samples for which statistics have been gathered. - * @last_update_tsc: Time of the last update of this data structure in 100 - * clock cycles. * @min: Minimum processing time in nanoseconds. * @max: Maximum processing time. * @sum: Processing time sum. @@ -1829,12 +1826,8 @@ struct scst_tgt { * Size: 96 bytes. */ struct scst_lat_stat_entry { - ktime_t last_update; uint32_t count; uint32_t padding; -#ifdef SCST_MEASURE_CLOCK_CYCLES - uint64_t last_update_tsc; -#endif uint64_t min; uint64_t max; uint64_t sum; @@ -2144,6 +2137,13 @@ struct scst_cmd { /* Cmd state, one of SCST_CMD_STATE_* constants */ enum scst_cmd_state state; + /* Time of last state update in 100 ns. */ + ktime_t last_state_update; +#ifdef SCST_MEASURE_CLOCK_CYCLES + /* Time of the last state update in 100 clock cycles.*/ + uint64_t last_state_update_tsc; +#endif + /************************************************************* ** Cmd's flags *************************************************************/ diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 13b560b17..4333a9489 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -15848,7 +15848,6 @@ void scst_check_debug_sn(struct scst_cmd *cmd) static void __scst_update_latency_stats(struct scst_cmd *cmd, struct scst_lat_stat_entry *stat, - struct scst_lat_stat_entry *new_stat, const ktime_t now, uint64_t nowc) { int64_t delta; @@ -15856,8 +15855,8 @@ static void __scst_update_latency_stats(struct scst_cmd *cmd, int64_t deltac; #endif - if (stat && ktime_to_ns(stat->last_update) != 0) { - delta = ktime_to_ns(ktime_sub(now, stat->last_update)); + if (stat && ktime_to_ns(cmd->last_state_update) != 0) { + delta = ktime_to_ns(ktime_sub(now, cmd->last_state_update)); if (delta < 0 || delta > NSEC_PER_SEC) { printk_once(KERN_INFO "%d: ignoring large time delta %lld\n", cmd->state, delta); @@ -15865,7 +15864,7 @@ static void __scst_update_latency_stats(struct scst_cmd *cmd, } do_div(delta, 100); #ifdef SCST_MEASURE_CLOCK_CYCLES - deltac = nowc - stat->last_update_tsc; + deltac = nowc - cmd->last_state_update_tsc; if (deltac < 0 || deltac > tsc_khz * 1000) { printk_once(KERN_INFO "%d: ignoring large cc delta %lld\n", cmd->state, deltac); @@ -15897,9 +15896,9 @@ static void __scst_update_latency_stats(struct scst_cmd *cmd, stat->sumsqc += deltac * deltac; #endif } - new_stat->last_update = now; + cmd->last_state_update = now; #ifdef SCST_MEASURE_CLOCK_CYCLES - new_stat->last_update_tsc = nowc; + cmd->last_state_update_tsc = nowc; #endif } @@ -15913,7 +15912,7 @@ void scst_update_latency_stats(struct scst_cmd *cmd, int new_state) ktime_t now; uint64_t nowc; int sz, dir; - struct scst_lat_stat_entry *prev_stat = NULL, *new_stat; + struct scst_lat_stat_entry *stat; unsigned long flags; sBUG_ON(new_state >= SCST_CMD_STATE_COUNT); @@ -15950,15 +15949,13 @@ void scst_update_latency_stats(struct scst_cmd *cmd, int new_state) else if (sz >= SCST_STATS_MAX_LOG2_SZ) sz = SCST_STATS_MAX_LOG2_SZ - 1; dir = cmd->expected_data_direction & 3; - if (new_state != SCST_CMD_STATE_INIT_WAIT) - prev_stat = &cmd->sess->lat_stats->ls[sz][dir][cmd->state]; - new_stat = &cmd->sess->lat_stats->ls[sz][dir][new_state]; + stat = &cmd->sess->lat_stats->ls[sz][dir][cmd->state]; spin_lock_irqsave(&cmd->sess->lat_stats_lock, flags); if (new_state == SCST_CMD_STATE_INIT) - __scst_update_latency_stats(cmd, NULL, prev_stat, + __scst_update_latency_stats(cmd, NULL, cmd->init_wait_time, cmd->init_wait_tsc); - __scst_update_latency_stats(cmd, prev_stat, new_stat, now, nowc); + __scst_update_latency_stats(cmd, stat, now, nowc); spin_unlock_irqrestore(&cmd->sess->lat_stats_lock, flags); }