ceph: include average/stdev r/w/m latency in mds metrics
authorVenky Shankar <vshankar@redhat.com>
Tue, 8 Mar 2022 12:42:18 +0000 (07:42 -0500)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 21 Mar 2022 12:35:16 +0000 (13:35 +0100)
stdev is computed in `cephfs-top` tool - clients forward
square of sums and IO count required to calculate stdev.

Signed-off-by: Venky Shankar <vshankar@redhat.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/ceph/metric.c
fs/ceph/metric.h

index 14b6af4..c47347d 100644 (file)
@@ -64,31 +64,40 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc,
        /* encode the read latency metric */
        read = (struct ceph_metric_read_latency *)(cap + 1);
        read->header.type = cpu_to_le32(CLIENT_METRIC_TYPE_READ_LATENCY);
-       read->header.ver = 1;
+       read->header.ver = 2;
        read->header.compat = 1;
        read->header.data_len = cpu_to_le32(sizeof(*read) - header_len);
        sum = m->metric[METRIC_READ].latency_sum;
        ktime_to_ceph_timespec(&read->lat, sum);
+       ktime_to_ceph_timespec(&read->avg, m->metric[METRIC_READ].latency_avg);
+       read->sq_sum = cpu_to_le64(m->metric[METRIC_READ].latency_sq_sum);
+       read->count = cpu_to_le64(m->metric[METRIC_READ].total);
        items++;
 
        /* encode the write latency metric */
        write = (struct ceph_metric_write_latency *)(read + 1);
        write->header.type = cpu_to_le32(CLIENT_METRIC_TYPE_WRITE_LATENCY);
-       write->header.ver = 1;
+       write->header.ver = 2;
        write->header.compat = 1;
        write->header.data_len = cpu_to_le32(sizeof(*write) - header_len);
        sum = m->metric[METRIC_WRITE].latency_sum;
        ktime_to_ceph_timespec(&write->lat, sum);
+       ktime_to_ceph_timespec(&write->avg, m->metric[METRIC_WRITE].latency_avg);
+       write->sq_sum = cpu_to_le64(m->metric[METRIC_WRITE].latency_sq_sum);
+       write->count = cpu_to_le64(m->metric[METRIC_WRITE].total);
        items++;
 
        /* encode the metadata latency metric */
        meta = (struct ceph_metric_metadata_latency *)(write + 1);
        meta->header.type = cpu_to_le32(CLIENT_METRIC_TYPE_METADATA_LATENCY);
-       meta->header.ver = 1;
+       meta->header.ver = 2;
        meta->header.compat = 1;
        meta->header.data_len = cpu_to_le32(sizeof(*meta) - header_len);
        sum = m->metric[METRIC_METADATA].latency_sum;
        ktime_to_ceph_timespec(&meta->lat, sum);
+       ktime_to_ceph_timespec(&meta->avg, m->metric[METRIC_METADATA].latency_avg);
+       meta->sq_sum = cpu_to_le64(m->metric[METRIC_METADATA].latency_sq_sum);
+       meta->count = cpu_to_le64(m->metric[METRIC_METADATA].total);
        items++;
 
        /* encode the dentry lease metric */
index c47ba00..0d0c44b 100644 (file)
@@ -19,27 +19,39 @@ enum ceph_metric_type {
        CLIENT_METRIC_TYPE_OPENED_INODES,
        CLIENT_METRIC_TYPE_READ_IO_SIZES,
        CLIENT_METRIC_TYPE_WRITE_IO_SIZES,
-
-       CLIENT_METRIC_TYPE_MAX = CLIENT_METRIC_TYPE_WRITE_IO_SIZES,
+       CLIENT_METRIC_TYPE_AVG_READ_LATENCY,
+       CLIENT_METRIC_TYPE_STDEV_READ_LATENCY,
+       CLIENT_METRIC_TYPE_AVG_WRITE_LATENCY,
+       CLIENT_METRIC_TYPE_STDEV_WRITE_LATENCY,
+       CLIENT_METRIC_TYPE_AVG_METADATA_LATENCY,
+       CLIENT_METRIC_TYPE_STDEV_METADATA_LATENCY,
+
+       CLIENT_METRIC_TYPE_MAX = CLIENT_METRIC_TYPE_STDEV_METADATA_LATENCY,
 };
 
 /*
  * This will always have the highest metric bit value
  * as the last element of the array.
  */
-#define CEPHFS_METRIC_SPEC_CLIENT_SUPPORTED {  \
-       CLIENT_METRIC_TYPE_CAP_INFO,            \
-       CLIENT_METRIC_TYPE_READ_LATENCY,        \
-       CLIENT_METRIC_TYPE_WRITE_LATENCY,       \
-       CLIENT_METRIC_TYPE_METADATA_LATENCY,    \
-       CLIENT_METRIC_TYPE_DENTRY_LEASE,        \
-       CLIENT_METRIC_TYPE_OPENED_FILES,        \
-       CLIENT_METRIC_TYPE_PINNED_ICAPS,        \
-       CLIENT_METRIC_TYPE_OPENED_INODES,       \
-       CLIENT_METRIC_TYPE_READ_IO_SIZES,       \
-       CLIENT_METRIC_TYPE_WRITE_IO_SIZES,      \
-                                               \
-       CLIENT_METRIC_TYPE_MAX,                 \
+#define CEPHFS_METRIC_SPEC_CLIENT_SUPPORTED {     \
+       CLIENT_METRIC_TYPE_CAP_INFO,               \
+       CLIENT_METRIC_TYPE_READ_LATENCY,           \
+       CLIENT_METRIC_TYPE_WRITE_LATENCY,          \
+       CLIENT_METRIC_TYPE_METADATA_LATENCY,       \
+       CLIENT_METRIC_TYPE_DENTRY_LEASE,           \
+       CLIENT_METRIC_TYPE_OPENED_FILES,           \
+       CLIENT_METRIC_TYPE_PINNED_ICAPS,           \
+       CLIENT_METRIC_TYPE_OPENED_INODES,          \
+       CLIENT_METRIC_TYPE_READ_IO_SIZES,          \
+       CLIENT_METRIC_TYPE_WRITE_IO_SIZES,         \
+       CLIENT_METRIC_TYPE_AVG_READ_LATENCY,       \
+       CLIENT_METRIC_TYPE_STDEV_READ_LATENCY,     \
+       CLIENT_METRIC_TYPE_AVG_WRITE_LATENCY,      \
+       CLIENT_METRIC_TYPE_STDEV_WRITE_LATENCY,    \
+       CLIENT_METRIC_TYPE_AVG_METADATA_LATENCY,   \
+       CLIENT_METRIC_TYPE_STDEV_METADATA_LATENCY, \
+                                                  \
+       CLIENT_METRIC_TYPE_MAX,                    \
 }
 
 struct ceph_metric_header {
@@ -61,18 +73,27 @@ struct ceph_metric_cap {
 struct ceph_metric_read_latency {
        struct ceph_metric_header header;
        struct ceph_timespec lat;
+       struct ceph_timespec avg;
+       __le64 sq_sum;
+       __le64 count;
 } __packed;
 
 /* metric write latency header */
 struct ceph_metric_write_latency {
        struct ceph_metric_header header;
        struct ceph_timespec lat;
+       struct ceph_timespec avg;
+       __le64 sq_sum;
+       __le64 count;
 } __packed;
 
 /* metric metadata latency header */
 struct ceph_metric_metadata_latency {
        struct ceph_metric_header header;
        struct ceph_timespec lat;
+       struct ceph_timespec avg;
+       __le64 sq_sum;
+       __le64 count;
 } __packed;
 
 /* metric dentry lease header */