From: "Satoshi Uchida" Subject: [PATCH 1/3] Output Virtual Block Device requests information to /proc/xen/vbd Date: Wed, 21 Jun 2006 18:51:22 +0900 Message-ID: <008201c69518$40ff8880$4c87380a@ad.spf.cl.nec.co.jp> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0083_01C69563.B0E73080" 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: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. ------=_NextPart_000_0083_01C69563.B0E73080 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable =20 This patch add /xen/proc/vbd. This proc file stores counts of I/O requests for VBD. I/O requests is counted for each Domains. For example, in case of four VMs, outputs of reading /xen/proc/vbd are = as follows. root@dom0 ~]# more /proc/xen/vbd Domain 4 - oo 0 rd 18699 wr 2 xvd 4 8:21 - oo 0 rd 18699 wr 2 Domain 7 - oo 0 rd 869 wr 376 xvd 7 8:22 - oo 0 rd 869 wr 376 Domain 8 - oo 0 rd 721 wr 197 xvd 8 8:23 - oo 0 rd 721 wr 197 Domain 9 - oo 0 rd 640 wr 77 xvd 9 8:24 - oo 0 rd 640 wr 77 The outputs show the following information. The first line shows domain information. Detail: Domain [Domain ID] - oo [oo-reqs] rd [rd-reqs] wr = [wr-reqs]. The second or less than third line shows each VBD information. xvd [Domain ID] [device majar]:[device minor] - oo [oo-reqs] rd = [rd-reqs] wr [wr-reqs]. VBD information handles "xvd [Domain ID] [device majar]:[device minor]" = for reason that the thread is running same name. Currently, Domain show domain ID. Someday, it want to correspond with domain name. Thanks, Satoshi UCHIDA ------=_NextPart_000_0083_01C69563.B0E73080 Content-Type: application/octet-stream; name="proc_xen_vbd.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="proc_xen_vbd.patch" # HG changeset patch=0A= # User s-uchida@ap.jp.nec.com=0A= # Node ID 55ab88937d77290a54d3315ea4cab6234efd4e78=0A= # Parent 360f9dc71f513c5e371c8c1b09cbb0f3c8e34d63=0A= Add /proc/xen/vbd. Output vbd request information.=0A= =0A= diff -r 360f9dc71f51 -r 55ab88937d77 = linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c=0A= --- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c Tue Jun 13 = 11:41:15 2006 +0100=0A= +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c Thu Jun 15 = 13:57:11 2006 +0900=0A= @@ -41,6 +41,10 @@=0A= #include =0A= #include =0A= #include "common.h"=0A= +=0A= +#include =0A= +#include =0A= +#include =0A= =0A= /*=0A= * These are rather arbitrary. They are fairly large because adjacent = requests=0A= @@ -85,6 +89,30 @@ static DEFINE_SPINLOCK(pending_free_lock=0A= static DEFINE_SPINLOCK(pending_free_lock);=0A= static DECLARE_WAIT_QUEUE_HEAD(pending_free_wq);=0A= =0A= +/*=0A= + * VBD(Virtual Block Device) information is allocated to 'dom_io_info'.=0A= + * by each domain.=0A= + */=0A= +=0A= +typedef struct {=0A= + domid_t dom;=0A= + unsigned long long rd_req;=0A= + unsigned long long wr_req;=0A= + unsigned long long oo_req;=0A= + struct list_head blkif_list;=0A= + struct list_head sibling_list;=0A= +} dom_io_info_t;=0A= +=0A= +static struct list_head dom_io_info;=0A= +static spinlock_t dom_io_info_lock =3D SPIN_LOCK_UNLOCKED;=0A= +static DECLARE_WAIT_QUEUE_HEAD(dom_io_info_wq);=0A= +=0A= +/*=0A= + * VBD information access proc file system which located /proc/xen/vbd.=0A= + */=0A= +static struct proc_dir_entry *blkback_pde;=0A= +=0A= +=0A= #define BLKBACK_INVALID_HANDLE (~0)=0A= =0A= static unsigned long mmap_vstart;=0A= @@ -185,6 +213,145 @@ static void fast_flush_area(pending_req_=0A= BUG_ON(ret);=0A= }=0A= =0A= +=0A= +/********************************************=0A= + * PROC OUTPUT FUNCTIONS=0A= + */=0A= +static int put_proc_domain(char *page, dom_io_info_t *info)=0A= +{=0A= + blkif_t *blkif;=0A= + int len;=0A= +=0A= +=0A= + info->oo_req =3D 0;=0A= + info->rd_req =3D 0;=0A= + info->wr_req =3D 0;=0A= +=0A= + list_for_each_entry(blkif, &info->blkif_list, sibling_list) {=0A= + info->oo_req +=3D blkif->st_oo_req;=0A= + info->rd_req +=3D blkif->st_rd_req;=0A= + info->wr_req +=3D blkif->st_wr_req;=0A= + }=0A= + =0A= + len =3D sprintf(=0A= + page,=0A= + "Domain %u - oo %8llu rd %8llu wr %8llu"=0A= + "\n",=0A= + info->dom, info->oo_req,=0A= + info->rd_req, info->wr_req=0A= + );=0A= +=0A= + list_for_each_entry(blkif, &info->blkif_list, sibling_list) {=0A= + len +=3D sprintf(=0A= + page + len, =0A= + " xvd %u %2u:%2u - oo %8d rd %8d wr %8d"=0A= + "\n",=0A= + blkif->domid,=0A= + blkif->be->major, blkif->be->minor,=0A= + blkif->st_oo_req, blkif->st_rd_req, blkif->st_wr_req,=0A= + );=0A= + }=0A= +=0A= + return len;=0A= +}=0A= +=0A= +static int put_proc_domains(char *page)=0A= +{=0A= + dom_io_info_t *info;=0A= + unsigned long flags;=0A= + int len;=0A= +=0A= + len =3D 0;=0A= + spin_lock_irqsave(&dom_io_info_lock, flags);=0A= + list_for_each_entry(info, &dom_io_info, sibling_list) {=0A= + len +=3D put_proc_domain(page+len, info);=0A= + }=0A= + spin_unlock_irqrestore(&dom_io_info_lock, flags);=0A= +=0A= + return len;=0A= +}=0A= +=0A= +=0A= +static int blkback_read(char *page, char **start, off_t off,=0A= + int count, int *eof, void *data)=0A= +{=0A= + int len;=0A= +=0A= + len =3D put_proc_domains(page);=0A= + =0A= + *eof =3D 1;=0A= + return len;=0A= +}=0A= +=0A= +=0A= +/*****************************************************************=0A= + * VBD information structure control=0A= + */=0A= +=0A= +dom_io_info_t *dominfo_get(domid_t dom)=0A= +{=0A= + dom_io_info_t *info;=0A= + unsigned long flags;=0A= +=0A= + spin_lock_irqsave(&dom_io_info_lock, flags);=0A= + list_for_each_entry(info, &dom_io_info, sibling_list) {=0A= + if (info->dom =3D=3D dom) {=0A= + spin_unlock_irqrestore(&dom_io_info_lock, flags);=0A= + return info;=0A= + }=0A= + }=0A= + spin_unlock_irqrestore(&dom_io_info_lock, flags);=0A= +=0A= + return NULL;=0A= +}=0A= +=0A= +=0A= +static int info_add(blkif_t *blkif)=0A= +{=0A= + dom_io_info_t *info;=0A= +=0A= + if (!(info =3D dominfo_get(blkif->domid))) {=0A= + info =3D kmalloc(sizeof(*info), GFP_KERNEL);=0A= + if (!info) {=0A= + printk("%s: out of memory\n", __FUNCTION__);=0A= + return -ENOMEM;=0A= + }=0A= + info->dom =3D blkif->domid ;=0A= + INIT_LIST_HEAD(&info->blkif_list);=0A= + info->rd_req =3D 0;=0A= + info->wr_req =3D 0;=0A= + info->oo_req =3D 0;=0A= + list_add_tail(&info->sibling_list, &dom_io_info);=0A= + }=0A= +=0A= + list_add_tail(&blkif->sibling_list, &info->blkif_list);=0A= +=0A= + return 0;=0A= +}=0A= +=0A= +=0A= +static int info_del(blkif_t *blkif)=0A= +{=0A= + dom_io_info_t *info;=0A= + unsigned long flags;=0A= +=0A= + if (!(info =3D dominfo_get(blkif->domid))) {=0A= + return -1;=0A= + }=0A= +=0A= + spin_lock_irqsave(&dom_io_info_lock, flags);=0A= + list_del(&blkif->sibling_list);=0A= + =0A= + if (list_empty(&info->blkif_list)) {=0A= + list_del(&info->sibling_list);=0A= + kfree(info);=0A= + }=0A= + spin_unlock_irqrestore(&dom_io_info_lock, flags);=0A= +=0A= + return 0;=0A= +}=0A= +=0A= +=0A= /******************************************************************=0A= * SCHEDULER FUNCTIONS=0A= */=0A= @@ -209,6 +376,8 @@ int blkif_schedule(void *arg)=0A= if (debug_lvl)=0A= printk(KERN_DEBUG "%s: started\n", current->comm);=0A= =0A= + info_add(blkif);=0A= +=0A= while (!kthread_should_stop()) {=0A= wait_event_interruptible(=0A= blkif->wq,=0A= @@ -232,6 +401,8 @@ int blkif_schedule(void *arg)=0A= print_stats(blkif);=0A= if (debug_lvl)=0A= printk(KERN_DEBUG "%s: exiting\n", current->comm);=0A= +=0A= + info_del(blkif);=0A= =0A= blkif->xenblkd =3D NULL;=0A= blkif_put(blkif);=0A= @@ -554,12 +725,22 @@ static int __init blkif_init(void)=0A= =0A= memset(pending_reqs, 0, sizeof(pending_reqs));=0A= INIT_LIST_HEAD(&pending_free);=0A= + INIT_LIST_HEAD(&dom_io_info);=0A= =0A= for (i =3D 0; i < blkif_reqs; i++)=0A= list_add_tail(&pending_reqs[i].free_list, &pending_free);=0A= =0A= blkif_xenbus_init();=0A= =0A= + /* set up /proc/xen/vbd */=0A= + if ((blkback_pde =3D create_xen_proc_entry("vbd", 0444)) =3D=3D NULL) {=0A= + DPRINTK("xen_vbd: Unable to create /proc/xen/vbd.\n");=0A= + return -1;=0A= + }=0A= +=0A= + blkback_pde->read_proc =3D blkback_read;=0A= +=0A= +=0A= return 0;=0A= }=0A= =0A= diff -r 360f9dc71f51 -r 55ab88937d77 = linux-2.6-xen-sparse/drivers/xen/blkback/common.h=0A= --- a/linux-2.6-xen-sparse/drivers/xen/blkback/common.h Tue Jun 13 = 11:41:15 2006 +0100=0A= +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/common.h Thu Jun 15 = 13:57: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= @@ -92,7 +93,19 @@ typedef struct blkif_st {=0A= =0A= grant_handle_t shmem_handle;=0A= grant_ref_t shmem_ref;=0A= +=0A= + struct list_head sibling_list;=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= diff -r 360f9dc71f51 -r 55ab88937d77 = linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c=0A= --- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Tue Jun 13 = 11:41:15 2006 +0100=0A= +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Thu Jun 15 = 13:57: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= ------=_NextPart_000_0083_01C69563.B0E73080 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_0083_01C69563.B0E73080--