From: "Satoshi Uchida" Subject: [PATCH 1/1] Output Virtual Block Device requests information ver. 2. Add information to sysfs. Date: Fri, 23 Jun 2006 20:37:03 +0900 Message-ID: <056301c696b9$58e49790$4c87380a@ad.spf.cl.nec.co.jp> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0564_01C69704.C8CC3F90" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: 'Keir Fraser' , xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. ------=_NextPart_000_0564_01C69704.C8CC3F90 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable This patch adds VBD statistic informations to sysfs. It creates 'statistics' directory under each VBD directory, and makes a sysfs file for each statistical information of VBD. Examples are as follows. By applying this patch, sysfs creates "statistics" directory under the = "vbd-*" directory. The "statistics" directory includes three statistical information files = of VBD; oo_req, rd_req, wr_req.=20 [root@Domain-0 ~]# ls /sys/devices/xen-backend/vbd-1-2049/ bus driver nodename power uevent devtype mode physical_device statistics [root@Domain-0 ~]# ls /sys/devices/xen-backend/vbd-1-2049/statistics/ oo_req rd_req wr_req [root@Domain-0 ~]# cat = /sys/devices/xen-backend/vbd-1-2049/statistics/oo_req 0 [root@Domain-0 ~]# cat = /sys/devices/xen-backend/vbd-1-2049/statistics/rd_req 1592 [root@Domain-0 ~]# cat = /sys/devices/xen-backend/vbd-1-2049/statistics/wr_req 565 [root@Domain-0 ~]# Thanks, Satoshi UCHIDA ------=_NextPart_000_0564_01C69704.C8CC3F90 Content-Type: application/octet-stream; name="Add_VBD_info_to_sysfs.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="Add_VBD_info_to_sysfs.patch" # HG changeset patch=0A= # User Satoshi UCHIDA =0A= # Node ID 7b69444493c10e0ee7fbdd787cb28517a75c77f8=0A= # Parent 161473836da3ccf922f44e910f8b5c01c709d1e6=0A= Output VBD request information into sysfs.=0A= =0A= Add group "statistics" and output each information into its group.=0A= Output information are oo_req, rd_req, and wr_req.=0A= =0A= Signed-off-by: Satoshi UCHIDA =0A= =0A= diff -r 161473836da3 -r 7b69444493c1 = linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c=0A= --- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c Wed Jun 14 = 22:15:13 2006 +0100=0A= +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c Fri Jun 23 = 20:18:11 2006 +0900=0A= @@ -40,6 +40,7 @@=0A= #include =0A= #include =0A= #include =0A= +#include =0A= #include "common.h"=0A= =0A= /*=0A= @@ -191,7 +192,7 @@ static void fast_flush_area(pending_req_=0A= =0A= static void print_stats(blkif_t *blkif)=0A= {=0A= - printk(KERN_DEBUG "%s: oo %3d | rd %4d | wr %4d\n",=0A= + printk(KERN_DEBUG "%s: oo %3lu | rd %4lu | wr %4lu\n",=0A= current->comm, blkif->st_oo_req,=0A= blkif->st_rd_req, blkif->st_wr_req);=0A= blkif->st_print =3D jiffies + msecs_to_jiffies(10 * 1000);=0A= @@ -463,6 +464,54 @@ static void dispatch_rw_block_io(blkif_t=0A= free_req(pending_req);=0A= } =0A= =0A= +=0A= +=0A= +/****************************************************************=0A= + * sysfs interface for VBD I/O requests=0A= + */=0A= +=0A= +#ifdef CONFIG_SYSFS=0A= +=0A= +VBD_SHOW(oo_req, fmt_ulong, be->blkif->st_oo_req);=0A= +VBD_SHOW(rd_req, fmt_ulong, be->blkif->st_rd_req);=0A= +VBD_SHOW(wr_req, fmt_ulong, be->blkif->st_wr_req);=0A= +=0A= +static struct attribute *vbdstat_attrs[] =3D {=0A= + &dev_attr_oo_req.attr,=0A= + &dev_attr_rd_req.attr,=0A= + &dev_attr_wr_req.attr,=0A= + NULL=0A= +};=0A= +=0A= +static struct attribute_group vbdstat_group =3D {=0A= + .name =3D "statistics",=0A= + .attrs =3D vbdstat_attrs,=0A= +};=0A= +=0A= +int xenvbd_sysfs_addif(struct xenbus_device *dev)=0A= +{=0A= + int error =3D 0;=0A= +=0A= + error =3D sysfs_create_group(&dev->dev.kobj,=0A= + &vbdstat_group);=0A= + if (error)=0A= + goto fail;=0A= +=0A= + return 0;=0A= +=0A= + fail:=0A= + sysfs_remove_group(&dev->dev.kobj,=0A= + &vbdstat_group);=0A= + return error;=0A= +}=0A= +=0A= +void xenvbd_sysfs_delif(struct xenbus_device *dev)=0A= +{=0A= + sysfs_remove_group(&dev->dev.kobj,=0A= + &vbdstat_group);=0A= +}=0A= +=0A= +#endif /* CONFIG_SYSFS */=0A= =0A= =0A= /******************************************************************=0A= diff -r 161473836da3 -r 7b69444493c1 = linux-2.6-xen-sparse/drivers/xen/blkback/common.h=0A= --- a/linux-2.6-xen-sparse/drivers/xen/blkback/common.h Wed Jun 14 = 22:15:13 2006 +0100=0A= +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/common.h Fri Jun 23 = 20:18:11 2006 +0900=0A= @@ -44,6 +44,7 @@=0A= #include =0A= #include =0A= #include =0A= +#include =0A= =0A= #define DPRINTK(_f, _a...) \=0A= pr_debug("(file=3D%s, line=3D%d) " _f, \=0A= @@ -84,15 +85,25 @@ typedef struct blkif_st {=0A= =0A= /* statistics */=0A= unsigned long st_print;=0A= - int st_rd_req;=0A= - int st_wr_req;=0A= - int st_oo_req;=0A= + unsigned long st_rd_req;=0A= + unsigned long st_wr_req;=0A= + unsigned long st_oo_req;=0A= =0A= wait_queue_head_t waiting_to_free;=0A= =0A= grant_handle_t shmem_handle;=0A= grant_ref_t shmem_ref;=0A= } blkif_t;=0A= +=0A= +struct backend_info=0A= +{=0A= + struct xenbus_device *dev;=0A= + blkif_t *blkif;=0A= + struct xenbus_watch backend_watch;=0A= + unsigned major;=0A= + unsigned minor;=0A= + char *mode;=0A= +};=0A= =0A= blkif_t *blkif_alloc(domid_t domid);=0A= void blkif_free(blkif_t *blkif);=0A= @@ -130,4 +141,31 @@ irqreturn_t blkif_be_int(int irq, void *=0A= irqreturn_t blkif_be_int(int irq, void *dev_id, struct pt_regs *regs);=0A= int blkif_schedule(void *arg);=0A= =0A= +=0A= +#ifdef CONFIG_SYSFS=0A= +=0A= +struct xenbus_device;=0A= +int xenvbd_sysfs_addif(struct xenbus_device *dev);=0A= +void xenvbd_sysfs_delif(struct xenbus_device *dev);=0A= +=0A= +static const char fmt_ulong[] =3D "%lu\n";=0A= +=0A= +#define VBD_SHOW(name, format, args...) \=0A= +static ssize_t show_##name(struct device *_dev, \=0A= + struct device_attribute *attr, char *buf) \=0A= +{ \=0A= + struct xenbus_device *dev =3D to_xenbus_device(_dev); \=0A= + struct backend_info *be =3D dev->dev.driver_data; \=0A= + \=0A= + return sprintf(buf, format, ##args); \=0A= +} \=0A= +DEVICE_ATTR(name, S_IRUGO, show_##name, NULL);=0A= +=0A= +#else=0A= +=0A= +#define xenvbd_sysfs_addif(dev) do { } while(0)=0A= +#define xenvbd_sysfs_delif(dev) do { } while(0)=0A= +=0A= +#endif=0A= +=0A= #endif /* __BLKIF__BACKEND__COMMON_H__ */=0A= diff -r 161473836da3 -r 7b69444493c1 = linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c=0A= --- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Wed Jun 14 = 22:15:13 2006 +0100=0A= +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Fri Jun 23 = 20:18:11 2006 +0900=0A= @@ -27,16 +27,6 @@=0A= #define DPRINTK(fmt, args...) \=0A= pr_debug("blkback/xenbus (%s:%d) " fmt ".\n", \=0A= __FUNCTION__, __LINE__, ##args)=0A= -=0A= -struct backend_info=0A= -{=0A= - struct xenbus_device *dev;=0A= - blkif_t *blkif;=0A= - struct xenbus_watch backend_watch;=0A= - unsigned major;=0A= - unsigned minor;=0A= - char *mode;=0A= -};=0A= =0A= static void connect(struct backend_info *);=0A= static int connect_ring(struct backend_info *);=0A= @@ -114,7 +104,8 @@ static int blkback_remove(struct xenbus_=0A= =0A= device_remove_file(&dev->dev, &dev_attr_physical_device);=0A= device_remove_file(&dev->dev, &dev_attr_mode);=0A= -=0A= + xenvbd_sysfs_delif(dev);=0A= + =0A= kfree(be);=0A= dev->dev.driver_data =3D NULL;=0A= return 0;=0A= @@ -236,6 +227,7 @@ static void backend_changed(struct xenbu=0A= =0A= device_create_file(&dev->dev, &dev_attr_physical_device);=0A= device_create_file(&dev->dev, &dev_attr_mode);=0A= + xenvbd_sysfs_addif(dev);=0A= =0A= /* We're potentially connected now */=0A= update_blkif_status(be->blkif); =0A= ------=_NextPart_000_0564_01C69704.C8CC3F90 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel ------=_NextPart_000_0564_01C69704.C8CC3F90--