acpi: Fix possible recursive locking in hwregs.c
Subsystems (2)
PATCH 1/1 acpi: Fix possible recursive locking in hwregs.c
Calling pm-suspend might trigger a recursive lock in it's code path. In function acpi_hw_clear_acpi_status, acpi_os_acquire_lock holds the lock acpi_gbl_hardware_lock before calling acpi_hw_register_write(), then without releasing acpi_gbl_hardware_lock, this function calls acpi_ev_walk_gpe_list, which tries to hold acpi_gbl_gpe_lock and thus might causes possible recursive lock.
Following patch fixes this scenario by just releasing acpi_gbl_hardware_lock before calling acpi_ev_walk_gpe_list.
Changes since v0(https://lkml.org/lkml/2011/9/21/355):
- Fix changelog, thanks to Lin Ming.
---
drivers/acpi/acpica/hwregs.c +3 -1
@@ -269,6 +269,9 @@ acpi_status acpi_hw_clear_acpi_status(void) status =acpi_hw_register_write (ACPI_REGISTER_PM1_STATUS ,ACPI_BITMASK_ALL_FIXED_STATUS ); + +acpi_os_release_lock (acpi_gbl_hardware_lock, lock_flags); +if (ACPI_FAILURE (status)) { goto unlock_and_exit; }
@@ -278,7 +281,6 @@ acpi_status acpi_hw_clear_acpi_status(void) status =acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block,NULL ); unlock_and_exit: -acpi_os_release_lock (acpi_gbl_hardware_lock, lock_flags);return_ACPI_STATUS (status); }
Quoted 1 line · Rakib Mullick
Calling pm-suspend might trigger a recursive lock in it's code path. In function
acpi_hw_clear_acpi_status,
As I replied at https://lkml.org/lkml/2011/9/22/6, I still don't think there is a recursive lock.
Or do you have a real test case to trigger the recursive lock you mentioned?
Lin Ming
Quoted 39 lines
acpi_os_acquire_lockholds the lockacpi_gbl_hardware_lockbefore callingacpi_hw_register_write(), then without releasingacpi_gbl_hardware_lock, this function callsacpi_ev_walk_gpe_list, which tries to holdacpi_gbl_gpe_lockand thus might causes possible recursive lock.Following patch fixes this scenario by just releasing
acpi_gbl_hardware_lockbefore callingacpi_ev_walk_gpe_list.Changes since v0(https://lkml.org/lkml/2011/9/21/355):
- Fix changelog, thanks to Lin Ming.Signed-off-by Rakib Mullick <[email protected]>Cc Lin Ming <[email protected]>Cc Andrew Morton <[email protected]>Cc Len Brown <[email protected]>---
drivers/acpi/acpica/hwregs.c +3
-1@@ -269,6 +269,9 @@ acpi_status acpi_hw_clear_acpi_status(void) status =acpi_hw_register_write (ACPI_REGISTER_PM1_STATUS ,ACPI_BITMASK_ALL_FIXED_STATUS ); + +acpi_os_release_lock (acpi_gbl_hardware_lock, lock_flags); +if (ACPI_FAILURE (status)) { goto unlock_and_exit; }@@ -278,7 +281,6 @@ acpi_status acpi_hw_clear_acpi_status(void) status =acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block,NULL ); unlock_and_exit: -acpi_os_release_lock (acpi_gbl_hardware_lock, lock_flags);return_ACPI_STATUS (status); }
Quoted 10 lines · Lin Ming
Quoted 2 lines · Rakib Mullick
Calling pm-suspend might trigger a recursive lock in it's code path. In function
acpi_hw_clear_acpi_status,As I replied at https://lkml.org/lkml/2011/9/22/6, I still don't think there is a recursive lock.
Or do you have a real test case to trigger the recursive lock you mentioned?
As I said before, recursive lock trigger's on a modified kernel (when calling pm-suspend), not with the mainline kernel. If you think that, since it's not happening with original kernel, so we shouldn't go for fix - that's a different thing, I don't have any argue. But, the issue is on.
Thanks,
Rakib
Hi,
Quoted 6 lines · Lin Ming
Quoted 1 line · Rakib Mullick
Calling pm-suspend might trigger a recursive lock in it's code path. In function
acpi_hw_clear_acpi_status,As I replied at https://lkml.org/lkml/2011/9/22/6, I still don't think there is a recursive lock.
At first look, it definitely doesn't look like a recursive lock, as Lin said. But, quoting Documentation/lockdep-design.txt:
"Multi-lock dependency rules:
----------------------------
The same lock-class must not be acquired twice, because this could lead to lock recursion deadlocks."
So, Rakib, do the 2 locks belong to the same lock-class? If yes, then I think that is the reason for the lockdep splat. Could you show the lockdep warning?
By the way, another way to look at this patch is as an optimization.. i.e., if acpi_gbl_hardware_lock doesn't need to be held to call acpi_ev_walk_gpe_list(), then we can move from the coarse-grained locking to finer-grained locking by releasing it earlier, as you did in your patch. [Note that you will have to update the goto label also, i.e., rename it as 'exit' or something like that]
Quoted 38 lines
Quoted 38 lines
acpi_os_acquire_lockholds the lockacpi_gbl_hardware_lockbefore callingacpi_hw_register_write(), then without releasingacpi_gbl_hardware_lock, this function callsacpi_ev_walk_gpe_list, which tries to holdacpi_gbl_gpe_lockand thus might causes possible recursive lock.Following patch fixes this scenario by just releasing
acpi_gbl_hardware_lockbefore callingacpi_ev_walk_gpe_list.Changes since v0(https://lkml.org/lkml/2011/9/21/355):
- Fix changelog, thanks to Lin Ming.Signed-off-by Rakib Mullick <[email protected]>Cc Lin Ming <[email protected]>Cc Andrew Morton <[email protected]>Cc Len Brown <[email protected]>---
drivers/acpi/acpica/hwregs.c +3
-1@@ -269,6 +269,9 @@ acpi_status acpi_hw_clear_acpi_status(void) status =acpi_hw_register_write (ACPI_REGISTER_PM1_STATUS ,ACPI_BITMASK_ALL_FIXED_STATUS ); + +acpi_os_release_lock (acpi_gbl_hardware_lock, lock_flags); +if (ACPI_FAILURE (status)) { goto unlock_and_exit; }@@ -278,7 +281,6 @@ acpi_status acpi_hw_clear_acpi_status(void) status =acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block,NULL ); unlock_and_exit: -acpi_os_release_lock (acpi_gbl_hardware_lock, lock_flags);return_ACPI_STATUS (status); }
Signature · 4 lines
Regards, Srivatsa S. Bhat <[email protected]> Linux Technology Center, IBM India Systems and Technology Lab
Quoted 13 lines · Srivatsa S. Bhat
Hi,
Quoted 6 lines · Lin Ming
Quoted 1 line · Rakib Mullick
Calling pm-suspend might trigger a recursive lock in it's code path. In function
acpi_hw_clear_acpi_status,As I replied at https://lkml.org/lkml/2011/9/22/6, I still don't think there is a recursive lock.
At first look, it definitely doesn't look like a recursive lock, as Lin said. But, quoting
Documentation/lockdep-design.txt:
Quoted 9 lines
"Multi-lock dependency rules:
----------------------------The same lock-class must not be acquired twice, because this could lead to lock recursion deadlocks."
So, Rakib, do the 2 locks belong to the same lock-class? If yes, then I think that is the reason for the lockdep splat. Could you show the lockdep warning?
Yes, same lock-class. And as per "Multi-lock dependency rules:", it leads to lock recursion deadlocks.
Lockdep warning attached.
Quoted 7 lines
By the way, another way to look at this patch is as an optimization.. i.e., if
acpi_gbl_hardware_lockdoesn't need to be held to callacpi_ev_walk_gpe_list(), then we can move from the coarse-grained locking to finer-grained locking by releasing it earlier, as you did in your patch. [Note that you will have to update the goto label also, i.e., rename it as 'exit' or something like that]
I can do it, thanks for suggestions. But, what does Lin thinks? Lin are you okay?
Thanks,
Rakib
Quoted 35 lines · Rakib Mullick
Quoted 13 lines · Srivatsa S. Bhat
Hi,
Quoted 6 lines · Lin Ming
Quoted 1 line · Rakib Mullick
Calling pm-suspend might trigger a recursive lock in it's code path. In function
acpi_hw_clear_acpi_status,As I replied at https://lkml.org/lkml/2011/9/22/6, I still don't think there is a recursive lock.
At first look, it definitely doesn't look like a recursive lock, as Lin said. But, quoting
Documentation/lockdep-design.txt:Quoted 9 lines
"Multi-lock dependency rules:
----------------------------The same lock-class must not be acquired twice, because this could lead to lock recursion deadlocks."
So, Rakib, do the 2 locks belong to the same lock-class? If yes, then I think that is the reason for the lockdep splat. Could you show the lockdep warning?
Yes, same lock-class. And as per "Multi-lock dependency rules:", it leads to lock recursion deadlocks.
Lockdep warning attached.Quoted 7 lines
By the way, another way to look at this patch is as an optimization.. i.e., if
acpi_gbl_hardware_lockdoesn't need to be held to callacpi_ev_walk_gpe_list(), then we can move from the coarse-grained locking to finer-grained locking by releasing it earlier, as you did in your patch. [Note that you will have to update the goto label also, i.e., rename it as 'exit' or something like that]
Quoted 2 lines
I can do it, thanks for suggestions. But, what does Lin thinks? Lin are you okay?
I'm OK.
We need to figure out why the dead lock happens. Could you also paste the patch which trigger this dead lock?
Thanks,
Lin Ming
Quoted 3 lines
Thanks,
Rakib
Quoted 36 lines · Lin Ming
Quoted 35 lines · Rakib Mullick
Quoted 13 lines · Srivatsa S. Bhat
Hi,
Quoted 6 lines · Lin Ming
Quoted 1 line · Rakib Mullick
Calling pm-suspend might trigger a recursive lock in it's code path. In function
acpi_hw_clear_acpi_status,As I replied at https://lkml.org/lkml/2011/9/22/6, I still don't think there is a recursive lock.
At first look, it definitely doesn't look like a recursive lock, as Lin said. But, quoting
Documentation/lockdep-design.txt:Quoted 9 lines
"Multi-lock dependency rules:
----------------------------The same lock-class must not be acquired twice, because this could lead to lock recursion deadlocks."
So, Rakib, do the 2 locks belong to the same lock-class? If yes, then I think that is the reason for the lockdep splat. Could you show the lockdep warning?
Yes, same lock-class. And as per "Multi-lock dependency rules:", it leads to lock recursion deadlocks.
Lockdep warning attached.Quoted 7 lines
By the way, another way to look at this patch is as an optimization.. i.e., if
acpi_gbl_hardware_lockdoesn't need to be held to callacpi_ev_walk_gpe_list(), then we can move from the coarse-grained locking to finer-grained locking by releasing it earlier, as you did in your patch. [Note that you will have to update the goto label also, i.e., rename it as 'exit' or something like that]
Quoted 5 lines
Quoted 2 lines
I can do it, thanks for suggestions. But, what does Lin thinks? Lin are you okay?
I'm OK.
Thanks. Then, I'll come up with a follow up patch includes the suggestion from Srivatsa.
Quoted 1 line
We need to figure out why the dead lock happens.
I think its pretty clear from the lockdep warning, the reason of the possible (since not happened with mainline kernel) dead lock.
Quoted 2 lines
Could you also paste the patch which trigger this dead lock?
It's basically a modification of kernel scheduler, it does load distribution differently. Since it's different approach and needs to introduce properly. I wish I'll show it some day, if I can make some fair improvement. Hope you understand.
Thanks,
Rakib