All of lore.kernel.org
 help / color / mirror / Atom feed
From: Coly Li <colyli@gmail.com>
To: dm-devel@redhat.com
Cc: Tao Ma <boyu.mt@taobao.com>, Robin Dong <sanbai@alibaba-inc.com>,
	Laurence Oberman <loberman@redhat.com>,
	Alasdair Kergon <agk@redhat.com>
Subject: [PATCH 3/4] dm-latency: add sysfs interface
Date: Thu, 26 Feb 2015 14:43:06 +0800	[thread overview]
Message-ID: <54EEC07A.5050800@gmail.com> (raw)

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,
  };

                 reply	other threads:[~2015-02-26  6:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=54EEC07A.5050800@gmail.com \
    --to=colyli@gmail.com \
    --cc=agk@redhat.com \
    --cc=boyu.mt@taobao.com \
    --cc=dm-devel@redhat.com \
    --cc=loberman@redhat.com \
    --cc=sanbai@alibaba-inc.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 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.