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

Konstantin Khorenko khorenko at virtuozzo.com
Fri Apr 30 14:33:45 MSK 2021


The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.24
------>
commit c06435eb5e1154345c78d3fd0f703bedd2c7bb40
Author: Andrey Grafin <Andrey.Grafin at acronis.com>
Date:   Fri Apr 30 14:33:45 2021 +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>
    
    (cherry picked from vz7 commit 0b0a62fe95e7 ("target: add read/write/sync
    latency counter"))
    Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko 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 07ce36e83f91..abe7f612b676 100644
--- a/drivers/target/target_core_stat.c
+++ b/drivers/target/target_core_stat.c
@@ -632,6 +632,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,
@@ -725,6 +726,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 82a87ce349ab..2622fd654bec 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -719,6 +719,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