Skip to contentSkip to conversation

Improve xenbus timeout error message

PATCH In review Mark McLoughlin 3 participants 8 messages Jun 30, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Improve xenbus timeout error message

Hi,
With latest fedora, we're seeing:

XENBUS: Timeout connecting to devices!

Attached is a patch to make it a little bit more useful:

XENBUS: Timeout connecting to device: device/vif/0

The problem is that the timeout occurs before the xennet module can
ever be loaded, which is to be expected. Anything that can be done to avoid the timeout in this case?

Cheers,
Mark.

linux-2.6.16.x86_64/drivers/xen/xenbus/xenbus_probe.c renamed from linux-2.6.16.x86_64/drivers/xen/xenbus/xenbus_probe.c.timeout-message +18 -17
@@ -879,29 +879,19 @@
 EXPORT_SYMBOL_GPL(unregister_xenstore_notifier);
 
 
-static int all_devices_ready_(struct device *dev, void *data)
+static int find_disconnected_device_(struct device *dev, void *data)
 {
 	struct xenbus_device *xendev = to_xenbus_device(dev);
-	int *result = data;
 
-	if (xendev->state != XenbusStateConnected) {
-		*result = 0;
-		return 1;
-	}
-
-	return 0;
+	return (xendev->state == XenbusStateConnected) ? 0 : 1;
 }
 
-
-static int all_devices_ready(void)
+static struct device *find_disconnected_device(struct device *start)
 {
-	int ready = 1;
-	bus_for_each_dev(&xenbus_frontend.bus, NULL, &ready,
-			 all_devices_ready_);
-	return ready;
+	return bus_find_device(&xenbus_frontend.bus, start, NULL,
+			       find_disconnected_device_);
 }
 
-
 void xenbus_probe(void *unused)
 {
 	BUG_ON((xenstored_ready <= 0));
@@ -1066,17 +1056,28 @@
 static int __init wait_for_devices(void)
 {
 	unsigned long timeout = jiffies + 10*HZ;
+	struct device *dev = NULL;
+	struct xenbus_device *xendev;
 
 	if (!is_running_on_xen())
 		return -ENODEV;
 
 	while (time_before(jiffies, timeout)) {
-		if (all_devices_ready())
+		if ((dev = find_disconnected_device(NULL)) == NULL)
 			return 0;
+		put_device(dev);
 		schedule_timeout_interruptible(HZ/10);
 	}
 
-	printk(KERN_WARNING "XENBUS: Timeout connecting to devices!\n");
+	while (dev != NULL) {
+		xendev = to_xenbus_device(dev);
+
+		printk(KERN_WARNING "XENBUS: Timeout connecting to device: %s\n",
+		       xendev->nodename);
+
+		dev = find_disconnected_device(dev);
+	}
+
 	return 0;
 }
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 5 lines · Mark McLoughlin

Hi,
With latest fedora, we're seeing:

XENBUS: Timeout connecting to devices!

Quoted 7 lines

Attached is a patch to make it a little bit more useful:

XENBUS: Timeout connecting to device: device/vif/0

The problem is that the timeout occurs before the xennet module can
ever be loaded, which is to be expected. Anything that can be done to avoid the timeout in this case?

The timeout is there to ensure that the boot does not proceed until all the devices needed during boot are available. In this case, since it's a vif, if you were using an NFS root then your boot would presumably fail.

If you need to improve this, you will have to have some way to tell the tools "these devices I need for boot, these I don't", and then have the tools put a flag in the store so that Xenbus knows that it doesn't need to wait for them.

Cheers,

Ewan.

#2 lore raw
Quoted 11 lines · Ewan Mellor
Quoted 3 lines

The problem is that the timeout occurs before the xennet module can
ever be loaded, which is to be expected. Anything that can be done to avoid the timeout in this case?

The timeout is there to ensure that the boot does not proceed until all the devices needed during boot are available. In this case, since it's a vif, if you were using an NFS root then your boot would presumably fail.

If you need to improve this, you will have to have some way to tell the tools "these devices I need for boot, these I don't", and then have the tools put a flag in the store so that Xenbus knows that it doesn't need to wait for them.

The obvious thing to do here is work out which devices haven't been picked up by any driver, and not wait on those since they are obviously not going to connect! We should either silently ignore those, or maybe print a list of them for information.

-- Keir

#3 lore raw
Quoted 19 lines · Keir Fraser
Quoted 10 lines · Ewan Mellor
Quoted 3 lines

The problem is that the timeout occurs before the xennet module can
ever be loaded, which is to be expected. Anything that can be done to avoid the timeout in this case?

The timeout is there to ensure that the boot does not proceed until all the
devices needed during boot are available. In this case, since it's a vif, if
you were using an NFS root then your boot would presumably fail.

Quoted 6 lines

If you need to improve this, you will have to have some way to tell the tools
"these devices I need for boot, these I don't", and then have the tools put a
flag in the store so that Xenbus knows that it doesn't need to wait for them.

Quoted 4 lines

The obvious thing to do here is work out which devices haven't been picked up by any driver, and not wait on those since they are obviously not going to connect! We should either silently ignore those, or maybe print a list of them for information.

Good point, how about this patch then?

Cheers,
Mark.

linux-2.6.16.x86_64/drivers/xen/xenbus/xenbus_probe.c renamed from linux-2.6.16.x86_64/drivers/xen/xenbus/xenbus_probe.c.timeout-message +20 -17
@@ -879,29 +879,19 @@
 EXPORT_SYMBOL_GPL(unregister_xenstore_notifier);
 
 
-static int all_devices_ready_(struct device *dev, void *data)
+static int find_disconnected_device_(struct device *dev, void *data)
 {
 	struct xenbus_device *xendev = to_xenbus_device(dev);
-	int *result = data;
 
-	if (xendev->state != XenbusStateConnected) {
-		*result = 0;
-		return 1;
-	}
-
-	return 0;
+	return (dev->driver == NULL || xendev->state == XenbusStateConnected) ? 0 : 1;
 }
 
-
-static int all_devices_ready(void)
+static struct device *find_disconnected_device(struct device *start)
 {
-	int ready = 1;
-	bus_for_each_dev(&xenbus_frontend.bus, NULL, &ready,
-			 all_devices_ready_);
-	return ready;
+	return bus_find_device(&xenbus_frontend.bus, start, NULL,
+			       find_disconnected_device_);
 }
 
-
 void xenbus_probe(void *unused)
 {
 	BUG_ON((xenstored_ready <= 0));
@@ -1066,17 +1056,30 @@
 static int __init wait_for_devices(void)
 {
 	unsigned long timeout = jiffies + 10*HZ;
+	struct device *dev = NULL;
+	struct xenbus_device *xendev;
 
 	if (!is_running_on_xen())
 		return -ENODEV;
 
 	while (time_before(jiffies, timeout)) {
-		if (all_devices_ready())
+		if ((dev = find_disconnected_device(NULL)) == NULL)
 			return 0;
+		put_device(dev);
 		schedule_timeout_interruptible(HZ/10);
 	}
 
-	printk(KERN_WARNING "XENBUS: Timeout connecting to devices!\n");
+	dev = NULL;
+
+	while ((dev = find_disconnected_device(dev)) != NULL) {
+		xendev = to_xenbus_device(dev);
+
+		printk(KERN_WARNING "XENBUS: Timeout connecting to device: %s\n",
+		       xendev->nodename);
+
+		put_device(dev);
+	}
+
 	return 0;
 }
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#4 lore raw
Quoted 6 lines · Mark McLoughlin
Quoted 4 lines

The obvious thing to do here is work out which devices haven't been picked up by any driver, and not wait on those since they are obviously not going to connect! We should either silently ignore those, or maybe print a list of them for information.

Good point, how about this patch then?

Yes, I just checked in a patch rather similar, except I also print the driverless devices (could be handy for diagnostics, but I'm not sure if it might turn out to be too noisy in some situations) and move some functions closer to where they are used.

Your original path is changeset 10570 in xen-unstable; my modification is 10573. Should be in the public tree in a couple of hours.

-- Keir

#5 lore raw
Quoted 10 lines · Keir Fraser
Quoted 7 lines · Mark McLoughlin
Quoted 5 lines

The obvious thing to do here is work out which devices haven't been picked up by any driver, and not wait on those since they are obviously
not going to connect! We should either silently ignore those, or maybe print a list of them for information.

Good point, how about this patch then?

Quoted 7 lines

Yes, I just checked in a patch rather similar, except I also print the driverless devices (could be handy for diagnostics, but I'm not sure if it might turn out to be too noisy in some situations) and move some functions closer to where they are used.

Your original path is changeset 10570 in xen-unstable; my modification is 10573. Should be in the public tree in a couple of hours.

Note, the original patch leaked device references when printing out the
warning if there are multiple disconnected devices. Fixed in the second patch.

Cheers,
Mark.

#6 lore raw
Quoted 4 lines · Mark McLoughlin

Note, the original patch leaked device references when printing out
the
warning if there are multiple disconnected devices. Fixed in the second patch.

Ha. And I spotted that and already fixed in a third patch (10574): The very final. :-)

-- Keir

#7 lore raw
Quoted 6 lines · Keir Fraser
Quoted 4 lines

Note, the original patch leaked device references when printing out
the
warning if there are multiple disconnected devices. Fixed in the second patch.

Ha. And I spotted that and already fixed in a third patch (10574): The very final. :-)

Also your fix is racy, since it calls bus_find_device() on a dev that you have no reference to (since you already called put_device()). So there's a vanishingly small possibility that the dev could disappear in the meantime.

I replaced with a straightforward bus_for_each_device iterator with the printk inside the iterator callback.

-- Keir