scsi: ufs: fix tag statistics for flush requests

rq_data_dir(rq) will always be either READ or WRITE so conditional
logic could never classify a request as a flush request causing
flush statistics to always be zero.
In addition it is neccesary to check the request type is FS in
order not to count other request type as read/write.

Change-Id: I678203ba47f8296caefa3f197566f2c65abdf059
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
This commit is contained in:
Gilad Broner 2015-02-08 14:40:10 +02:00 committed by David Keitel
parent 741bd793f5
commit 9eccb6a00d
3 changed files with 33 additions and 32 deletions

View file

@ -209,34 +209,39 @@ static int ufsdbg_tag_stats_show(struct seq_file *file, void *data)
spin_lock_irqsave(hba->host->host_lock, flags); spin_lock_irqsave(hba->host->host_lock, flags);
/* Header */ /* Header */
seq_printf(file, " Tag Stat\t\t%s Queue Fullness\n", sep); seq_printf(file, " Tag Stat\t\t%s Number of pending reqs upon issue (Q fullness)\n",
sep);
for (i = 0; i < TAB_CHARS * (TS_NUM_STATS + 4); i++) { for (i = 0; i < TAB_CHARS * (TS_NUM_STATS + 4); i++) {
seq_puts(file, "-"); seq_puts(file, "-");
if (i == (TAB_CHARS * 3 - 1)) if (i == (TAB_CHARS * 3 - 1))
seq_puts(file, sep); seq_puts(file, sep);
} }
seq_printf(file, seq_printf(file,
"\n #\tnum uses\t%s\t #\tAll\t Read\t Write\t Urgent\t Flush\n", "\n #\tnum uses\t%s\t #\tAll\tRead\tWrite\tUrg.R\tUrg.W\tFlush\n",
sep); sep);
/* values */ /* values */
for (i = 0; i < max_depth; i++) { for (i = 0; i < max_depth; i++) {
if (ufs_stats->tag_stats[i][0] <= 0 && if (ufs_stats->tag_stats[i][TS_TAG] <= 0 &&
ufs_stats->tag_stats[i][1] <= 0 && ufs_stats->tag_stats[i][TS_READ] <= 0 &&
ufs_stats->tag_stats[i][2] <= 0 && ufs_stats->tag_stats[i][TS_WRITE] <= 0 &&
ufs_stats->tag_stats[i][3] <= 0 && ufs_stats->tag_stats[i][TS_URGENT_READ] <= 0 &&
ufs_stats->tag_stats[i][4] <= 0) ufs_stats->tag_stats[i][TS_URGENT_WRITE] <= 0 &&
ufs_stats->tag_stats[i][TS_FLUSH] <= 0)
continue; continue;
is_tag_empty = false; is_tag_empty = false;
seq_printf(file, " %d\t ", i); seq_printf(file, " %d\t ", i);
for (j = 0; j < TS_NUM_STATS; j++) { for (j = 0; j < TS_NUM_STATS; j++) {
seq_printf(file, "%llu\t ", ufs_stats->tag_stats[i][j]); seq_printf(file, "%llu\t", ufs_stats->tag_stats[i][j]);
if (j == 0) if (j != 0)
seq_printf(file, "\t%s\t %d\t%llu\t ", sep, i, continue;
ufs_stats->tag_stats[i][j+1] + seq_printf(file, "\t%s\t %d\t%llu\t", sep, i,
ufs_stats->tag_stats[i][j+2] + ufs_stats->tag_stats[i][TS_READ] +
ufs_stats->tag_stats[i][j+3]); ufs_stats->tag_stats[i][TS_WRITE] +
ufs_stats->tag_stats[i][TS_URGENT_READ] +
ufs_stats->tag_stats[i][TS_URGENT_WRITE] +
ufs_stats->tag_stats[i][TS_FLUSH]);
} }
seq_puts(file, "\n"); seq_puts(file, "\n");
} }
@ -977,7 +982,7 @@ void ufsdbg_add_debugfs(struct ufs_hba *hba)
} }
hba->debugfs_files.tag_stats = hba->debugfs_files.tag_stats =
debugfs_create_file("tag_stats", S_IRUSR, debugfs_create_file("tag_stats", S_IRUSR | S_IWUSR,
hba->debugfs_files.debugfs_root, hba, hba->debugfs_files.debugfs_root, hba,
&ufsdbg_tag_stats_fops); &ufsdbg_tag_stats_fops);
if (!hba->debugfs_files.tag_stats) { if (!hba->debugfs_files.tag_stats) {
@ -987,7 +992,7 @@ void ufsdbg_add_debugfs(struct ufs_hba *hba)
} }
hba->debugfs_files.err_stats = hba->debugfs_files.err_stats =
debugfs_create_file("err_stats", S_IRUSR, debugfs_create_file("err_stats", S_IRUSR | S_IWUSR,
hba->debugfs_files.debugfs_root, hba, hba->debugfs_files.debugfs_root, hba,
&ufsdbg_err_stats_fops); &ufsdbg_err_stats_fops);
if (!hba->debugfs_files.err_stats) { if (!hba->debugfs_files.err_stats) {

View file

@ -63,32 +63,27 @@
struct request *rq = hba->lrb[task_tag].cmd ? \ struct request *rq = hba->lrb[task_tag].cmd ? \
hba->lrb[task_tag].cmd->request : NULL; \ hba->lrb[task_tag].cmd->request : NULL; \
u64 **tag_stats = hba->ufs_stats.tag_stats; \ u64 **tag_stats = hba->ufs_stats.tag_stats; \
int rq_type = -1; \ int rq_type = TS_WRITE; \
if (!hba->ufs_stats.enabled) \ if (!hba->ufs_stats.enabled) \
break; \ break; \
tag_stats[tag][TS_TAG]++; \ tag_stats[tag][TS_TAG]++; \
if (!rq) \ if (!rq || !(rq->cmd_type & REQ_TYPE_FS)) \
break; \ break; \
WARN_ON(hba->ufs_stats.q_depth > hba->nutrs); \ WARN_ON(hba->ufs_stats.q_depth > hba->nutrs); \
if (rq_data_dir(rq) == READ) \ if (rq->cmd_flags & REQ_FLUSH) \
rq_type = (rq->cmd_flags & REQ_URGENT) ?\
TS_URGENT : TS_READ; \
else if (rq_data_dir(rq) == WRITE) \
rq_type = TS_WRITE; \
else if (rq->cmd_flags & REQ_FLUSH) \
rq_type = TS_FLUSH; \ rq_type = TS_FLUSH; \
else \ else if (rq_data_dir(rq) == READ) \
break; \ rq_type = (rq->cmd_flags & REQ_URGENT) ?\
TS_URGENT_READ : TS_READ; \
else if (rq->cmd_flags & REQ_URGENT) \
rq_type = TS_URGENT_WRITE; \
tag_stats[hba->ufs_stats.q_depth++][rq_type]++; \ tag_stats[hba->ufs_stats.q_depth++][rq_type]++; \
} while (0) } while (0)
#define UFSHCD_UPDATE_TAG_STATS_COMPLETION(hba, cmd) \ #define UFSHCD_UPDATE_TAG_STATS_COMPLETION(hba, cmd) \
do { \ do { \
struct request *rq = cmd ? cmd->request : NULL; \ struct request *rq = cmd ? cmd->request : NULL; \
if (cmd->request && \ if (rq && rq->cmd_type & REQ_TYPE_FS) \
((rq_data_dir(rq) == READ) || \
(rq_data_dir(rq) == WRITE) || \
(rq->cmd_flags & REQ_FLUSH))) \
hba->ufs_stats.q_depth--; \ hba->ufs_stats.q_depth--; \
} while (0) } while (0)

View file

@ -514,9 +514,10 @@ enum ts_types {
TS_TAG = 0, TS_TAG = 0,
TS_READ = 1, TS_READ = 1,
TS_WRITE = 2, TS_WRITE = 2,
TS_URGENT = 3, TS_URGENT_READ = 3,
TS_FLUSH = 4, TS_URGENT_WRITE = 4,
TS_NUM_STATS = 5, TS_FLUSH = 5,
TS_NUM_STATS = 6,
}; };
#endif #endif