Skip to contentSkip to conversation

xen/xenbus: log more information when device state got reset

PATCH In review Marek Marczykowski-Górecki 2 participants 4 messages Aug 3 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 xen/xenbus: log more information when device state got reset

Ease diagnosing what actually changed.

---
 drivers/xen/xenbus/xenbus_probe.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/xen/xenbus/xenbus_probe.c +2 -1
index eb260eceb4d2..a259c8f0fff4 100644
@@ -686,7 +686,8 @@ void xenbus_dev_changed(const char *node, struct xen_bus_type *bus)
 			 * and new one needs to be probed.
 			 */
 			dev_warn(&dev->dev,
-				 "state reset occurred, reconnecting\n");
+				 "state reset occurred (xenstore state %u, local state %u, xenstore backend %u, local backend %u), reconnecting\n",
+				 state, dev->state, backend, dev->otherend_id);
 			dev->vanished = true;
 		}
 		if (dev->vanished) {
Signature · 1 line
2.54.0
#1 lore raw

PATCH 2/2 xen/xenbus: check otherend_id only after it has been initialized

When device just got initialized (for example on module load), the otherend_id field is initialized only after xenbus_read_otherend_details() gets called. If xenstore watch triggers xenbus_dev_changed() before that, it might consider still zeroed otherend_id field (not matching actual xenstore content) as a sign of device state reset. It can happen because xenstore watch are handled in another thread (xenwatch), which can run in parallel to the initial device probe running at module load. In that case, it would call device_unregister(), which would deadlock against device probe from module init.

Fix this by considering dev->otherend_id change only after dev->otherend is set (which happen after otherend_id is initialized).

Fixes e2dcf9065536 "xen/xenbus: better handle backend crash"
---
 drivers/xen/xenbus/xenbus_probe.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/xen/xenbus/xenbus_probe.c +2 -1
index a259c8f0fff4..b42d8d2e5a33 100644
@@ -680,7 +680,8 @@ void xenbus_dev_changed(const char *node, struct xen_bus_type *bus)
 							    dev->otherend_id);
 
 		if (state == XenbusStateInitialising &&
-		    (state != dev->state || backend != dev->otherend_id)) {
+		    (state != dev->state ||
+		     (dev->otherend && backend != dev->otherend_id))) {
 			/*
 			 * State has been reset, assume the old one vanished
 			 * and new one needs to be probed.
Signature · 1 line
2.54.0
maintainer Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] xen/xenbus: check otherend_id only after it has been initialized

Quoted 11 lines · Marek Marczykowski-Górecki

When device just got initialized (for example on module load), the otherend_id field is initialized only after xenbus_read_otherend_details() gets called. If xenstore watch triggers xenbus_dev_changed() before that, it might consider still zeroed otherend_id field (not matching actual xenstore content) as a sign of device state reset. It can happen because xenstore watch are handled in another thread (xenwatch), which can run in parallel to the initial device probe running at module load. In that case, it would call device_unregister(), which would deadlock against device probe from module init.

Quoted 5 lines

Fix this by considering dev->otherend_id change only after dev->otherend is set (which happen after otherend_id is initialized).

Fixes e2dcf9065536 "xen/xenbus: better handle backend crash"

Juergen