"suspicious RCU usage" in heapcheck driver
Hi Philippe,
while preparing Xenomai for recent kernels, switching prandom_u32 to get_random_u32 [1], I triggered some RCU warning:
[ 515.060011] =============================
[ 515.060011] WARNING: suspicious RCU usage
[ 515.060012] 6.1.0-rc5+ #10 Not tainted
[ 515.060014] -----------------------------
[ 515.060014] ../include/linux/rcupdate.h:740 rcu_read_lock() used
illegally while idle!
[ 515.060017]
[ 515.060017] other info that might help us debug this:
[ 515.060017]
[ 515.060017]
[ 515.060017] rcu_scheduler_active = 2, debug_locks = 1
[ 515.060019] RCU used illegally from extended quiescent state!
[ 515.060019] 1 lock held by smokey/1435:
[ 515.060021] #0: ffffffff82d63c60 (rcu_read_lock){....}-{1:2}, at:
__is_insn_slot_addr+0x5/0x120
[ 515.060049]
[ 515.060049] stack backtrace:
[ 515.060050] CPU: 0 PID: 1435 Comm: smokey Not tainted 6.1.0-rc5+ #10
[ 515.060053] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS
rel-1.15.0-0-g2dd4b9b-rebuilt.opensuse.org 04/01/2014
[ 515.060054] IRQ stage: Xenomai
[ 515.060055] Call Trace:
[ 515.060056] <TASK>
[ 515.060058]
[ 515.060058] =============================
[ 515.060059] WARNING: suspicious RCU usage
[ 515.060060] 6.1.0-rc5+ #10 Not tainted
[ 515.060061] -----------------------------
[ 515.060061] ../include/linux/rcupdate.h:768 rcu_read_unlock() used
illegally while idle!
[ 515.060063]
[ 515.060063] other info that might help us debug this:
[ 515.060063]
[ 515.060063]
[ 515.060063] rcu_scheduler_active = 2, debug_locks = 1
[ 515.060065] RCU used illegally from extended quiescent state!
[ 515.060065] 2 locks held by smokey/1435:
[ 515.060067] #0: ffffffff82d63c60 (rcu_read_lock){....}-{1:2}, at:
__is_insn_slot_addr+0x5/0x120
[ 515.060073] #1: ffffffff82d63c60 (rcu_read_lock){....}-{1:2}, at:
__is_insn_slot_addr+0x5/0x120
[ 515.060078]
[ 515.060078] stack backtrace:
[ 515.060078] CPU: 0 PID: 1435 Comm: smokey Not tainted 6.1.0-rc5+ #10
[ 515.060081] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS
rel-1.15.0-0-g2dd4b9b-rebuilt.opensuse.org 04/01/2014
[ 515.060082] IRQ stage: Xenomai
[ 515.060083] Call Trace:
[ 515.060084] <TASK>
[ 515.060086] dump_stack_lvl+0x7d/0xb5
[ 515.060106] __is_insn_slot_addr+0x10e/0x120
[ 515.060112] kernel_text_address+0xbf/0xd0
[ 515.060126] __kernel_text_address+0xe/0x40
[ 515.060129] show_trace_log_lvl+0x18c/0x3f0
[ 515.060152] ? dump_stack_lvl+0x7d/0xb5
[ 515.060162] dump_stack_lvl+0x7d/0xb5
[ 515.060168] __is_insn_slot_addr+0xd8/0x120
[ 515.060171] kernel_text_address+0xbf/0xd0
[ 515.060176] __kernel_text_address+0xe/0x40
[ 515.060179] show_trace_log_lvl+0x18c/0x3f0
[ 515.060196] ? dump_stack_lvl+0x7d/0xb5
[ 515.060206] dump_stack_lvl+0x7d/0xb5
[ 515.060212] inband_irq_save+0xa/0x30
[ 515.060215] get_random_u32+0x2f/0x230
[ 515.060228] heapcheck_ioctl+0xa42/0xbb0
[ 515.060244] ? ktime_get_mono_fast_ns+0x3b/0xa0
[ 515.060260] ? rtdm_fd_ioctl+0xec/0x340
[ 515.060270] rtdm_fd_ioctl+0xec/0x340
[ 515.060284] ? CoBaLt_fcntl+0x20/0x20
[ 515.060286] CoBaLt_ioctl+0xa/0x20
[ 515.060288] handle_head_syscall+0x115/0x5c0
[ 515.060301] pipeline_syscall+0x85/0x120
[ 515.060307] syscall_enter_from_user_mode+0x3f/0xa0
[ 515.060312] do_syscall_64+0x15/0xb0
[ 515.060317] entry_SYSCALL_64_after_hwframe+0x63/0xcdFrom my understanding of the code path we are taking here, it's a non-RT IOCTL that should be fine to take random Linux locks or disable Linux IRQs. But 5.10, 5.15 and 6.1 all complain about being idle here. Any idea where we may confuse lockdep?
Jan
[1]
https://source.denx.de/Xenomai/xenomai/-/commit/91d4232ada71ab2f59709398f370df0c89857e76
Signature · 2 lines
Siemens AG, Technology Competence Center Embedded Linux
Quoted 81 lines · Jan Kiszka
Hi Philippe,
while preparing Xenomai for recent kernels, switching
prandom_u32toget_random_u32[1], I triggered some RCU warning:[ 515.060011] ============================= [ 515.060011] WARNING: suspicious RCU usage [ 515.060012] 6.1.0-rc5+ #10 Not tainted [ 515.060014] ----------------------------- [ 515.060014] ../include/linux/rcupdate.h:740 rcu_read_lock() used illegally while idle! [ 515.060017] [ 515.060017] other info that might help us debug this: [ 515.060017] [ 515.060017] [ 515.060017] rcu_scheduler_active = 2, debug_locks = 1 [ 515.060019] RCU used illegally from extended quiescent state! [ 515.060019] 1 lock held by smokey/1435: [ 515.060021] #0: ffffffff82d63c60 (rcu_read_lock){....}-{1:2}, at: __is_insn_slot_addr+0x5/0x120 [ 515.060049] [ 515.060049] stack backtrace: [ 515.060050] CPU: 0 PID: 1435 Comm: smokey Not tainted 6.1.0-rc5+ #10 [ 515.060053] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.15.0-0-g2dd4b9b-rebuilt.opensuse.org 04/01/2014 [ 515.060054] IRQ stage: Xenomai [ 515.060055] Call Trace: [ 515.060056] <TASK> [ 515.060058] [ 515.060058] ============================= [ 515.060059] WARNING: suspicious RCU usage [ 515.060060] 6.1.0-rc5+ #10 Not tainted [ 515.060061] ----------------------------- [ 515.060061] ../include/linux/rcupdate.h:768 rcu_read_unlock() used illegally while idle! [ 515.060063] [ 515.060063] other info that might help us debug this: [ 515.060063] [ 515.060063] [ 515.060063] rcu_scheduler_active = 2, debug_locks = 1 [ 515.060065] RCU used illegally from extended quiescent state! [ 515.060065] 2 locks held by smokey/1435: [ 515.060067] #0: ffffffff82d63c60 (rcu_read_lock){....}-{1:2}, at: __is_insn_slot_addr+0x5/0x120 [ 515.060073] #1: ffffffff82d63c60 (rcu_read_lock){....}-{1:2}, at: __is_insn_slot_addr+0x5/0x120 [ 515.060078] [ 515.060078] stack backtrace: [ 515.060078] CPU: 0 PID: 1435 Comm: smokey Not tainted 6.1.0-rc5+ #10 [ 515.060081] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.15.0-0-g2dd4b9b-rebuilt.opensuse.org 04/01/2014 [ 515.060082] IRQ stage: Xenomai [ 515.060083] Call Trace: [ 515.060084] <TASK> [ 515.060086] dump_stack_lvl+0x7d/0xb5 [ 515.060106] __is_insn_slot_addr+0x10e/0x120 [ 515.060112] kernel_text_address+0xbf/0xd0 [ 515.060126] __kernel_text_address+0xe/0x40 [ 515.060129] show_trace_log_lvl+0x18c/0x3f0 [ 515.060152] ? dump_stack_lvl+0x7d/0xb5 [ 515.060162] dump_stack_lvl+0x7d/0xb5 [ 515.060168] __is_insn_slot_addr+0xd8/0x120 [ 515.060171] kernel_text_address+0xbf/0xd0 [ 515.060176] __kernel_text_address+0xe/0x40 [ 515.060179] show_trace_log_lvl+0x18c/0x3f0 [ 515.060196] ? dump_stack_lvl+0x7d/0xb5 [ 515.060206] dump_stack_lvl+0x7d/0xb5 [ 515.060212] inband_irq_save+0xa/0x30 [ 515.060215] get_random_u32+0x2f/0x230 [ 515.060228] heapcheck_ioctl+0xa42/0xbb0 [ 515.060244] ? ktime_get_mono_fast_ns+0x3b/0xa0 [ 515.060260] ? rtdm_fd_ioctl+0xec/0x340 [ 515.060270] rtdm_fd_ioctl+0xec/0x340 [ 515.060284] ? CoBaLt_fcntl+0x20/0x20 [ 515.060286] CoBaLt_ioctl+0xa/0x20 [ 515.060288] handle_head_syscall+0x115/0x5c0 [ 515.060301] pipeline_syscall+0x85/0x120 [ 515.060307] syscall_enter_from_user_mode+0x3f/0xa0 [ 515.060312] do_syscall_64+0x15/0xb0 [ 515.060317] entry_SYSCALL_64_after_hwframe+0x63/0xcd
Quoted 4 lines
From my understanding of the code path we are taking here, it's a non-RT IOCTL that should be fine to take random Linux locks or disable Linux IRQs. But 5.10, 5.15 and 6.1 all complain about being idle here. Any idea where we may confuse lockdep?
This syscall is processed from the head stage otherwise it would have been routed to handle_root_syscall() I believe, so the issue is most likely with rcu_is_watching(). There is a fix for this in the linux-evl tree [1], still in the -next branch ATM, will be upstreamed soon.
[1] https://source.denx.de/Xenomai/xenomai4/linux-evl/-/commit/03d19b028241d0385ea72e91481d7468d806ffe8
Signature · 1 line
Philippe.
Quoted 89 lines · Philippe Gerum
Quoted 81 lines · Jan Kiszka
Hi Philippe,
while preparing Xenomai for recent kernels, switching
prandom_u32toget_random_u32[1], I triggered some RCU warning:[ 515.060011] ============================= [ 515.060011] WARNING: suspicious RCU usage [ 515.060012] 6.1.0-rc5+ #10 Not tainted [ 515.060014] ----------------------------- [ 515.060014] ../include/linux/rcupdate.h:740 rcu_read_lock() used illegally while idle! [ 515.060017] [ 515.060017] other info that might help us debug this: [ 515.060017] [ 515.060017] [ 515.060017] rcu_scheduler_active = 2, debug_locks = 1 [ 515.060019] RCU used illegally from extended quiescent state! [ 515.060019] 1 lock held by smokey/1435: [ 515.060021] #0: ffffffff82d63c60 (rcu_read_lock){....}-{1:2}, at: __is_insn_slot_addr+0x5/0x120 [ 515.060049] [ 515.060049] stack backtrace: [ 515.060050] CPU: 0 PID: 1435 Comm: smokey Not tainted 6.1.0-rc5+ #10 [ 515.060053] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.15.0-0-g2dd4b9b-rebuilt.opensuse.org 04/01/2014 [ 515.060054] IRQ stage: Xenomai [ 515.060055] Call Trace: [ 515.060056] <TASK> [ 515.060058] [ 515.060058] ============================= [ 515.060059] WARNING: suspicious RCU usage [ 515.060060] 6.1.0-rc5+ #10 Not tainted [ 515.060061] ----------------------------- [ 515.060061] ../include/linux/rcupdate.h:768 rcu_read_unlock() used illegally while idle! [ 515.060063] [ 515.060063] other info that might help us debug this: [ 515.060063] [ 515.060063] [ 515.060063] rcu_scheduler_active = 2, debug_locks = 1 [ 515.060065] RCU used illegally from extended quiescent state! [ 515.060065] 2 locks held by smokey/1435: [ 515.060067] #0: ffffffff82d63c60 (rcu_read_lock){....}-{1:2}, at: __is_insn_slot_addr+0x5/0x120 [ 515.060073] #1: ffffffff82d63c60 (rcu_read_lock){....}-{1:2}, at: __is_insn_slot_addr+0x5/0x120 [ 515.060078] [ 515.060078] stack backtrace: [ 515.060078] CPU: 0 PID: 1435 Comm: smokey Not tainted 6.1.0-rc5+ #10 [ 515.060081] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.15.0-0-g2dd4b9b-rebuilt.opensuse.org 04/01/2014 [ 515.060082] IRQ stage: Xenomai [ 515.060083] Call Trace: [ 515.060084] <TASK> [ 515.060086] dump_stack_lvl+0x7d/0xb5 [ 515.060106] __is_insn_slot_addr+0x10e/0x120 [ 515.060112] kernel_text_address+0xbf/0xd0 [ 515.060126] __kernel_text_address+0xe/0x40 [ 515.060129] show_trace_log_lvl+0x18c/0x3f0 [ 515.060152] ? dump_stack_lvl+0x7d/0xb5 [ 515.060162] dump_stack_lvl+0x7d/0xb5 [ 515.060168] __is_insn_slot_addr+0xd8/0x120 [ 515.060171] kernel_text_address+0xbf/0xd0 [ 515.060176] __kernel_text_address+0xe/0x40 [ 515.060179] show_trace_log_lvl+0x18c/0x3f0 [ 515.060196] ? dump_stack_lvl+0x7d/0xb5 [ 515.060206] dump_stack_lvl+0x7d/0xb5 [ 515.060212] inband_irq_save+0xa/0x30 [ 515.060215] get_random_u32+0x2f/0x230 [ 515.060228] heapcheck_ioctl+0xa42/0xbb0 [ 515.060244] ? ktime_get_mono_fast_ns+0x3b/0xa0 [ 515.060260] ? rtdm_fd_ioctl+0xec/0x340 [ 515.060270] rtdm_fd_ioctl+0xec/0x340 [ 515.060284] ? CoBaLt_fcntl+0x20/0x20 [ 515.060286] CoBaLt_ioctl+0xa/0x20 [ 515.060288] handle_head_syscall+0x115/0x5c0 [ 515.060301] pipeline_syscall+0x85/0x120 [ 515.060307] syscall_enter_from_user_mode+0x3f/0xa0 [ 515.060312] do_syscall_64+0x15/0xb0 [ 515.060317] entry_SYSCALL_64_after_hwframe+0x63/0xcdQuoted 4 lines
From my understanding of the code path we are taking here, it's a non-RT IOCTL that should be fine to take random Linux locks or disable Linux IRQs. But 5.10, 5.15 and 6.1 all complain about being idle here. Any idea where we may confuse lockdep?
Quoted 7 lines
This syscall is processed from the head stage otherwise it would have been routed to
handle_root_syscall()I believe, so the issue is most likely withrcu_is_watching(). There is a fix for this in the linux-evl tree [1], still in the -next branch ATM, will be upstreamed soon.[1] https://source.denx.de/Xenomai/xenomai4/linux-evl/-/commit/03d19b028241d0385ea72e91481d7468d806ffe8
We are coming from head stage, but the caller should have been migrated to Linux before calling the ioctl_nrt handler. The whole purpose of that handler is to be able to use Linux services, e.g. vmalloc in this case.
Jan
Signature · 2 lines
Siemens AG, Technology Competence Center Embedded Linux
Quoted 95 lines · Jan Kiszka
Quoted 94 lines · Philippe Gerum
Quoted 81 lines · Jan Kiszka
Hi Philippe,
while preparing Xenomai for recent kernels, switching
prandom_u32toget_random_u32[1], I triggered some RCU warning:[ 515.060011] ============================= [ 515.060011] WARNING: suspicious RCU usage [ 515.060012] 6.1.0-rc5+ #10 Not tainted [ 515.060014] ----------------------------- [ 515.060014] ../include/linux/rcupdate.h:740 rcu_read_lock() used illegally while idle! [ 515.060017] [ 515.060017] other info that might help us debug this: [ 515.060017] [ 515.060017] [ 515.060017] rcu_scheduler_active = 2, debug_locks = 1 [ 515.060019] RCU used illegally from extended quiescent state! [ 515.060019] 1 lock held by smokey/1435: [ 515.060021] #0: ffffffff82d63c60 (rcu_read_lock){....}-{1:2}, at: __is_insn_slot_addr+0x5/0x120 [ 515.060049] [ 515.060049] stack backtrace: [ 515.060050] CPU: 0 PID: 1435 Comm: smokey Not tainted 6.1.0-rc5+ #10 [ 515.060053] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.15.0-0-g2dd4b9b-rebuilt.opensuse.org 04/01/2014 [ 515.060054] IRQ stage: Xenomai [ 515.060055] Call Trace: [ 515.060056] <TASK> [ 515.060058] [ 515.060058] ============================= [ 515.060059] WARNING: suspicious RCU usage [ 515.060060] 6.1.0-rc5+ #10 Not tainted [ 515.060061] ----------------------------- [ 515.060061] ../include/linux/rcupdate.h:768 rcu_read_unlock() used illegally while idle! [ 515.060063] [ 515.060063] other info that might help us debug this: [ 515.060063] [ 515.060063] [ 515.060063] rcu_scheduler_active = 2, debug_locks = 1 [ 515.060065] RCU used illegally from extended quiescent state! [ 515.060065] 2 locks held by smokey/1435: [ 515.060067] #0: ffffffff82d63c60 (rcu_read_lock){....}-{1:2}, at: __is_insn_slot_addr+0x5/0x120 [ 515.060073] #1: ffffffff82d63c60 (rcu_read_lock){....}-{1:2}, at: __is_insn_slot_addr+0x5/0x120 [ 515.060078] [ 515.060078] stack backtrace: [ 515.060078] CPU: 0 PID: 1435 Comm: smokey Not tainted 6.1.0-rc5+ #10 [ 515.060081] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.15.0-0-g2dd4b9b-rebuilt.opensuse.org 04/01/2014 [ 515.060082] IRQ stage: Xenomai [ 515.060083] Call Trace: [ 515.060084] <TASK> [ 515.060086] dump_stack_lvl+0x7d/0xb5 [ 515.060106] __is_insn_slot_addr+0x10e/0x120 [ 515.060112] kernel_text_address+0xbf/0xd0 [ 515.060126] __kernel_text_address+0xe/0x40 [ 515.060129] show_trace_log_lvl+0x18c/0x3f0 [ 515.060152] ? dump_stack_lvl+0x7d/0xb5 [ 515.060162] dump_stack_lvl+0x7d/0xb5 [ 515.060168] __is_insn_slot_addr+0xd8/0x120 [ 515.060171] kernel_text_address+0xbf/0xd0 [ 515.060176] __kernel_text_address+0xe/0x40 [ 515.060179] show_trace_log_lvl+0x18c/0x3f0 [ 515.060196] ? dump_stack_lvl+0x7d/0xb5 [ 515.060206] dump_stack_lvl+0x7d/0xb5 [ 515.060212] inband_irq_save+0xa/0x30 [ 515.060215] get_random_u32+0x2f/0x230 [ 515.060228] heapcheck_ioctl+0xa42/0xbb0 [ 515.060244] ? ktime_get_mono_fast_ns+0x3b/0xa0 [ 515.060260] ? rtdm_fd_ioctl+0xec/0x340 [ 515.060270] rtdm_fd_ioctl+0xec/0x340 [ 515.060284] ? CoBaLt_fcntl+0x20/0x20 [ 515.060286] CoBaLt_ioctl+0xa/0x20 [ 515.060288] handle_head_syscall+0x115/0x5c0 [ 515.060301] pipeline_syscall+0x85/0x120 [ 515.060307] syscall_enter_from_user_mode+0x3f/0xa0 [ 515.060312] do_syscall_64+0x15/0xb0 [ 515.060317] entry_SYSCALL_64_after_hwframe+0x63/0xcdQuoted 4 lines
From my understanding of the code path we are taking here, it's a non-RT IOCTL that should be fine to take random Linux locks or disable Linux IRQs. But 5.10, 5.15 and 6.1 all complain about being idle here. Any idea where we may confuse lockdep?
This syscall is processed from the head stage otherwise it would have been routed to
handle_root_syscall()I believe, so the issue is most likely withrcu_is_watching(). There is a fix for this in the linux-evl tree [1], still in the -next branch ATM, will be upstreamed soon.
Quoted 8 lines
Quoted 2 lines
[1] https://source.denx.de/Xenomai/xenomai4/linux-evl/-/commit/03d19b028241d0385ea72e91481d7468d806ffe8
We are coming from head stage, but the caller should have been migrated to Linux before calling the
ioctl_nrthandler. The whole purpose of that[ 515.060082] IRQ stage: Xenomai
As a matter of fact, the core thinks that rtdm_fd_ioctl() did not relax.
Signature · 1 line
Philippe.
Quoted 101 lines · Philippe Gerum
Quoted 98 lines · Jan Kiszka
Quoted 96 lines · Philippe Gerum
Quoted 81 lines · Jan Kiszka
Hi Philippe,
while preparing Xenomai for recent kernels, switching
prandom_u32toget_random_u32[1], I triggered some RCU warning:[ 515.060011] ============================= [ 515.060011] WARNING: suspicious RCU usage [ 515.060012] 6.1.0-rc5+ #10 Not tainted [ 515.060014] ----------------------------- [ 515.060014] ../include/linux/rcupdate.h:740 rcu_read_lock() used illegally while idle! [ 515.060017] [ 515.060017] other info that might help us debug this: [ 515.060017] [ 515.060017] [ 515.060017] rcu_scheduler_active = 2, debug_locks = 1 [ 515.060019] RCU used illegally from extended quiescent state! [ 515.060019] 1 lock held by smokey/1435: [ 515.060021] #0: ffffffff82d63c60 (rcu_read_lock){....}-{1:2}, at: __is_insn_slot_addr+0x5/0x120 [ 515.060049] [ 515.060049] stack backtrace: [ 515.060050] CPU: 0 PID: 1435 Comm: smokey Not tainted 6.1.0-rc5+ #10 [ 515.060053] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.15.0-0-g2dd4b9b-rebuilt.opensuse.org 04/01/2014 [ 515.060054] IRQ stage: Xenomai [ 515.060055] Call Trace: [ 515.060056] <TASK> [ 515.060058] [ 515.060058] ============================= [ 515.060059] WARNING: suspicious RCU usage [ 515.060060] 6.1.0-rc5+ #10 Not tainted [ 515.060061] ----------------------------- [ 515.060061] ../include/linux/rcupdate.h:768 rcu_read_unlock() used illegally while idle! [ 515.060063] [ 515.060063] other info that might help us debug this: [ 515.060063] [ 515.060063] [ 515.060063] rcu_scheduler_active = 2, debug_locks = 1 [ 515.060065] RCU used illegally from extended quiescent state! [ 515.060065] 2 locks held by smokey/1435: [ 515.060067] #0: ffffffff82d63c60 (rcu_read_lock){....}-{1:2}, at: __is_insn_slot_addr+0x5/0x120 [ 515.060073] #1: ffffffff82d63c60 (rcu_read_lock){....}-{1:2}, at: __is_insn_slot_addr+0x5/0x120 [ 515.060078] [ 515.060078] stack backtrace: [ 515.060078] CPU: 0 PID: 1435 Comm: smokey Not tainted 6.1.0-rc5+ #10 [ 515.060081] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.15.0-0-g2dd4b9b-rebuilt.opensuse.org 04/01/2014 [ 515.060082] IRQ stage: Xenomai [ 515.060083] Call Trace: [ 515.060084] <TASK> [ 515.060086] dump_stack_lvl+0x7d/0xb5 [ 515.060106] __is_insn_slot_addr+0x10e/0x120 [ 515.060112] kernel_text_address+0xbf/0xd0 [ 515.060126] __kernel_text_address+0xe/0x40 [ 515.060129] show_trace_log_lvl+0x18c/0x3f0 [ 515.060152] ? dump_stack_lvl+0x7d/0xb5 [ 515.060162] dump_stack_lvl+0x7d/0xb5 [ 515.060168] __is_insn_slot_addr+0xd8/0x120 [ 515.060171] kernel_text_address+0xbf/0xd0 [ 515.060176] __kernel_text_address+0xe/0x40 [ 515.060179] show_trace_log_lvl+0x18c/0x3f0 [ 515.060196] ? dump_stack_lvl+0x7d/0xb5 [ 515.060206] dump_stack_lvl+0x7d/0xb5 [ 515.060212] inband_irq_save+0xa/0x30 [ 515.060215] get_random_u32+0x2f/0x230 [ 515.060228] heapcheck_ioctl+0xa42/0xbb0 [ 515.060244] ? ktime_get_mono_fast_ns+0x3b/0xa0 [ 515.060260] ? rtdm_fd_ioctl+0xec/0x340 [ 515.060270] rtdm_fd_ioctl+0xec/0x340 [ 515.060284] ? CoBaLt_fcntl+0x20/0x20 [ 515.060286] CoBaLt_ioctl+0xa/0x20 [ 515.060288] handle_head_syscall+0x115/0x5c0 [ 515.060301] pipeline_syscall+0x85/0x120 [ 515.060307] syscall_enter_from_user_mode+0x3f/0xa0 [ 515.060312] do_syscall_64+0x15/0xb0 [ 515.060317] entry_SYSCALL_64_after_hwframe+0x63/0xcdQuoted 4 lines
From my understanding of the code path we are taking here, it's a non-RT IOCTL that should be fine to take random Linux locks or disable Linux IRQs. But 5.10, 5.15 and 6.1 all complain about being idle here. Any idea where we may confuse lockdep?
This syscall is processed from the head stage otherwise it would have been routed to
handle_root_syscall()I believe, so the issue is most likely withrcu_is_watching(). There is a fix for this in the linux-evl tree [1], still in the -next branch ATM, will be upstreamed soon.[1] https://source.denx.de/Xenomai/xenomai4/linux-evl/-/commit/03d19b028241d0385ea72e91481d7468d806ffe8
Quoted 8 lines
Quoted 5 lines
We are coming from head stage, but the caller should have been migrated to Linux before calling the
ioctl_nrthandler. The whole purpose of that[ 515.060082] IRQ stage: XenomaiAs a matter of fact, the core thinks that
rtdm_fd_ioctl()did not relax.
Indeed! Just confirmed with a WARN_ON_ONCE(running_oob()). Then we have a different issue. Debugging that one.
Jan
Signature · 2 lines
Siemens AG, Technology Competence Center Embedded Linux
Quoted 106 lines · Jan Kiszka
Quoted 105 lines · Philippe Gerum
Quoted 101 lines · Jan Kiszka
Quoted 89 lines · Philippe Gerum
Quoted 81 lines · Jan Kiszka
Hi Philippe,
while preparing Xenomai for recent kernels, switching
prandom_u32toget_random_u32[1], I triggered some RCU warning:[ 515.060011] ============================= [ 515.060011] WARNING: suspicious RCU usage [ 515.060012] 6.1.0-rc5+ #10 Not tainted [ 515.060014] ----------------------------- [ 515.060014] ../include/linux/rcupdate.h:740 rcu_read_lock() used illegally while idle! [ 515.060017] [ 515.060017] other info that might help us debug this: [ 515.060017] [ 515.060017] [ 515.060017] rcu_scheduler_active = 2, debug_locks = 1 [ 515.060019] RCU used illegally from extended quiescent state! [ 515.060019] 1 lock held by smokey/1435: [ 515.060021] #0: ffffffff82d63c60 (rcu_read_lock){....}-{1:2}, at: __is_insn_slot_addr+0x5/0x120 [ 515.060049] [ 515.060049] stack backtrace: [ 515.060050] CPU: 0 PID: 1435 Comm: smokey Not tainted 6.1.0-rc5+ #10 [ 515.060053] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.15.0-0-g2dd4b9b-rebuilt.opensuse.org 04/01/2014 [ 515.060054] IRQ stage: Xenomai [ 515.060055] Call Trace: [ 515.060056] <TASK> [ 515.060058] [ 515.060058] ============================= [ 515.060059] WARNING: suspicious RCU usage [ 515.060060] 6.1.0-rc5+ #10 Not tainted [ 515.060061] ----------------------------- [ 515.060061] ../include/linux/rcupdate.h:768 rcu_read_unlock() used illegally while idle! [ 515.060063] [ 515.060063] other info that might help us debug this: [ 515.060063] [ 515.060063] [ 515.060063] rcu_scheduler_active = 2, debug_locks = 1 [ 515.060065] RCU used illegally from extended quiescent state! [ 515.060065] 2 locks held by smokey/1435: [ 515.060067] #0: ffffffff82d63c60 (rcu_read_lock){....}-{1:2}, at: __is_insn_slot_addr+0x5/0x120 [ 515.060073] #1: ffffffff82d63c60 (rcu_read_lock){....}-{1:2}, at: __is_insn_slot_addr+0x5/0x120 [ 515.060078] [ 515.060078] stack backtrace: [ 515.060078] CPU: 0 PID: 1435 Comm: smokey Not tainted 6.1.0-rc5+ #10 [ 515.060081] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.15.0-0-g2dd4b9b-rebuilt.opensuse.org 04/01/2014 [ 515.060082] IRQ stage: Xenomai [ 515.060083] Call Trace: [ 515.060084] <TASK> [ 515.060086] dump_stack_lvl+0x7d/0xb5 [ 515.060106] __is_insn_slot_addr+0x10e/0x120 [ 515.060112] kernel_text_address+0xbf/0xd0 [ 515.060126] __kernel_text_address+0xe/0x40 [ 515.060129] show_trace_log_lvl+0x18c/0x3f0 [ 515.060152] ? dump_stack_lvl+0x7d/0xb5 [ 515.060162] dump_stack_lvl+0x7d/0xb5 [ 515.060168] __is_insn_slot_addr+0xd8/0x120 [ 515.060171] kernel_text_address+0xbf/0xd0 [ 515.060176] __kernel_text_address+0xe/0x40 [ 515.060179] show_trace_log_lvl+0x18c/0x3f0 [ 515.060196] ? dump_stack_lvl+0x7d/0xb5 [ 515.060206] dump_stack_lvl+0x7d/0xb5 [ 515.060212] inband_irq_save+0xa/0x30 [ 515.060215] get_random_u32+0x2f/0x230 [ 515.060228] heapcheck_ioctl+0xa42/0xbb0 [ 515.060244] ? ktime_get_mono_fast_ns+0x3b/0xa0 [ 515.060260] ? rtdm_fd_ioctl+0xec/0x340 [ 515.060270] rtdm_fd_ioctl+0xec/0x340 [ 515.060284] ? CoBaLt_fcntl+0x20/0x20 [ 515.060286] CoBaLt_ioctl+0xa/0x20 [ 515.060288] handle_head_syscall+0x115/0x5c0 [ 515.060301] pipeline_syscall+0x85/0x120 [ 515.060307] syscall_enter_from_user_mode+0x3f/0xa0 [ 515.060312] do_syscall_64+0x15/0xb0 [ 515.060317] entry_SYSCALL_64_after_hwframe+0x63/0xcdQuoted 4 lines
From my understanding of the code path we are taking here, it's a non-RT IOCTL that should be fine to take random Linux locks or disable Linux IRQs. But 5.10, 5.15 and 6.1 all complain about being idle here. Any idea where we may confuse lockdep?
Quoted 7 lines
This syscall is processed from the head stage otherwise it would have been routed to
handle_root_syscall()I believe, so the issue is most likely withrcu_is_watching(). There is a fix for this in the linux-evl tree [1], still in the -next branch ATM, will be upstreamed soon.[1] https://source.denx.de/Xenomai/xenomai4/linux-evl/-/commit/03d19b028241d0385ea72e91481d7468d806ffe8
We are coming from head stage, but the caller should have been migrated to Linux before calling the
ioctl_nrthandler. The whole purpose of that
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
[ 515.060082] IRQ stage: XenomaiAs a matter of fact, the core thinks that
rtdm_fd_ioctl()did not relax.Indeed! Just confirmed with a WARN_ON_ONCE(running_oob()). Then we have a different issue. Debugging that one.
Argh, test_seq() switches itself back to primary after its non-RT initialization, then eventually calls the get_random_u32 which fails, and returns to secondary before returing to the caller.
So, the problem is that old prandom_u32 was oob-safe, get_random_u32 is no longer. I don't think it is worth to harden it for this testcase, so we need to look for some alternative algorithm. Pseudo random should be fine here, right?
Jan
Signature · 2 lines
Siemens AG, Technology Competence Center Embedded Linux