[4/4] target: add read/write/sync latency counter

Submitted by Andrey Grafin on Dec. 20, 2017, 10:10 a.m.

Details

Message ID 20171220101014.751-4-Andrey.Grafin@acronis.com
State New
Series "Series without cover letter"
Headers show

Commit Message

Andrey Grafin Dec. 20, 2017, 10:10 a.m.
This patch adds latency counter for write/read/sync operation for LUN.

This value can be obtain from histogram file (as the second line of output):
cat /sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.localhost.x8664\:sn.fdee138936b9/tpgt_1/lun/lun_3/statistics/scsi_tgt_port/read_hist
1 0 0 0 9 0 2 0 0 1 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
118807

Signed-off-by: Andrey Grafin <Andrey.Grafin@acronis.com>
---
 drivers/target/target_core_stat.c | 4 ++++
 include/target/target_core_base.h | 1 +
 2 files changed, 5 insertions(+)

Patch hide | download patch | download mbox

diff --git a/drivers/target/target_core_stat.c b/drivers/target/target_core_stat.c
index 6445869a22b..015e66d1d19 100644
--- a/drivers/target/target_core_stat.c
+++ b/drivers/target/target_core_stat.c
@@ -795,6 +795,7 @@  void scsi_port_stats_hist_observe(
 		return;
 
 	scsi_port_stats_hist_observe_bsearch(hist, val);
+	atomic64_add(val, &hist->latencies);
 }
 
 static ssize_t find_token(const char *page, size_t size,
@@ -888,6 +889,9 @@  static ssize_t snprintf_histogram(char *page, size_t size,
 	ret += snprintf(page + ret, PAGE_SIZE - ret,
 		"%llu\n", (u64)atomic64_read(&hist->counters[i]));
 
+	ret += snprintf(page + ret, PAGE_SIZE - ret,
+		"%llu\n", (u64)atomic64_read(&hist->latencies));
+
 	return ret;
 }
 
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 8cfc2c11287..d3d5ae38c53 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -718,6 +718,7 @@  struct scsi_port_stats_hist {
 	u64		items[TCM_SE_PORT_STATS_HIST_MAX];
 	atomic64_t	counters[TCM_SE_PORT_STATS_HIST_MAX];
 	u8		count;
+	atomic64_t	latencies;
 	struct rcu_head	rcu_head;
 };