* [PATCH 3/4] dm-latency: add sysfs interface
@ 2015-02-26 6:43 Coly Li
0 siblings, 0 replies; only message in thread
From: Coly Li @ 2015-02-26 6:43 UTC (permalink / raw)
To: dm-devel; +Cc: Tao Ma, Robin Dong, Laurence Oberman, Alasdair Kergon
From: Coly Li <bosong.ly@alibaba-inc.com>
This patch adds sysfs interface to display io latency statistic info.
3 files are used to export statistic info based on delay unit level,
- /sys/block/dm-X/dm/io_latency_us
- /sys/block/dm-X/dm/io_latency_ms
- /sys/block/dm-X/dm/io_latency_s
The statistic counter is increasing only, a user space application
should calculate "delta" value for a sampling interval.
Signed-off-by: Coly Li <bosong.ly@alibaba-inc.com>
Reviewed-by: Robin Dong <sanbai@alibaba-inc.com>
Reviewed-by: Tao Ma <boyu.mt@taobao.com>
---
drivers/md/dm-sysfs.c | 70
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 70 insertions(+)
diff --git a/drivers/md/dm-sysfs.c b/drivers/md/dm-sysfs.c
index c62c5ab..eab2dde 100644
--- a/drivers/md/dm-sysfs.c
+++ b/drivers/md/dm-sysfs.c
@@ -6,6 +6,7 @@
#include <linux/sysfs.h>
#include <linux/dm-ioctl.h>
+#include <asm/atomic.h>
#include "dm.h"
struct dm_sysfs_attr {
@@ -64,14 +65,83 @@ static ssize_t dm_attr_suspended_show(struct
mapped_device *md, char *buf)
return strlen(buf);
}
+static ssize_t dm_attr_io_latency_us_show(struct mapped_device *md,
char *buf)
+{
+ int slot_base = 0;
+ int i, nr, ptr;
+
+ for (ptr = 0, i = 0; i < DM_LATENCY_STATS_US_NR; i++) {
+ nr = sprintf(buf + ptr,
+ "%d-%d(us):%d\n",
+ slot_base,
+ slot_base + DM_LATENCY_STATS_US_GRAINSIZE - 1,
+ atomic_read(&md->latency_stats_us[i]));
+ if (nr < 0)
+ break;
+
+ slot_base += DM_LATENCY_STATS_US_GRAINSIZE;
+ ptr += nr;
+ }
+
+ return strlen(buf);
+}
+
+static ssize_t dm_attr_io_latency_ms_show(struct mapped_device *md,
char *buf)
+{
+ int slot_base = 0;
+ int i, nr, ptr;
+
+ for (ptr = 0, i = 0; i < DM_LATENCY_STATS_MS_NR; i++) {
+ nr = sprintf(buf + ptr,
+ "%d-%d(ms):%d\n",
+ slot_base,
+ slot_base + DM_LATENCY_STATS_MS_GRAINSIZE - 1,
+ atomic_read(&(md->latency_stats_ms[i])));
+ if (nr < 0)
+ break;
+
+ slot_base += DM_LATENCY_STATS_MS_GRAINSIZE;
+ ptr += nr;
+ }
+
+ return strlen(buf);
+}
+
+static ssize_t dm_attr_io_latency_s_show(struct mapped_device *md, char
*buf)
+{
+ int slot_base = 0;
+ int i, nr , ptr;
+
+ for(ptr = 0, i = 0; i < DM_LATENCY_STATS_S_NR; i++) {
+ nr = sprintf(buf + ptr,
+ "%d-%d(s):%d\n",
+ slot_base,
+ slot_base + DM_LATENCY_STATS_S_GRAINSIZE - 1,
+ atomic_read(&(md->latency_stats_s[i])));
+ if (nr < 0)
+ break;
+
+ slot_base += DM_LATENCY_STATS_S_GRAINSIZE;
+ ptr += nr;
+ }
+
+ return strlen(buf);
+}
+
static DM_ATTR_RO(name);
static DM_ATTR_RO(uuid);
static DM_ATTR_RO(suspended);
+static DM_ATTR_RO(io_latency_us);
+static DM_ATTR_RO(io_latency_ms);
+static DM_ATTR_RO(io_latency_s);
static struct attribute *dm_attrs[] = {
&dm_attr_name.attr,
&dm_attr_uuid.attr,
&dm_attr_suspended.attr,
+ &dm_attr_io_latency_us.attr,
+ &dm_attr_io_latency_ms.attr,
+ &dm_attr_io_latency_s.attr,
NULL,
};
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2015-02-26 6:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-26 6:43 [PATCH 3/4] dm-latency: add sysfs interface Coly Li
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.