From: Venky Shankar <vshankar@redhat.com>
To: jlayton@redhat.com, pdonnell@redhat.com, xiubli@redhat.com
Cc: ceph-devel@vger.kernel.org, Venky Shankar <vshankar@redhat.com>
Subject: [PATCH v1 3/4] ceph: include average/stddev r/w/m latency in mds metrics
Date: Mon, 13 Sep 2021 18:43:10 +0530 [thread overview]
Message-ID: <20210913131311.1347903-4-vshankar@redhat.com> (raw)
In-Reply-To: <20210913131311.1347903-1-vshankar@redhat.com>
The use of `jiffies_to_timespec64()` seems incorrect too, switch
that to `ktime_to_timespec64()`.
Signed-off-by: Venky Shankar <vshankar@redhat.com>
---
fs/ceph/metric.c | 36 +++++++++++++++++++-----------------
fs/ceph/metric.h | 44 +++++++++++++++++++++++++++++++-------------
2 files changed, 50 insertions(+), 30 deletions(-)
diff --git a/fs/ceph/metric.c b/fs/ceph/metric.c
index e00b1c2ce25b..cb332ae2411f 100644
--- a/fs/ceph/metric.c
+++ b/fs/ceph/metric.c
@@ -8,6 +8,13 @@
#include "metric.h"
#include "mds_client.h"
+static void to_ceph_timespec(struct ceph_timespec *ts, ktime_t val)
+{
+ struct timespec64 t = ktime_to_timespec64(val);
+ ts->tv_sec = cpu_to_le32(t.tv_sec);
+ ts->tv_nsec = cpu_to_le32(t.tv_nsec);
+}
+
static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc,
struct ceph_mds_session *s)
{
@@ -20,8 +27,6 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc,
struct ceph_client_metric *m = &mdsc->metric;
u64 nr_caps = atomic64_read(&m->total_caps);
struct ceph_msg *msg;
- struct timespec64 ts;
- s64 sum;
s32 items = 0;
s32 len;
@@ -51,37 +56,34 @@ 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->type = cpu_to_le32(CLIENT_METRIC_TYPE_READ_LATENCY);
- read->ver = 1;
+ read->ver = 2;
read->compat = 1;
read->data_len = cpu_to_le32(sizeof(*read) - 10);
- sum = m->read_latency_sum;
- jiffies_to_timespec64(sum, &ts);
- read->lat.tv_sec = cpu_to_le32(ts.tv_sec);
- read->lat.tv_nsec = cpu_to_le32(ts.tv_nsec);
+ to_ceph_timespec(&read->lat, m->read_latency_sum);
+ to_ceph_timespec(&read->avg, m->avg_read_latency);
+ to_ceph_timespec(&read->stdev, m->read_latency_stdev);
items++;
/* encode the write latency metric */
write = (struct ceph_metric_write_latency *)(read + 1);
write->type = cpu_to_le32(CLIENT_METRIC_TYPE_WRITE_LATENCY);
- write->ver = 1;
+ write->ver = 2;
write->compat = 1;
write->data_len = cpu_to_le32(sizeof(*write) - 10);
- sum = m->write_latency_sum;
- jiffies_to_timespec64(sum, &ts);
- write->lat.tv_sec = cpu_to_le32(ts.tv_sec);
- write->lat.tv_nsec = cpu_to_le32(ts.tv_nsec);
+ to_ceph_timespec(&write->lat, m->write_latency_sum);
+ to_ceph_timespec(&write->avg, m->avg_write_latency);
+ to_ceph_timespec(&write->stdev, m->write_latency_stdev);
items++;
/* encode the metadata latency metric */
meta = (struct ceph_metric_metadata_latency *)(write + 1);
meta->type = cpu_to_le32(CLIENT_METRIC_TYPE_METADATA_LATENCY);
- meta->ver = 1;
+ meta->ver = 2;
meta->compat = 1;
meta->data_len = cpu_to_le32(sizeof(*meta) - 10);
- sum = m->metadata_latency_sum;
- jiffies_to_timespec64(sum, &ts);
- meta->lat.tv_sec = cpu_to_le32(ts.tv_sec);
- meta->lat.tv_nsec = cpu_to_le32(ts.tv_nsec);
+ to_ceph_timespec(&meta->lat, m->metadata_latency_sum);
+ to_ceph_timespec(&meta->avg, m->avg_metadata_latency);
+ to_ceph_timespec(&meta->stdev, m->metadata_latency_stdev);
items++;
/* encode the dentry lease metric */
diff --git a/fs/ceph/metric.h b/fs/ceph/metric.h
index 136689fa0aec..b68927378e59 100644
--- a/fs/ceph/metric.h
+++ b/fs/ceph/metric.h
@@ -14,22 +14,34 @@ enum ceph_metric_type {
CLIENT_METRIC_TYPE_WRITE_LATENCY,
CLIENT_METRIC_TYPE_METADATA_LATENCY,
CLIENT_METRIC_TYPE_DENTRY_LEASE,
-
- CLIENT_METRIC_TYPE_MAX = CLIENT_METRIC_TYPE_DENTRY_LEASE,
+ 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_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_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, \
}
/* metric caps header */
@@ -52,8 +64,10 @@ struct ceph_metric_read_latency {
__u8 ver;
__u8 compat;
- __le32 data_len; /* length of sizeof(lat) */
+ __le32 data_len; /* length of sizeof(lat+avg+stdev) */
struct ceph_timespec lat;
+ struct ceph_timespec avg;
+ struct ceph_timespec stdev;
} __packed;
/* metric write latency header */
@@ -63,8 +77,10 @@ struct ceph_metric_write_latency {
__u8 ver;
__u8 compat;
- __le32 data_len; /* length of sizeof(lat) */
+ __le32 data_len; /* length of sizeof(lat_avg_stdev) */
struct ceph_timespec lat;
+ struct ceph_timespec avg;
+ struct ceph_timespec stdev;
} __packed;
/* metric metadata latency header */
@@ -74,8 +90,10 @@ struct ceph_metric_metadata_latency {
__u8 ver;
__u8 compat;
- __le32 data_len; /* length of sizeof(lat) */
+ __le32 data_len; /* length of sizeof(lat+avg+stdev) */
struct ceph_timespec lat;
+ struct ceph_timespec avg;
+ struct ceph_timespec stdev;
} __packed;
/* metric dentry lease header */
--
2.27.0
next prev parent reply other threads:[~2021-09-13 13:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-13 13:13 [PATCH v1 0/4] ceph: forward average read/write/metadata latency Venky Shankar
2021-09-13 13:13 ` [PATCH v1 1/4] ceph: use "struct ceph_timespec" for r/w/m latencies Venky Shankar
2021-09-13 13:13 ` [PATCH v1 2/4] ceph: track average/stdev r/w/m latency Venky Shankar
2021-09-13 13:13 ` Venky Shankar [this message]
2021-09-13 13:13 ` [PATCH v1 4/4] ceph: use tracked average r/w/m latencies to display metrics in debugfs Venky Shankar
2021-09-13 15:13 ` [PATCH v1 0/4] ceph: forward average read/write/metadata latency Jeff Layton
2021-09-13 15:21 ` Jeff Layton
2021-09-13 15:41 ` Venky Shankar
2021-09-14 12:53 ` Xiubo Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210913131311.1347903-4-vshankar@redhat.com \
--to=vshankar@redhat.com \
--cc=ceph-devel@vger.kernel.org \
--cc=jlayton@redhat.com \
--cc=pdonnell@redhat.com \
--cc=xiubli@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).