WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] [BLKBACK/BLKTAP] add sysfs throughput pro

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [BLKBACK/BLKTAP] add sysfs throughput profiling to blk{back/tap}
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 21 Feb 2007 18:00:22 -0800
Delivery-date: Wed, 21 Feb 2007 18:00:05 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Jake Wires <jwires@xxxxxxxxxxxxx>
# Date 1172086924 28800
# Node ID ad3ee81cc8c4bf44edc01404782c7a197f8764fc
# Parent  87f31a0db841b3be5be938213adf2bd47acf3080
[BLKBACK/BLKTAP] add sysfs throughput profiling to blk{back/tap}
---
 linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c |    6 +
 linux-2.6-xen-sparse/drivers/xen/blkback/common.h  |    2 
 linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c  |   12 +-
 linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c   |   12 ++
 linux-2.6-xen-sparse/drivers/xen/blktap/common.h   |    2 
 linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c   |   96 ++++++++++++++++-----
 6 files changed, 104 insertions(+), 26 deletions(-)

diff -r 87f31a0db841 -r ad3ee81cc8c4 
linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c        Wed Feb 21 
19:12:16 2007 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c        Wed Feb 21 
11:42:04 2007 -0800
@@ -490,6 +490,12 @@ static void dispatch_rw_block_io(blkif_t
 
        for (i = 0; i < nbio; i++)
                submit_bio(operation, biolist[i]);
+
+        if (operation == READ) {
+                blkif->st_rd_sect += preq.nr_sects;
+        } else if (operation == WRITE) {
+                blkif->st_wr_sect += preq.nr_sects;
+        }
 
        return;
 
diff -r 87f31a0db841 -r ad3ee81cc8c4 
linux-2.6-xen-sparse/drivers/xen/blkback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/common.h Wed Feb 21 19:12:16 
2007 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/common.h Wed Feb 21 11:42:04 
2007 -0800
@@ -88,6 +88,8 @@ typedef struct blkif_st {
        int                 st_wr_req;
        int                 st_oo_req;
        int                 st_br_req;
+        int                 st_rd_sect;
+        int                 st_wr_sect;
 
        wait_queue_head_t waiting_to_free;
 
diff -r 87f31a0db841 -r ad3ee81cc8c4 
linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Wed Feb 21 19:12:16 
2007 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Wed Feb 21 11:42:04 
2007 -0800
@@ -111,16 +111,20 @@ static void update_blkif_status(blkif_t 
        }                                                               \
        DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
 
-VBD_SHOW(oo_req, "%d\n", be->blkif->st_oo_req);
-VBD_SHOW(rd_req, "%d\n", be->blkif->st_rd_req);
-VBD_SHOW(wr_req, "%d\n", be->blkif->st_wr_req);
-VBD_SHOW(br_req, "%d\n", be->blkif->st_br_req);
+VBD_SHOW(oo_req,  "%d\n", be->blkif->st_oo_req);
+VBD_SHOW(rd_req,  "%d\n", be->blkif->st_rd_req);
+VBD_SHOW(wr_req,  "%d\n", be->blkif->st_wr_req);
+VBD_SHOW(br_req,  "%d\n", be->blkif->st_br_req);
+VBD_SHOW(rd_sect, "%d\n", be->blkif->st_rd_sect);
+VBD_SHOW(wr_sect, "%d\n", be->blkif->st_wr_sect);
 
 static struct attribute *vbdstat_attrs[] = {
        &dev_attr_oo_req.attr,
        &dev_attr_rd_req.attr,
        &dev_attr_wr_req.attr,
        &dev_attr_br_req.attr,
+       &dev_attr_rd_sect.attr,
+       &dev_attr_wr_sect.attr,
        NULL
 };
 
diff -r 87f31a0db841 -r ad3ee81cc8c4 
linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c  Wed Feb 21 19:12:16 
2007 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c  Wed Feb 21 11:42:04 
2007 -0800
@@ -1195,7 +1195,7 @@ static void dispatch_rw_block_io(blkif_t
        int op, operation = (req->operation == BLKIF_OP_WRITE) ? WRITE : READ;
        struct gnttab_map_grant_ref map[BLKIF_MAX_SEGMENTS_PER_REQUEST*2];
        unsigned int nseg;
-       int ret, i;
+       int ret, i, nr_sects = 0;
        tap_blkif_t *info;
        uint64_t sector;
        blkif_request_t *target;
@@ -1291,6 +1291,9 @@ static void dispatch_rw_block_io(blkif_t
                                          req->seg[i].gref, blkif->domid);
                        op++;
                }
+
+               nr_sects += (req->seg[i].last_sect - 
+                            req->seg[i].first_sect + 1);
        }
 
        ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, map, op);
@@ -1403,6 +1406,13 @@ static void dispatch_rw_block_io(blkif_t
        target->id = usr_idx;
        wmb(); /* blktap_poll() reads req_prod_pvt asynchronously */
        info->ufe_ring.req_prod_pvt++;
+
+       if (operation == READ) {
+               blkif->st_rd_sect += nr_sects;
+       } else if (operation == WRITE) {
+               blkif->st_wr_sect += nr_sects;
+       }
+
        return;
 
  fail_flush:
diff -r 87f31a0db841 -r ad3ee81cc8c4 
linux-2.6-xen-sparse/drivers/xen/blktap/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/common.h  Wed Feb 21 19:12:16 
2007 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/common.h  Wed Feb 21 11:42:04 
2007 -0800
@@ -76,6 +76,8 @@ typedef struct blkif_st {
        int                 st_rd_req;
        int                 st_wr_req;
        int                 st_oo_req;
+       int                 st_rd_sect;
+       int                 st_wr_sect;
 
        wait_queue_head_t waiting_to_free;
 
diff -r 87f31a0db841 -r ad3ee81cc8c4 
linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c  Wed Feb 21 19:12:16 
2007 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c  Wed Feb 21 11:42:04 
2007 -0800
@@ -112,6 +112,74 @@ static int blktap_name(blkif_t *blkif, c
        return 0;
 }
 
+/****************************************************************
+ *  sysfs interface for VBD I/O requests
+ */
+
+#define VBD_SHOW(name, format, args...)                                        
\
+       static ssize_t show_##name(struct device *_dev,                 \
+                                  struct device_attribute *attr,       \
+                                  char *buf)                           \
+       {                                                               \
+               struct xenbus_device *dev = to_xenbus_device(_dev);     \
+               struct backend_info *be = dev->dev.driver_data;         \
+                                                                       \
+               return sprintf(buf, format, ##args);                    \
+       }                                                               \
+       DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
+
+VBD_SHOW(tap_oo_req,  "%d\n", be->blkif->st_oo_req);
+VBD_SHOW(tap_rd_req,  "%d\n", be->blkif->st_rd_req);
+VBD_SHOW(tap_wr_req,  "%d\n", be->blkif->st_wr_req);
+VBD_SHOW(tap_rd_sect, "%d\n", be->blkif->st_rd_sect);
+VBD_SHOW(tap_wr_sect, "%d\n", be->blkif->st_wr_sect);
+
+static struct attribute *tapstat_attrs[] = {
+       &dev_attr_tap_oo_req.attr,
+       &dev_attr_tap_rd_req.attr,
+       &dev_attr_tap_wr_req.attr,
+       &dev_attr_tap_rd_sect.attr,
+       &dev_attr_tap_wr_sect.attr,
+       NULL
+};
+
+static struct attribute_group tapstat_group = {
+       .name = "statistics",
+       .attrs = tapstat_attrs,
+};
+
+int xentap_sysfs_addif(struct xenbus_device *dev)
+{
+       return sysfs_create_group(&dev->dev.kobj, &tapstat_group);
+}
+
+void xentap_sysfs_delif(struct xenbus_device *dev)
+{
+       sysfs_remove_group(&dev->dev.kobj, &tapstat_group);
+}
+
+static int blktap_remove(struct xenbus_device *dev)
+{
+       struct backend_info *be = dev->dev.driver_data;
+
+       if (be->backend_watch.node) {
+               unregister_xenbus_watch(&be->backend_watch);
+               kfree(be->backend_watch.node);
+               be->backend_watch.node = NULL;
+       }
+       if (be->blkif) {
+               if (be->blkif->xenblkd)
+                       kthread_stop(be->blkif->xenblkd);
+               signal_tapdisk(be->blkif->dev_num);
+               tap_blkif_free(be->blkif);
+               be->blkif = NULL;
+       }
+       xentap_sysfs_delif(be->dev);
+       kfree(be);
+       dev->dev.driver_data = NULL;
+       return 0;
+}
+
 static void tap_update_blkif_status(blkif_t *blkif)
 { 
        int err;
@@ -134,6 +202,13 @@ static void tap_update_blkif_status(blki
        err = blktap_name(blkif, name);
        if (err) {
                xenbus_dev_error(blkif->be->dev, err, "get blktap dev name");
+               return;
+       }
+
+       err = xentap_sysfs_addif(blkif->be->dev);
+       if (err) {
+               xenbus_dev_fatal(blkif->be->dev, err, 
+                                "creating sysfs entries");
                return;
        }
 
@@ -144,27 +219,6 @@ static void tap_update_blkif_status(blki
                xenbus_dev_fatal(blkif->be->dev, err, "start xenblkd");
                WPRINTK("Error starting thread\n");
        }
-}
-
-static int blktap_remove(struct xenbus_device *dev)
-{
-       struct backend_info *be = dev->dev.driver_data;
-
-       if (be->backend_watch.node) {
-               unregister_xenbus_watch(&be->backend_watch);
-               kfree(be->backend_watch.node);
-               be->backend_watch.node = NULL;
-       }
-       if (be->blkif) {
-               if (be->blkif->xenblkd)
-                       kthread_stop(be->blkif->xenblkd);
-               signal_tapdisk(be->blkif->dev_num);
-               tap_blkif_free(be->blkif);
-               be->blkif = NULL;
-       }
-       kfree(be);
-       dev->dev.driver_data = NULL;
-       return 0;
 }
 
 /**

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [BLKBACK/BLKTAP] add sysfs throughput profiling to blk{back/tap}, Xen patchbot-unstable <=