ceph: add read/write latency metric support
Calculate the latency for OSD read requests. Add a new r_end_stamp field to struct ceph_osd_request that will hold the time of that the reply was received. Use that to calculate the RTT for each call, and divide the sum of those by number of calls to get averate RTT. Keep a tally of RTT for OSD writes and number of calls to track average latency of OSD writes. URL: https://tracker.ceph.com/issues/43215 Signed-off-by: Xiubo Li <xiubli@redhat.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
#include <linux/ctype.h>
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/seq_file.h>
|
||||
#include <linux/math64.h>
|
||||
#include <linux/ktime.h>
|
||||
|
||||
#include <linux/ceph/libceph.h>
|
||||
#include <linux/ceph/mon_client.h>
|
||||
@@ -18,6 +20,7 @@
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
|
||||
#include "mds_client.h"
|
||||
#include "metric.h"
|
||||
|
||||
static int mdsmap_show(struct seq_file *s, void *p)
|
||||
{
|
||||
@@ -124,13 +127,51 @@ static int mdsc_show(struct seq_file *s, void *p)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define CEPH_METRIC_SHOW(name, total, avg, min, max, sq) { \
|
||||
s64 _total, _avg, _min, _max, _sq, _st; \
|
||||
_avg = ktime_to_us(avg); \
|
||||
_min = ktime_to_us(min == KTIME_MAX ? 0 : min); \
|
||||
_max = ktime_to_us(max); \
|
||||
_total = total - 1; \
|
||||
_sq = _total > 0 ? DIV64_U64_ROUND_CLOSEST(sq, _total) : 0; \
|
||||
_st = int_sqrt64(_sq); \
|
||||
_st = ktime_to_us(_st); \
|
||||
seq_printf(s, "%-14s%-12lld%-16lld%-16lld%-16lld%lld\n", \
|
||||
name, total, _avg, _min, _max, _st); \
|
||||
}
|
||||
|
||||
static int metric_show(struct seq_file *s, void *p)
|
||||
{
|
||||
struct ceph_fs_client *fsc = s->private;
|
||||
struct ceph_mds_client *mdsc = fsc->mdsc;
|
||||
struct ceph_client_metric *m = &mdsc->metric;
|
||||
int i, nr_caps = 0;
|
||||
s64 total, sum, avg, min, max, sq;
|
||||
|
||||
seq_printf(s, "item total avg_lat(us) min_lat(us) max_lat(us) stdev(us)\n");
|
||||
seq_printf(s, "-----------------------------------------------------------------------------------\n");
|
||||
|
||||
spin_lock(&m->read_latency_lock);
|
||||
total = m->total_reads;
|
||||
sum = m->read_latency_sum;
|
||||
avg = total > 0 ? DIV64_U64_ROUND_CLOSEST(sum, total) : 0;
|
||||
min = m->read_latency_min;
|
||||
max = m->read_latency_max;
|
||||
sq = m->read_latency_sq_sum;
|
||||
spin_unlock(&m->read_latency_lock);
|
||||
CEPH_METRIC_SHOW("read", total, avg, min, max, sq);
|
||||
|
||||
spin_lock(&m->write_latency_lock);
|
||||
total = m->total_writes;
|
||||
sum = m->write_latency_sum;
|
||||
avg = total > 0 ? DIV64_U64_ROUND_CLOSEST(sum, total) : 0;
|
||||
min = m->write_latency_min;
|
||||
max = m->write_latency_max;
|
||||
sq = m->write_latency_sq_sum;
|
||||
spin_unlock(&m->write_latency_lock);
|
||||
CEPH_METRIC_SHOW("write", total, avg, min, max, sq);
|
||||
|
||||
seq_printf(s, "\n");
|
||||
seq_printf(s, "item total miss hit\n");
|
||||
seq_printf(s, "-------------------------------------------------\n");
|
||||
|
||||
|
Reference in New Issue
Block a user