watchdog: Fix lockdep warning
PATCH 1/1 watchdog: Fix lockdep warning
Fully initialize detector_work work struct to avoid this kernel warning when lockdep is enabled:
=====================================
WARNING: bad unlock balance detected!
6.5.0-rc5+ #687 Not tainted
-------------------------------------
swapper/0/1 is trying to release lock (detector_work) at:
[<000000004037e554>] __flush_work+0x60/0x658 but there are no more locks to release!
other info that might help us debug this:
no locks held by swapper/0/1.
stack backtrace: CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.5.0-rc5+ #687 Hardware name: 9000/785/C3700 Backtrace: [<0000000041455d5c>] print_unlock_imbalance_bug.part.0+0x20c/0x230 [<000000004040d5e8>] lock_release+0x2e8/0x3f8 [<000000004037e5cc>] __flush_work+0xd8/0x658 [<000000004037eb7c>] flush_work+0x30/0x60 [<000000004011f140>] lockup_detector_check+0x54/0x128 [<0000000040306430>] do_one_initcall+0x9c/0x408 [<0000000040102d44>] kernel_init_freeable+0x688/0x7f0 [<000000004146df68>] kernel_init+0x64/0x3a8 [<0000000040302020>] ret_from_kernel_thread+0x20/0x28
---
kernel/watchdog.c +1 -0
@@ -1022,5 +1022,6 @@ void __init lockup_detector_init(void)else allow_lockup_detector_init_retry = true; +INIT_WORK (&detector_work, lockup_detector_delay_init);lockup_detector_setup (); }
Adding workqueue and lockdep people into Cc.
Quoted 37 lines · Helge Deller
Fully initialize
detector_workwork struct to avoid this kernel warning when lockdep is enabled:=====================================
WARNING: bad unlock balance detected!
6.5.0-rc5+ #687 Not tainted
-------------------------------------
swapper/0/1 is trying to release lock (detector_work) at:[<000000004037e554>] __flush_work+0x60/0x658 but there are no more locks to release!other info that might help us debug this:
no locks held by swapper/0/1.stack backtrace: CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.5.0-rc5+ #687 Hardware name: 9000/785/C3700 Backtrace: [<0000000041455d5c>] print_unlock_imbalance_bug.part.0+0x20c/0x230 [<000000004040d5e8>] lock_release+0x2e8/0x3f8 [<000000004037e5cc>] __flush_work+0xd8/0x658 [<000000004037eb7c>] flush_work+0x30/0x60 [<000000004011f140>] lockup_detector_check+0x54/0x128 [<0000000040306430>] do_one_initcall+0x9c/0x408 [<0000000040102d44>] kernel_init_freeable+0x688/0x7f0 [<000000004146df68>] kernel_init+0x64/0x3a8 [<0000000040302020>] ret_from_kernel_thread+0x20/0x28Signed-off-by Helge Deller <[email protected]>---
kernel/watchdog.c +0
-0
kernel/watchdog.c void __init lockup_detector_init(void) · line 1027
Quoted 6 lines
kernel/watchdog.c +1
-0@@ -1022,5 +1022,6 @@ void __init lockup_detector_init(void)else allow_lockup_detector_init_retry = true; +INIT_WORK (&detector_work, lockup_detector_delay_init);lockup_detector_setup (); }
Strange. The work is initialized when declared:
static struct work_struct detector_work __initdata =
__WORK_INITIALIZER(detector_work, lockup_detector_delay_init);
, which should initialize the lockdep map as well. I would expect this is enough.
And I do not see this on x86_64 with CONFIG_PROVE_LOCKING=y on today's Linus' tree. And the flush_work() is always called from the lockup_detector_check() late init call.
IMHO, it must be a bug somewhere else. Otherwise, many other users of DECLARE_WORK() or __WORK_INITIALIZER() would have the same problem.
Or do I miss something?
Best Regards,
Petr
Quoted 49 lines · Petr Mladek
Adding workqueue and lockdep people into Cc.
Quoted 37 lines · Helge Deller
Fully initialize
detector_workwork struct to avoid this kernel warning when lockdep is enabled:=====================================
WARNING: bad unlock balance detected!
6.5.0-rc5+ #687 Not tainted
-------------------------------------
swapper/0/1 is trying to release lock (detector_work) at:[<000000004037e554>] __flush_work+0x60/0x658 but there are no more locks to release!other info that might help us debug this:
no locks held by swapper/0/1.stack backtrace: CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.5.0-rc5+ #687 Hardware name: 9000/785/C3700 Backtrace: [<0000000041455d5c>] print_unlock_imbalance_bug.part.0+0x20c/0x230 [<000000004040d5e8>] lock_release+0x2e8/0x3f8 [<000000004037e5cc>] __flush_work+0xd8/0x658 [<000000004037eb7c>] flush_work+0x30/0x60 [<000000004011f140>] lockup_detector_check+0x54/0x128 [<0000000040306430>] do_one_initcall+0x9c/0x408 [<0000000040102d44>] kernel_init_freeable+0x688/0x7f0 [<000000004146df68>] kernel_init+0x64/0x3a8 [<0000000040302020>] ret_from_kernel_thread+0x20/0x28Signed-off-by Helge Deller <[email protected]>---
kernel/watchdog.c +0
-0kernel/watchdog.c void __init lockup_detector_init(void) · line 1027
Quoted 6 lines
kernel/watchdog.c +1
-0@@ -1022,5 +1022,6 @@ void __init lockup_detector_init(void)else allow_lockup_detector_init_retry = true; +INIT_WORK (&detector_work, lockup_detector_delay_init);lockup_detector_setup (); }Strange. The work is initialized when declared:
Quoted 5 lines
static struct
work_structdetector_work__initdata=__WORK_INITIALIZER(detector_work, lockup_detector_delay_init);, which should initialize the lockdep map as well. I would expect this is enough.
Right. It's enough...
Quoted 7 lines
And I do not see this on
x86_64withCONFIG_PROVE_LOCKING=yon today's Linus' tree. And theflush_work()is always called from thelockup_detector_check()late init call.IMHO, it must be a bug somewhere else. Otherwise, many other users of
DECLARE_WORK()or__WORK_INITIALIZER()would have the same problem.
Right. I should have replied earlier to this patch. Andrew already dropped this patch here from his patch collection.
It turns out the problem is in function static_obj() from lockdep, which doesn't recognize the __initdata section for all platforms.
Please look at this patch on the LKML instead, which fixes the real problem:
[PATCH v2] lockdep: Fix static memory detection even more
Thanks!
Helge