Skip to contentSkip to conversation

driver core: fix async device shutdown hang

PATCH In review Stuart Hayes 3 participants 5 messages Sep 17, 2024 – Sep 18, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 driver core: fix async device shutdown hang

Modify device_shutdown() so that supplier devices do not wait for consumer devices to be shut down first when the devlink is sync state only, since the consumer is not dependent on the supplier in this case.

Without this change, a circular dependency could hang the system.

---
 drivers/base/core.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/base/core.c +9 -1
index b69b82da8837..76513e360496 100644
@@ -4898,8 +4898,16 @@ void device_shutdown(void)
 
 		idx = device_links_read_lock();
 		list_for_each_entry_rcu(link, &dev->links.suppliers, c_node,
-				device_links_read_lock_held())
+				device_links_read_lock_held()) {
+			/*
+			 * sync_state_only suppliers don't need to wait,
+			 * aren't reordered on devices_kset, so making them
+			 * wait could result in a hang
+			 */
+			if (device_link_flag_is_sync_state_only(link->flags))
+				continue;
 			link->supplier->p->shutdown_after = cookie;
+		}
 		device_links_read_unlock(idx);
 		put_device(dev);
 
Signature · 1 line
2.39.3
#1 lore raw
Quoted 7 lines · Stuart Hayes

Modify device_shutdown() so that supplier devices do not wait for consumer devices to be shut down first when the devlink is sync state only, since the consumer is not dependent on the supplier in this case.

Without this change, a circular dependency could hang the system.

What commit id does this fix? Should it go to stable?

And what driver is causing this problem, is this a regression or for something new that just got added to the tree?

thanks,

greg k-h

#2 lore raw
Quoted 9 lines · Greg Kroah-Hartman
Quoted 7 lines · Stuart Hayes

Modify device_shutdown() so that supplier devices do not wait for consumer devices to be shut down first when the devlink is sync state only, since the consumer is not dependent on the supplier in this case.

Without this change, a circular dependency could hang the system.

Quoted 8 lines

What commit id does this fix? Should it go to stable?

And what driver is causing this problem, is this a regression or for something new that just got added to the tree?

thanks,

greg k-h

This fixes commit 8064952c65045f05ee2671fe437770e50c151776, in driver-core-next & linux-next... it's problem with code that was just added to the tree (in drivers/base/core.c). It is not in stable.

Apologies, I should have mentioned that from the start.

The issue was found using qemu... a pl061 device (supplier) and gpio-keys device (consumer), from a qemu-generated device tree with the aarch64 architecture. I don't know why the devlink is in the sync_state_only state in this case. I didn't dig into that, because I figured the shutdown code shouldn't hang regardless.

#3 lore raw
Quoted 17 lines · stuart hayes
Quoted 14 lines · Greg Kroah-Hartman
Quoted 7 lines · Stuart Hayes

Modify device_shutdown() so that supplier devices do not wait for consumer devices to be shut down first when the devlink is sync state only, since the consumer is not dependent on the supplier in this case.

Without this change, a circular dependency could hang the system.

What commit id does this fix? Should it go to stable?

And what driver is causing this problem, is this a regression or for something new that just got added to the tree?

Quoted 7 lines
Quoted 3 lines

thanks,

greg k-h

This fixes commit 8064952c65045f05ee2671fe437770e50c151776, in driver-core-next & linux-next... it's problem with code that was just added to the tree (in drivers/base/core.c). It is not in stable.

Ah, that wasn't obvious, sorry.

Quoted 1 line

Apologies, I should have mentioned that from the start.

Can you resend this with a "Fixes:" tag in it so I can just take it that way and not have to edit it by hand?

thanks,

greg k-h

#4 lore raw
Quoted 36 lines · Greg Kroah-Hartman
Quoted 22 lines · stuart hayes
Quoted 19 lines · Greg Kroah-Hartman
Quoted 11 lines · Stuart Hayes

Modify device_shutdown() so that supplier devices do not wait for
consumer devices to be shut down first when the devlink is sync state
only, since the consumer is not dependent on the supplier in this case.

Without this change, a circular dependency could hang the system.

What commit id does this fix?  Should it go to stable?

And what driver is causing this problem, is this a regression or for
something new that just got added to the tree?

Quoted 8 lines
Quoted 3 lines

thanks,

greg k-h

This fixes commit 8064952c65045f05ee2671fe437770e50c151776, in driver-core-next & linux-next... it's problem with code that was just
added to the tree (in drivers/base/core.c).  It is not in stable.

Ah, that wasn't obvious, sorry.

Quoted 1 line

Apologies, I should have mentioned that from the start.

Quoted 8 lines

Can you resend this with a "Fixes:" tag in it so I can just take it that
way and not have to edit it by hand?

thanks,

greg k-h

FYI
This patch plus the rest of the original Bundle has been tested at Red Hat on a system with 24 nvme devices. Improvement was almost 8 times faster to shutdown.