Kuriakose Mathew
2009-Aug-17 06:40 UTC
[Xen-devel] how to read value from xenstore inside kernel
Can someone please point me to a code( or help me to find some code)where a value corresponding to a key is read from Xenstore inside the kernel . My requirement is to read a xenstore value from netback.c . Thanks Mathew _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Konrad Rzeszutek Wilk
2009-Aug-17 14:38 UTC
Re: [Xen-devel] how to read value from xenstore inside kernel
On Mon, Aug 17, 2009 at 12:10:21PM +0530, Kuriakose Mathew wrote:> Can someone please point me to a code( or help me to find some code)where a > value corresponding to a key is read from Xenstore inside the kernel . My > requirement is to read a xenstore value from netback.c .In drivers/xen/blkback/xenbus.c, the function backend_changed exclusivy job is to read those values. Here is an example: 278 err = xenbus_scanf(XBT_NIL, dev->nodename, "physical-device", "%x:%x", 279 &major, &minor); I would recommend you get a copy of "Understanding Xen" to understand how XenStore "transfers" the data from one domain to another.> > Thanks > Mathew> _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Kuriakose Mathew
2009-Aug-17 17:55 UTC
Re: [Xen-devel] how to read value from xenstore inside kernel
Thanks for the response. But I want the value to be read in netback.c . I checked the drivers/xen/netback/xenbus.c and found some functions using xenbus_scanf . But couldn''t find where these functions are getting called. Whether it will be possible to directly call xenbus_scanf directly in netback.c ? I want a value in xenstore to be read in some function in netback.c. Please help. -Mathew On Mon, Aug 17, 2009 at 8:08 PM, Konrad Rzeszutek Wilk < konrad.wilk@oracle.com> wrote:> On Mon, Aug 17, 2009 at 12:10:21PM +0530, Kuriakose Mathew wrote: > > Can someone please point me to a code( or help me to find some code)where > a > > value corresponding to a key is read from Xenstore inside the kernel . My > > requirement is to read a xenstore value from netback.c . > > In drivers/xen/blkback/xenbus.c, the function backend_changed exclusivy job > is > to read those values. Here is an example: > > 278 err = xenbus_scanf(XBT_NIL, dev->nodename, "physical-device", > "%x:%x", > 279 &major, &minor); > > I would recommend you get a copy of "Understanding Xen" to understand how > XenStore "transfers" the data from one domain to another. > > > > > Thanks > > Mathew > > > _______________________________________________ > > Xen-devel mailing list > > Xen-devel@lists.xensource.com > > http://lists.xensource.com/xen-devel > >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Konrad Rzeszutek Wilk
2009-Aug-17 18:20 UTC
Re: [Xen-devel] how to read value from xenstore inside kernel
On Mon, Aug 17, 2009 at 11:25:36PM +0530, Kuriakose Mathew wrote:> Thanks for the response. > But I want the value to be read in netback.c . I checked the > drivers/xen/netback/xenbus.c > and found some functions using xenbus_scanf . But couldn''t find where these > functions are getting called.I recommend you get acquinted with ''cscope'' and run under your linux directory this command: ''make cscope'' to create the cscope files. Then look for xenbus_scanf.> Whether it will be possible to directly call xenbus_scanf directly in > netback.c ? I want a value in xenstore to be read in some function inYes, if you have all of the #include files set right.> netback.c._______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Kuriakose Mathew
2009-Aug-25 10:57 UTC
Re: [Xen-devel] how to read value from xenstore inside kernel
Hi , I have been trying to use to xenbus_read. I added the below code in netback.c , static void net_tx_action(unsigned long unused) function. char * test; const char *nodename = "console"; test = xenbus_read(XBT_NIL, nodename, "limit", NULL); It is compiling fine. But when the kernel is crashing at this point during runtime. I expect to read the /local/domain/0/console/limit , which I am able to read from shell using xenstore-read . Am I missing something ? Thanks Mathew On Mon, Aug 17, 2009 at 11:50 PM, Konrad Rzeszutek Wilk < konrad.wilk@oracle.com> wrote:> On Mon, Aug 17, 2009 at 11:25:36PM +0530, Kuriakose Mathew wrote: > > Thanks for the response. > > But I want the value to be read in netback.c . I checked the > > drivers/xen/netback/xenbus.c > > and found some functions using xenbus_scanf . But couldn''t find where > these > > functions are getting called. > > I recommend you get acquinted with ''cscope'' and run under your linux > directory this > command: ''make cscope'' to create the cscope files. Then look for > xenbus_scanf. > > > Whether it will be possible to directly call xenbus_scanf directly in > > netback.c ? I want a value in xenstore to be read in some function in > > Yes, if you have all of the #include files set right. > > > netback.c. >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
James Harper
2009-Aug-25 11:07 UTC
RE: [Xen-devel] how to read value from xenstore inside kernel
> Hi , > > I have been trying to use to xenbus_read. > > I added the below code in netback.c , static voidnet_tx_action(unsigned long> unused) function. > > char * test; > const char *nodename = "console"; > test = xenbus_read(XBT_NIL, nodename, "limit", NULL); > > It is compiling fine. But when the kernel is crashing at this pointduring> runtime. > I expect to read the /local/domain/0/console/limit , which I am ableto read> from shell using > xenstore-read . Am I missing something ?Not sure how much this helps, but you should not be re-reading from xenbus every time a packet is sent. That would involve huge per-packet overheads. You can read it initially and then set a ''watch'' on the value to get notified every time it changes. Have you got a copy of the crash message? James _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Kuriakose Mathew
2009-Aug-25 12:44 UTC
Re: [Xen-devel] how to read value from xenstore inside kernel
Thanks James. I will try to get the crash message but not how to get it in a file. When I restart the system after making the change, it gets rebooted at this point. So I have to find a way to get those message displayed while a system is booting. I ll try to get it. Also regarding ''watch'' , it is called when the value of key changes but if I want to read some value which is static then will this help? Not sure if I am right. -Mathew On Tue, Aug 25, 2009 at 4:37 PM, James Harper <james.harper@bendigoit.com.au> wrote:> > Hi , > > > > I have been trying to use to xenbus_read. > > > > I added the below code in netback.c , static void > net_tx_action(unsigned long > > unused) function. > > > > char * test; > > const char *nodename = "console"; > > test = xenbus_read(XBT_NIL, nodename, "limit", NULL); > > > > It is compiling fine. But when the kernel is crashing at this point > during > > runtime. > > I expect to read the /local/domain/0/console/limit , which I am able > to read > > from shell using > > xenstore-read . Am I missing something ? > > Not sure how much this helps, but you should not be re-reading from > xenbus every time a packet is sent. That would involve huge per-packet > overheads. You can read it initially and then set a ''watch'' on the value > to get notified every time it changes. > > Have you got a copy of the crash message? > > James > >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
James Harper
2009-Aug-25 12:46 UTC
RE: [Xen-devel] how to read value from xenstore inside kernel
> > Thanks James. > I will try to get the crash message but not how to get it in a file.When I> restart the system after making the change, it gets rebooted at thispoint. So> I have to find a way to get those message displayed while a system isbooting.> I ll try to get it. > > Also regarding ''watch'' , it is called when the value of key changesbut if I> want to read some value which is static then will this help? > Not sure if I am right. >If it''s static then just read it when the other values are read. James _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Kuriakose Mathew
2009-Aug-28 08:52 UTC
Re: [Xen-devel] how to read value from xenstore inside kernel
When I am using char * test; const char *nodename = "vif/2/0"; test = xenbus_read(XBT_NIL, nodename, "mac", NULL); in netback .c ,I am getting this error when the kernel is rebooted. guest1 BUG: scheduling while atomic: xenwatch/0x00000100/13 and for a different nodename ( console , mac ) crash msg is as follows In netback.c::net_tx_action called BUG: scheduling while atomic: syslogd/0x00000100/4532 [<c02f73c6>] schedule+0x5c6/0x990 [<c0138654>] autoremove_wake_function+0x14/0x40 [<c011aeb9>] __wake_up_common+0x39/0x60 [<c011b468>] __wake_up+0x38/0x50 [<c02f84f3>] __mutex_lock_slowpath+0x53/0x8d [<c02f853c>] .text.lock.mutex+0xf/0x23 [<c0248c19>] xs_talkv+0x49/0x180 [<c0248e96>] xs_single+0x46/0x60 [<c024913a>] xenbus_read+0x3a/0x60 [<c025410e>] net_tx_action+0x2e/0xe90 [<c015470e>] __generic_file_aio_write_nolock+0x34e/0x510 [<c0154a3b>] __generic_file_write_nolock+0x8b/0xb0 [<c0138640>] autoremove_wake_function+0x0/0x40 [<c0188354>] do_path_lookup+0xc4/0x2e0 [<c0186e9a>] getname+0xaa/0xe0 [<c02f8398>] mutex_lock+0x8/0x20 [<c017746b>] do_readv_writev+0x1fb/0x300 [<c012905a>] tasklet_action+0x7a/0x130 [<c0128a24>] __do_softirq+0x94/0x130 [<c0128b4b>] do_softirq+0x8b/0xa0 [<c0107444>] do_IRQ+0x44/0xa0 [<c0243620>] evtchn_do_upcall+0xc0/0x190 [<c010591d>] hypervisor_callback+0x3d/0x45 .. .. BUG: scheduling while atomic: syslogd/0x00000100/4532 [<c02f73c6>] schedule+0x5c6/0x990 [<c024861a>] xb_write+0x14a/0x1e0 [<c0248ab5>] read_reply+0x75/0x100 [<c0138640>] autoremove_wake_function+0x0/0x40 [<c0248c71>] xs_talkv+0xa1/0x180 [<c0248e96>] xs_single+0x46/0x60 [<c024913a>] xenbus_read+0x3a/0x60 [<c025410e>] net_tx_action+0x2e/0xe90 [<c015470e>] __generic_file_aio_write_nolock+0x34e/0x510 [<c0154a3b>] __generic_file_write_nolock+0x8b/0xb0 [<c0138640>] autoremove_wake_function+0x0/0x40 [<c0188354>] do_path_lookup+0xc4/0x2e0 [<c0186e9a>] getname+0xaa/0xe0 [<c02f8398>] mutex_lock+0x8/0x20 [<c017746b>] do_readv_writev+0x1fb/0x300 [<c012905a>] tasklet_action+0x7a/0x130 [<c0128a24>] __do_softirq+0x94/0x130 [<c0128b4b>] do_softirq+0x8b/0xa0 [<c0107444>] do_IRQ+0x44/0xa0 [<c0243620>] evtchn_do_upcall+0xc0/0x190 [<c010591d>] hypervisor_callback+0x3d/0x45 -Mathew On Tue, Aug 25, 2009 at 4:37 PM, James Harper <james.harper@bendigoit.com.au> wrote:> > Hi , > > > > I have been trying to use to xenbus_read. > > > > I added the below code in netback.c , static void > net_tx_action(unsigned long > > unused) function. > > > > char * test; > > const char *nodename = "console"; > > test = xenbus_read(XBT_NIL, nodename, "limit", NULL); > > > > It is compiling fine. But when the kernel is crashing at this point > during > > runtime. > > I expect to read the /local/domain/0/console/limit , which I am able > to read > > from shell using > > xenstore-read . Am I missing something ? > > Not sure how much this helps, but you should not be re-reading from > xenbus every time a packet is sent. That would involve huge per-packet > overheads. You can read it initially and then set a ''watch'' on the value > to get notified every time it changes. > > Have you got a copy of the crash message? > > James > >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
James Harper
2009-Aug-28 09:07 UTC
RE: [Xen-devel] how to read value from xenstore inside kernel
> When I am using > char * test; > const char *nodename = "vif/2/0"; > test = xenbus_read(XBT_NIL, nodename, "mac", NULL); > > in netback .c ,I am getting this error when the kernel is rebooted. > > guest1 BUG: scheduling while atomic: xenwatch/0x00000100/13 >That will be because the xenbus_read involves a wait of some sort, and you can''t do that in that sort of function. Basically the rx and tx and other hardware event handlers need to execute as fast as possible, which precludes any waiting for xenbus responses to arrive. Read your value at startup, or put a watch in at startup and read it when it changes. James _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Kuriakose Mathew
2009-Aug-28 11:41 UTC
Re: [Xen-devel] how to read value from xenstore inside kernel
In netback.c , I intialized a target_watch struct and a callback function target_watch. Now for registering it , I used the below function in " static int __init netback_init(void) " spin_lock_init(&net_schedule_list_lock); INIT_LIST_HEAD(&net_schedule_list); netif_xenbus_init(); //ADDED CODE err = register_xenbus_watch(&target_watch); if(IS_ERR(err)) { printk(KERN_NOTICE "In netback.c::init Failed to initialize watcher\n"); } else { printk(KERN_NOTICE " In netback.c::init xenbus watcher initialized\n"); } ///END OF ADD When I reboot , it is hung at the point above the ''register_xenbus_watch(&target_watch)'' . Neither of the printk messages are dispayed. On Fri, Aug 28, 2009 at 2:37 PM, James Harper <james.harper@bendigoit.com.au> wrote:> > When I am using > > char * test; > > const char *nodename = "vif/2/0"; > > test = xenbus_read(XBT_NIL, nodename, "mac", NULL); > > > > in netback .c ,I am getting this error when the kernel is rebooted. > > > > guest1 BUG: scheduling while atomic: xenwatch/0x00000100/13 > > > > That will be because the xenbus_read involves a wait of some sort, and > you can''t do that in that sort of function. > > Basically the rx and tx and other hardware event handlers need to > execute as fast as possible, which precludes any waiting for xenbus > responses to arrive. > > Read your value at startup, or put a watch in at startup and read it > when it changes. > > James >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
James Harper
2009-Aug-28 11:44 UTC
RE: [Xen-devel] how to read value from xenstore inside kernel
> When I reboot , it is hung at the point above the > ''register_xenbus_watch(&target_watch)'' . > Neither of the printk messages are dispayed. >Please show the code where you initialize target_watch James _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Kuriakose Mathew
2009-Aug-28 11:51 UTC
Re: [Xen-devel] how to read value from xenstore inside kernel
The .node member I initialized while declaring and .callback I initialized in netbacl init function (just above where I use register_xenbus_watch )as shown below. (used balloon.c as guideline) static struct xenbus_watch target_watch { .node = "memory/target" }; static int __init netback_init(void) { ...... target_watch.callback = watch_target; ... register_xenbus_watch(&target_watch); ... } Thanks Mathew On Fri, Aug 28, 2009 at 5:14 PM, James Harper <james.harper@bendigoit.com.au> wrote:> > When I reboot , it is hung at the point above the > > ''register_xenbus_watch(&target_watch)'' . > > Neither of the printk messages are dispayed. > > > > Please show the code where you initialize target_watch > > James >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
James Harper
2009-Aug-28 11:57 UTC
RE: [Xen-devel] how to read value from xenstore inside kernel
> > The .node member I initialized while declaring and .callback Iinitialized> in netbacl init function (just above where I use register_xenbus_watch)as> shown below. (used balloon.c as guideline) >Try adding the watch (or just a read as a test) in netback/xenbus.c inside the connect() function where a lot of other xenbus activity is happening James _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Kuriakose Mathew
2009-Aug-28 14:39 UTC
Re: [Xen-devel] how to read value from xenstore inside kernel
I tried watch in xenbus.c ( connect function) code is as shown below. //////////ADDED CODE//////////////////// static struct xenbus_watch target_watch { .node = "memory/target" }; //////////////////////////////////////////////// /* React to a change in the target key */ static void mywatch_target(struct xenbus_watch *watch, const char **vec, unsigned int len) { unsigned long long new_target; int err; printk(KERN_NOTICE "In netback.c::watch_target called \n"); err = xenbus_scanf(XBT_NIL, "memory", "target", "%llu", &new_target); if (err != 1) { /* This is ok (for domain0 at least) - so just return */ return; } /* The given memory/target value is in KiB, so it needs converting to * pages. PAGE_SHIFT converts bytes to pages, hence PAGE_SHIFT - 10. */ //balloon_set_new_target(new_target >> (PAGE_SHIFT - 10)); } ////////////////////END OF ADD //////////////////////////// static void connect(struct backend_info *be) { int err; struct xenbus_device *dev = be->dev; err = connect_rings(be); if (err) return; err = xen_net_read_mac(dev, be->netif->fe_dev_addr); if (err) { xenbus_dev_fatal(dev, err, "parsing %s/mac", dev->nodename); return; } xen_net_read_rate(dev, &be->netif->credit_bytes, &be->netif->credit_usec); be->netif->remaining_credit = be->netif->credit_bytes; xenbus_switch_state(dev, XenbusStateConnected); netif_wake_queue(be->netif->dev); /////////////////ADDED CODE//////////// target_watch.callback = mywatch_target; printk(KERN_NOTICE "In xenbus.c::connect b4 register \n"); err = register_xenbus_watch(&target_watch); if(IS_ERR(err)) { printk(KERN_NOTICE "In xenbus.c::connect Failed to initialize watcher\n"); } else { printk(KERN_NOTICE " In xenbus.c::connect xenbus watcher initialized\n"); } //////////////END OF ADD////////////// } The crash message is In xenbus.c::connect b4 register ------------[ cut here ]------------ kernel BUG at /home/saransh/xen-3.1.3/linux-2.6.18.8-xen/drivers/xen/xenbus/xenbus_xs.c:607! invalid opcode: 0000 [#1] SMP Modules linked in: xt_tcpudp xt_physdev iptable_filter ip_tables x_tables ppdev ac video container button sbs i2c_ec i2c_core asus_acpi battery bridge lp serio_raw parport_pc parport serial_core rtc pcspkr shpchp pci_hotplug ipv6 tsdev evdev ext3 jbd sg sd_mod amd74xx usbhid ehci_hcd ohci_hcd usbcore sata_nv libata scsi_mod forcedeth thermal processor fan fuse CPU: 1 EIP: 0061:[<c0249306>] Not tainted VLI EFLAGS: 00010286 (2.6.18.8-xen #1) EIP is at register_xenbus_watch+0xc6/0xe0 eax: c0364bd4 ebx: c0364bd4 ecx: c0f2da10 edx: c0364bd4 esi: fffffffe edi: c1511f03 ebp: ed00cb40 esp: c1511ef4 ds: 007b es: 007b ss: 0069 Process xenwatch (pid: 13, ti=c1510000 task=c0446620 task.ti=c1510000) Stack: c1511f03 c032d562 c0364bd4 43fe0400 34363330 00344442 c0fe0000 fffffffe c0fe0400 c02564db c03218b0 ed00c540 c032db45 c030ec5b c1511f5c c032db12 c031610b c1511f68 c032dc1d c031ac96 c1511f64 00000000 c0fe0408 ed00c540 Call Trace: [<c02564db>] frontend_changed+0x4db/0x650 [<c024a8d8>] otherend_changed+0xa8/0xb0 [<c0249710>] xenwatch_thread+0x0/0x140 [<c0248b5a>] xenwatch_handle_callback+0x1a/0x60 [<c0249840>] xenwatch_thread+0x130/0x140 [<c0248b40>] xenwatch_handle_callback+0x0/0x60 [<c0138640>] autoremove_wake_function+0x0/0x40 [<c0138486>] kthread+0xf6/0x100 [<c0138390>] kthread+0x0/0x100 [<c0103005>] kernel_thread_helper+0x5/0x10 Code: 10 00 c7 43 04 00 02 20 00 86 05 e0 3d 36 c0 b8 a8 3e 41 c0 e8 0c 2a ef ff 89 f8 8b 5c 24 18 8b 74 24 1c 8b 7c 24 20 83 c4 24 c3 <0f> 0b 5f 02 6c 03 32 c0 e9 75 ff ff ff 8d b6 00 00 00 00 8d bc EIP: [<c0249306>] register_xenbus_watch+0xc6/0xe0 SS:ESP 0069:c1511ef4 <6>Bluetooth: Core ver 2.10 Thanks Mathew On Fri, Aug 28, 2009 at 5:27 PM, James Harper <james.harper@bendigoit.com.au> wrote:> > > > The .node member I initialized while declaring and .callback I > initialized > > in netbacl init function (just above where I use register_xenbus_watch > )as > > shown below. (used balloon.c as guideline) > > > > Try adding the watch (or just a read as a test) in netback/xenbus.c > inside the connect() function where a lot of other xenbus activity is > happening > > James >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Kuriakose Mathew
2009-Aug-29 15:01 UTC
Re: [Xen-devel] how to read value from xenstore inside kernel
Hi , Thanks. I think the registration is happening. I mistook the call trace to be a crash. But now when I write a new value to xenstore memory/target , it is showing some odd behavior like the shell is scrolling up . I think the callback function is getting called again and again as though some kind of infinite loop. -Mathew On Fri, Aug 28, 2009 at 8:09 PM, Kuriakose Mathew <kmathew123@gmail.com>wrote:> I tried watch in xenbus.c ( connect function) > > code is as shown below. > > //////////ADDED CODE//////////////////// > > > static struct xenbus_watch target_watch > { > .node = "memory/target" > > }; > > //////////////////////////////////////////////// > > /* React to a change in the target key */ > static void mywatch_target(struct xenbus_watch *watch, > const char **vec, unsigned int len) > { > unsigned long long new_target; > int err; > printk(KERN_NOTICE "In netback.c::watch_target called \n"); > err = xenbus_scanf(XBT_NIL, "memory", "target", "%llu", &new_target); > if (err != 1) { > /* This is ok (for domain0 at least) - so just return */ > return; > } > > /* The given memory/target value is in KiB, so it needs converting to > * pages. PAGE_SHIFT converts bytes to pages, hence PAGE_SHIFT - 10. > */ > //balloon_set_new_target(new_target >> (PAGE_SHIFT - 10)); > } > > > ////////////////////END OF ADD //////////////////////////// > > > static void connect(struct backend_info *be) > { > int err; > struct xenbus_device *dev = be->dev; > > err = connect_rings(be); > if (err) > return; > > err = xen_net_read_mac(dev, be->netif->fe_dev_addr); > if (err) { > xenbus_dev_fatal(dev, err, "parsing %s/mac", dev->nodename); > return; > } > > xen_net_read_rate(dev, &be->netif->credit_bytes, > &be->netif->credit_usec); > be->netif->remaining_credit = be->netif->credit_bytes; > > xenbus_switch_state(dev, XenbusStateConnected); > > netif_wake_queue(be->netif->dev); > > /////////////////ADDED CODE//////////// > target_watch.callback = mywatch_target; > > printk(KERN_NOTICE "In xenbus.c::connect b4 register \n"); > err = register_xenbus_watch(&target_watch); > if(IS_ERR(err)) { > printk(KERN_NOTICE "In xenbus.c::connect Failed to > initialize watcher\n"); > } else { > printk(KERN_NOTICE " In xenbus.c::connect xenbus watcher > initialized\n"); > } > //////////////END OF ADD////////////// > } > > The crash message is > > In xenbus.c::connect b4 register > ------------[ cut here ]------------ > kernel BUG at > /home/saransh/xen-3.1.3/linux-2.6.18.8-xen/drivers/xen/xenbus/xenbus_xs.c:607! > invalid opcode: 0000 [#1] > SMP > Modules linked in: xt_tcpudp xt_physdev iptable_filter ip_tables x_tables > ppdev ac video container button sbs i2c_ec i2c_core asus_acpi battery bridge > lp serio_raw parport_pc parport serial_core rtc pcspkr shpchp pci_hotplug > ipv6 tsdev evdev ext3 jbd sg sd_mod amd74xx usbhid ehci_hcd ohci_hcd usbcore > sata_nv libata scsi_mod forcedeth thermal processor fan fuse > CPU: 1 > EIP: 0061:[<c0249306>] Not tainted VLI > EFLAGS: 00010286 (2.6.18.8-xen #1) > EIP is at register_xenbus_watch+0xc6/0xe0 > eax: c0364bd4 ebx: c0364bd4 ecx: c0f2da10 edx: c0364bd4 > esi: fffffffe edi: c1511f03 ebp: ed00cb40 esp: c1511ef4 > ds: 007b es: 007b ss: 0069 > Process xenwatch (pid: 13, ti=c1510000 task=c0446620 task.ti=c1510000) > Stack: c1511f03 c032d562 c0364bd4 43fe0400 34363330 00344442 c0fe0000 > fffffffe > c0fe0400 c02564db c03218b0 ed00c540 c032db45 c030ec5b c1511f5c > c032db12 > c031610b c1511f68 c032dc1d c031ac96 c1511f64 00000000 c0fe0408 > ed00c540 > Call Trace: > [<c02564db>] frontend_changed+0x4db/0x650 > [<c024a8d8>] otherend_changed+0xa8/0xb0 > [<c0249710>] xenwatch_thread+0x0/0x140 > [<c0248b5a>] xenwatch_handle_callback+0x1a/0x60 > [<c0249840>] xenwatch_thread+0x130/0x140 > [<c0248b40>] xenwatch_handle_callback+0x0/0x60 > [<c0138640>] autoremove_wake_function+0x0/0x40 > [<c0138486>] kthread+0xf6/0x100 > [<c0138390>] kthread+0x0/0x100 > [<c0103005>] kernel_thread_helper+0x5/0x10 > Code: 10 00 c7 43 04 00 02 20 00 86 05 e0 3d 36 c0 b8 a8 3e 41 c0 e8 0c 2a > ef ff 89 f8 8b 5c 24 18 8b 74 24 1c 8b 7c 24 20 83 c4 24 c3 <0f> 0b 5f 02 6c > 03 32 c0 e9 75 ff ff ff 8d b6 00 00 00 00 8d bc > EIP: [<c0249306>] register_xenbus_watch+0xc6/0xe0 SS:ESP 0069:c1511ef4 > <6>Bluetooth: Core ver 2.10 > > > Thanks > Mathew > > > > On Fri, Aug 28, 2009 at 5:27 PM, James Harper < > james.harper@bendigoit.com.au> wrote: > >> > >> > The .node member I initialized while declaring and .callback I >> initialized >> > in netbacl init function (just above where I use register_xenbus_watch >> )as >> > shown below. (used balloon.c as guideline) >> > >> >> Try adding the watch (or just a read as a test) in netback/xenbus.c >> inside the connect() function where a lot of other xenbus activity is >> happening >> >> James >> > >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Kuriakose Mathew
2009-Aug-29 15:38 UTC
Re: [Xen-devel] how to read value from xenstore inside kernel
How to avoid the callback function getting called again and again after registration of xenbus_watch? -Mathew On Sat, Aug 29, 2009 at 8:31 PM, Kuriakose Mathew <kmathew123@gmail.com>wrote:> Hi , > > Thanks. I think the registration is happening. I mistook the call trace to > be a crash. But now when I write a new value to xenstore memory/target , it > is showing some odd behavior like the shell is scrolling up . > > I think the callback function is getting called again and again as though > some kind of infinite loop. > > -Mathew > > > On Fri, Aug 28, 2009 at 8:09 PM, Kuriakose Mathew <kmathew123@gmail.com>wrote: > >> I tried watch in xenbus.c ( connect function) >> >> code is as shown below. >> >> //////////ADDED CODE//////////////////// >> >> >> static struct xenbus_watch target_watch >> { >> .node = "memory/target" >> >> }; >> >> //////////////////////////////////////////////// >> >> /* React to a change in the target key */ >> static void mywatch_target(struct xenbus_watch *watch, >> const char **vec, unsigned int len) >> { >> unsigned long long new_target; >> int err; >> printk(KERN_NOTICE "In netback.c::watch_target called \n"); >> err = xenbus_scanf(XBT_NIL, "memory", "target", "%llu", &new_target); >> if (err != 1) { >> /* This is ok (for domain0 at least) - so just return */ >> return; >> } >> >> /* The given memory/target value is in KiB, so it needs converting to >> * pages. PAGE_SHIFT converts bytes to pages, hence PAGE_SHIFT - 10. >> */ >> //balloon_set_new_target(new_target >> (PAGE_SHIFT - 10)); >> } >> >> >> ////////////////////END OF ADD //////////////////////////// >> >> >> static void connect(struct backend_info *be) >> { >> int err; >> struct xenbus_device *dev = be->dev; >> >> err = connect_rings(be); >> if (err) >> return; >> >> err = xen_net_read_mac(dev, be->netif->fe_dev_addr); >> if (err) { >> xenbus_dev_fatal(dev, err, "parsing %s/mac", dev->nodename); >> return; >> } >> >> xen_net_read_rate(dev, &be->netif->credit_bytes, >> &be->netif->credit_usec); >> be->netif->remaining_credit = be->netif->credit_bytes; >> >> xenbus_switch_state(dev, XenbusStateConnected); >> >> netif_wake_queue(be->netif->dev); >> >> /////////////////ADDED CODE//////////// >> target_watch.callback = mywatch_target; >> >> printk(KERN_NOTICE "In xenbus.c::connect b4 register \n"); >> err = register_xenbus_watch(&target_watch); >> if(IS_ERR(err)) { >> printk(KERN_NOTICE "In xenbus.c::connect Failed to >> initialize watcher\n"); >> } else { >> printk(KERN_NOTICE " In xenbus.c::connect xenbus watcher >> initialized\n"); >> } >> //////////////END OF ADD////////////// >> } >> >> The crash message is >> >> In xenbus.c::connect b4 register >> ------------[ cut here ]------------ >> kernel BUG at >> /home/saransh/xen-3.1.3/linux-2.6.18.8-xen/drivers/xen/xenbus/xenbus_xs.c:607! >> invalid opcode: 0000 [#1] >> SMP >> Modules linked in: xt_tcpudp xt_physdev iptable_filter ip_tables x_tables >> ppdev ac video container button sbs i2c_ec i2c_core asus_acpi battery bridge >> lp serio_raw parport_pc parport serial_core rtc pcspkr shpchp pci_hotplug >> ipv6 tsdev evdev ext3 jbd sg sd_mod amd74xx usbhid ehci_hcd ohci_hcd usbcore >> sata_nv libata scsi_mod forcedeth thermal processor fan fuse >> CPU: 1 >> EIP: 0061:[<c0249306>] Not tainted VLI >> EFLAGS: 00010286 (2.6.18.8-xen #1) >> EIP is at register_xenbus_watch+0xc6/0xe0 >> eax: c0364bd4 ebx: c0364bd4 ecx: c0f2da10 edx: c0364bd4 >> esi: fffffffe edi: c1511f03 ebp: ed00cb40 esp: c1511ef4 >> ds: 007b es: 007b ss: 0069 >> Process xenwatch (pid: 13, ti=c1510000 task=c0446620 task.ti=c1510000) >> Stack: c1511f03 c032d562 c0364bd4 43fe0400 34363330 00344442 c0fe0000 >> fffffffe >> c0fe0400 c02564db c03218b0 ed00c540 c032db45 c030ec5b c1511f5c >> c032db12 >> c031610b c1511f68 c032dc1d c031ac96 c1511f64 00000000 c0fe0408 >> ed00c540 >> Call Trace: >> [<c02564db>] frontend_changed+0x4db/0x650 >> [<c024a8d8>] otherend_changed+0xa8/0xb0 >> [<c0249710>] xenwatch_thread+0x0/0x140 >> [<c0248b5a>] xenwatch_handle_callback+0x1a/0x60 >> [<c0249840>] xenwatch_thread+0x130/0x140 >> [<c0248b40>] xenwatch_handle_callback+0x0/0x60 >> [<c0138640>] autoremove_wake_function+0x0/0x40 >> [<c0138486>] kthread+0xf6/0x100 >> [<c0138390>] kthread+0x0/0x100 >> [<c0103005>] kernel_thread_helper+0x5/0x10 >> Code: 10 00 c7 43 04 00 02 20 00 86 05 e0 3d 36 c0 b8 a8 3e 41 c0 e8 0c 2a >> ef ff 89 f8 8b 5c 24 18 8b 74 24 1c 8b 7c 24 20 83 c4 24 c3 <0f> 0b 5f 02 6c >> 03 32 c0 e9 75 ff ff ff 8d b6 00 00 00 00 8d bc >> EIP: [<c0249306>] register_xenbus_watch+0xc6/0xe0 SS:ESP 0069:c1511ef4 >> <6>Bluetooth: Core ver 2.10 >> >> >> Thanks >> Mathew >> >> >> >> On Fri, Aug 28, 2009 at 5:27 PM, James Harper < >> james.harper@bendigoit.com.au> wrote: >> >>> > >>> > The .node member I initialized while declaring and .callback I >>> initialized >>> > in netbacl init function (just above where I use register_xenbus_watch >>> )as >>> > shown below. (used balloon.c as guideline) >>> > >>> >>> Try adding the watch (or just a read as a test) in netback/xenbus.c >>> inside the connect() function where a lot of other xenbus activity is >>> happening >>> >>> James >>> >> >> >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel