Commit c873ccb
mm: fix possible deadlock in kmemleak
There are some AA deadlock issues in kmemleak, similar to the situation
reported by Breno [1]. The deadlock path is as follows:
mem_pool_alloc()
-> raw_spin_lock_irqsave(&kmemleak_lock, flags);
-> pr_warn()
-> netconsole subsystem
-> netpoll
-> __alloc_skb
-> __create_object
-> raw_spin_lock_irqsave(&kmemleak_lock, flags);
To solve this problem, switch to printk_safe mode before printing warning
message, this will redirect all printk()-s to a special per-CPU buffer,
which will be flushed later from a safe context (irq work), and this
deadlock problem can be avoided. The proper API to use should be
printk_deferred_enter()/printk_deferred_exit() [2]. Another way is to
place the warn print after kmemleak is released.
Link: https://lkml.kernel.org/r/[email protected]
Link: https://lore.kernel.org/all/[email protected]/#t [1]
Link: https://lore.kernel.org/all/[email protected]/ [2]
Signed-off-by: Gu Bowen <[email protected]>
Reviewed-by: Waiman Long <[email protected]>
Reviewed-by: Catalin Marinas <[email protected]>
Reviewed-by: Breno Leitao <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: John Ogness <[email protected]>
Cc: Lu Jialin <[email protected]>
Cc: Petr Mladek <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>1 parent 6659d02 commit c873ccb
1 file changed
+20
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
437 | 437 | | |
438 | 438 | | |
439 | 439 | | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
440 | 445 | | |
441 | 446 | | |
442 | 447 | | |
| 448 | + | |
443 | 449 | | |
444 | 450 | | |
445 | 451 | | |
| |||
736 | 742 | | |
737 | 743 | | |
738 | 744 | | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
739 | 750 | | |
740 | 751 | | |
741 | 752 | | |
742 | 753 | | |
743 | 754 | | |
744 | 755 | | |
745 | 756 | | |
| 757 | + | |
746 | 758 | | |
747 | 759 | | |
748 | 760 | | |
| |||
856 | 868 | | |
857 | 869 | | |
858 | 870 | | |
859 | | - | |
860 | | - | |
861 | | - | |
862 | | - | |
863 | | - | |
| 871 | + | |
864 | 872 | | |
865 | | - | |
866 | 873 | | |
867 | 874 | | |
868 | 875 | | |
| |||
882 | 889 | | |
883 | 890 | | |
884 | 891 | | |
885 | | - | |
| 892 | + | |
886 | 893 | | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
887 | 900 | | |
888 | 901 | | |
889 | 902 | | |
| |||
0 commit comments