[Devel] [PATCH RHEL7 COMMIT] target: add read/write/sync latency counter

Konstantin Khorenko khorenko at virtuozzo.com
Thu Jan 11 18:22:47 MSK 2018


The commit is pushed to "branch-rh7-3.10.0-693.11.1.vz7.39.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.11.1.vz7.39.10
------>
commit 0b0a62fe95e7c8ebf76d3b2ddeb47bfba199a302
Author: Andrey Grafin <Andrey.Grafin at acronis.com>
Date:   Thu Jan 11 18:22:47 2018 +0300

    target: add read/write/sync latency counter
    
    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 at acronis.com>
    Acked-by: Andrei Vagin <avagin at virtuozzo.com>
---
 drivers/target/target_core_stat.c | 4 ++++
 include/target/target_core_base.h | 1 +
 2 files changed, 5 insertions(+)

diff --git a/drivers/target/target_core_stat.c b/drivers/target/target_core_stat.c
index 8608b88e9996..b6b1b0a5c682 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 8cfc2c11287e..d3d5ae38c534 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;
 };
 


More information about the Devel mailing list