RCU stall in sock_def_readable()
Hi,
Did anything change recently with respect to RCU stall detection or sock_def_readable()? My tests have been failing pretty much in the same place every other time I run it. It's getting rather annoying. The test runs:
trace-cmd record -p function -e syscalls ./hackbench 50
(enables syscall trace events along with function tracing and records to a file)
On a VM with the attached config (it has LOCKDEP enabled), and every other run the following triggers:
[ 219.564147] rcu: INFO: rcu_preempt detected stalls on CPUs/tasks: [ 219.566376] rcu: Tasks blocked on level-0 rcu_node (CPUs 0-3): P3152/1:b..l [ 219.568975] rcu: (detected by 0, t=6502 jiffies, g=30165, q=175 ncpus=4) [ 219.571215] task:hackbench_64 state:R running task stack:0 pid:3152 tgid:3152 ppid:3145 task_flags:0x400000 flags:0x00080000 [ 219.575470] Call Trace: [ 219.576432] <TASK> [ 219.577396] __schedule+0x4ac/0x12f0 [ 219.578731] preempt_schedule_common+0x26/0xe0 [ 219.580319] ? preempt_schedule_thunk+0x16/0x30 [ 219.581956] preempt_schedule_thunk+0x16/0x30 [ 219.583550] ? _raw_spin_unlock_irqrestore+0x39/0x70 [ 219.585328] _raw_spin_unlock_irqrestore+0x5d/0x70 [ 219.587039] sock_def_readable+0x9c/0x2b0 [ 219.588509] unix_stream_sendmsg+0x2d7/0x710 [ 219.590104] sock_write_iter+0x185/0x190 [ 219.591591] vfs_write+0x457/0x5b0 [ 219.592900] ksys_write+0xc8/0xf0 [ 219.594173] do_syscall_64+0x117/0x1660 [ 219.595586] ? irqentry_exit+0xd9/0x690 [ 219.596992] entry_SYSCALL_64_after_hwframe+0x76/0x7e [ 219.598809] RIP: 0033:0x7f30e2eb0190 [ 219.600239] RSP: 002b:00007ffd4e5f9368 EFLAGS: 00000202 ORIG_RAX: 0000000000000001 [ 219.602828] RAX: ffffffffffffffda RBX: 00007ffd4e5f94f8 RCX: 00007f30e2eb0190 [ 219.605254] RDX: 0000000000000001 RSI: 00007ffd4e5f938f RDI: 0000000000000006 [ 219.607598] RBP: 00007ffd4e5f93e0 R08: 00057bcf00000000 R09: 0000000000000000 [ 219.609969] R10: 00007f30e2dd14d0 R11: 0000000000000202 R12: 0000000000000000 [ 219.612453] R13: 00007ffd4e5f9510 R14: 000055c31b856dd8 R15: 00007f30e2fdb020 [ 219.614933] </TASK>
Always with the exact same stacktrace!
Note, the machine is fine. It's not locked up at all. It appears to be something that might be blocking RCU for a little longer than RCU would like.
I'm not sure if RCU changed its stall detection that makes it more sensitive or if the sock_def_readable() did something different that causes more contention or something, but this has started with the 7.0-rc1.
Any ideas?
-- Steve
Quoted 49 lines · Steven Rostedt
Hi,
Did anything change recently with respect to RCU stall detection or
sock_def_readable()? My tests have been failing pretty much in the same place every other time I run it. It's getting rather annoying. The test runs:trace-cmd record -p function -e syscalls ./hackbench 50
(enables syscall trace events along with function tracing and records to a file)
On a VM with the attached config (it has LOCKDEP enabled), and every other run the following triggers:
[ 219.564147] rcu: INFO: rcu_preempt detected stalls on CPUs/tasks: [ 219.566376] rcu: Tasks blocked on level-0 rcu_node (CPUs 0-3): P3152/1:b..l [ 219.568975] rcu: (detected by 0, t=6502 jiffies, g=30165, q=175 ncpus=4) [ 219.571215] task:hackbench_64 state:R running task stack:0 pid:3152 tgid:3152 ppid:3145 task_flags:0x400000 flags:0x00080000 [ 219.575470] Call Trace: [ 219.576432] <TASK> [ 219.577396] __schedule+0x4ac/0x12f0 [ 219.578731] preempt_schedule_common+0x26/0xe0 [ 219.580319] ? preempt_schedule_thunk+0x16/0x30 [ 219.581956] preempt_schedule_thunk+0x16/0x30 [ 219.583550] ? _raw_spin_unlock_irqrestore+0x39/0x70 [ 219.585328] _raw_spin_unlock_irqrestore+0x5d/0x70 [ 219.587039] sock_def_readable+0x9c/0x2b0 [ 219.588509] unix_stream_sendmsg+0x2d7/0x710 [ 219.590104] sock_write_iter+0x185/0x190 [ 219.591591] vfs_write+0x457/0x5b0 [ 219.592900] ksys_write+0xc8/0xf0 [ 219.594173] do_syscall_64+0x117/0x1660 [ 219.595586] ? irqentry_exit+0xd9/0x690 [ 219.596992] entry_SYSCALL_64_after_hwframe+0x76/0x7e [ 219.598809] RIP: 0033:0x7f30e2eb0190 [ 219.600239] RSP: 002b:00007ffd4e5f9368 EFLAGS: 00000202 ORIG_RAX: 0000000000000001 [ 219.602828] RAX: ffffffffffffffda RBX: 00007ffd4e5f94f8 RCX: 00007f30e2eb0190 [ 219.605254] RDX: 0000000000000001 RSI: 00007ffd4e5f938f RDI: 0000000000000006 [ 219.607598] RBP: 00007ffd4e5f93e0 R08: 00057bcf00000000 R09: 0000000000000000 [ 219.609969] R10: 00007f30e2dd14d0 R11: 0000000000000202 R12: 0000000000000000 [ 219.612453] R13: 00007ffd4e5f9510 R14: 000055c31b856dd8 R15: 00007f30e2fdb020 [ 219.614933] </TASK>Always with the exact same stacktrace!
Note, the machine is fine. It's not locked up at all. It appears to be something that might be blocking RCU for a little longer than RCU would like.
Quoted 6 lines
I'm not sure if RCU changed its stall detection that makes it more sensitive or if the
sock_def_readable()did something different that causes more contention or something, but this has started with the 7.0-rc1.Any ideas?
One "hail Mary" thought is to revert this guy and see if it helps:
d41e37f26b31 ("rcu: Fix rcu_read_unlock() deadloop due to softirq")
This commit fixes a bug, so we cannot revert it in mainline, but there is some reason to believe that there are more bugs beyond the one that it fixed, and it might have (through no fault of its own) made those other bugs more probable.
Worth a try, anyway!
Thanx, Paul
Quoted 10 lines · On Thu, 16 Apr 2026 17:16:11 -0700 "Paul E. McKenney" <[email protected]>…
One "hail Mary" thought is to revert this guy and see if it helps:
d41e37f26b31("rcu: Fixrcu_read_unlock()deadloop due to softirq")This commit fixes a bug, so we cannot revert it in mainline, but there is some reason to believe that there are more bugs beyond the one that it fixed, and it might have (through no fault of its own) made those other bugs more probable.
Worth a try, anyway!
Hail mary's are worth a try, but the reason they call it a hail mary is because it is unlikely to succeed :-p
run test ssh -t root@tracetest "trace-cmd record -p function -e syscalls /work/c/hackbench_64 50"
ssh -t root@tracetest "trace-cmd record -p function -e syscalls /work/c/hackbench_64 50" ... [ 209.590500] rcu: INFO: rcu_preempt detected stalls on CPUs/tasks:
[ 209.592620] rcu: Tasks blocked on level-0 rcu_node (CPUs 0-3): P3151/1:b..l [ 209.595266] rcu: (detected by 0, t=6502 jiffies, g=29673, q=186 ncpus=4) [ 209.597557] task:hackbench_64 state:R running task stack:0 pid:3151 tgid:3151 ppid:3144 task_flags:0x400000 flags:0x00080000 [ 209.601871] Call Trace: [ 209.602852] <TASK> [ 209.603752] __schedule+0x4ac/0x12f0 [ 209.605172] preempt_schedule_common+0x26/0xe0 [ 209.606755] ? preempt_schedule_thunk+0x16/0x30 [ 209.608337] preempt_schedule_thunk+0x16/0x30 [ 209.609973] ? _raw_spin_unlock_irqrestore+0x39/0x70 [ 209.611688] _raw_spin_unlock_irqrestore+0x5d/0x70 [ 209.613408] sock_def_readable+0x9c/0x2b0 [ 209.614841] unix_stream_sendmsg+0x2d7/0x710 [ 209.616420] sock_write_iter+0x185/0x190 [ 209.617934] vfs_write+0x457/0x5b0 [ 209.619242] ksys_write+0xc8/0xf0 [ 209.620532] do_syscall_64+0x117/0x1660 [ 209.621936] ? irqentry_exit+0xd9/0x690 [ 209.623319] entry_SYSCALL_64_after_hwframe+0x76/0x7e [ 209.625199] RIP: 0033:0x7f603e8e5190 [ 209.626628] RSP: 002b:00007ffd003f99c8 EFLAGS: 00000202 ORIG_RAX: 0000000000000001 [ 209.629304] RAX: ffffffffffffffda RBX: 00007ffd003f9b58 RCX: 00007f603e8e5190 [ 209.631710] RDX: 0000000000000001 RSI: 00007ffd003f99ef RDI: 0000000000000006 [ 209.634200] RBP: 00007ffd003f9a40 R08: 0011861580000000 R09: 0000000000000000 [ 209.636638] R10: 00007f603e8064d0 R11: 0000000000000202 R12: 0000000000000000 [ 209.639050] R13: 00007ffd003f9b70 R14: 00005637df126dd8 R15: 00007f603ea10020 [ 209.641600] </TASK>
Detected kernel crash!
That was with the revert :-(
-- Steve
Quoted 46 lines · On Fri, 17 Apr 2026 08:43:13 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 10 lines · On Thu, 16 Apr 2026 17:16:11 -0700 "Paul E. McKenney" <[email protected]>…
One "hail Mary" thought is to revert this guy and see if it helps:
d41e37f26b31("rcu: Fixrcu_read_unlock()deadloop due to softirq")This commit fixes a bug, so we cannot revert it in mainline, but there is some reason to believe that there are more bugs beyond the one that it fixed, and it might have (through no fault of its own) made those other bugs more probable.
Worth a try, anyway!
Hail mary's are worth a try, but the reason they call it a hail mary is because it is unlikely to succeed :-p
run test ssh -t root@tracetest "trace-cmd record -p function -e syscalls /work/c/hackbench_64 50"
ssh -t root@tracetest "trace-cmd record -p function -e syscalls /work/c/hackbench_64 50" ... [ 209.590500] rcu: INFO:rcu_preemptdetected stalls on CPUs/tasks:[ 209.592620] rcu: Tasks blocked on level-0 rcu_node (CPUs 0-3): P3151/1:b..l [ 209.595266] rcu: (detected by 0, t=6502 jiffies, g=29673, q=186 ncpus=4) [ 209.597557] task:hackbench_64 state:R running task stack:0 pid:3151 tgid:3151 ppid:3144 task_flags:0x400000 flags:0x00080000 [ 209.601871] Call Trace: [ 209.602852] <TASK> [ 209.603752] __schedule+0x4ac/0x12f0 [ 209.605172] preempt_schedule_common+0x26/0xe0 [ 209.606755] ? preempt_schedule_thunk+0x16/0x30 [ 209.608337] preempt_schedule_thunk+0x16/0x30 [ 209.609973] ? _raw_spin_unlock_irqrestore+0x39/0x70 [ 209.611688] _raw_spin_unlock_irqrestore+0x5d/0x70 [ 209.613408] sock_def_readable+0x9c/0x2b0 [ 209.614841] unix_stream_sendmsg+0x2d7/0x710 [ 209.616420] sock_write_iter+0x185/0x190 [ 209.617934] vfs_write+0x457/0x5b0 [ 209.619242] ksys_write+0xc8/0xf0 [ 209.620532] do_syscall_64+0x117/0x1660 [ 209.621936] ? irqentry_exit+0xd9/0x690 [ 209.623319] entry_SYSCALL_64_after_hwframe+0x76/0x7e [ 209.625199] RIP: 0033:0x7f603e8e5190 [ 209.626628] RSP: 002b:00007ffd003f99c8 EFLAGS: 00000202 ORIG_RAX: 0000000000000001 [ 209.629304] RAX: ffffffffffffffda RBX: 00007ffd003f9b58 RCX: 00007f603e8e5190 [ 209.631710] RDX: 0000000000000001 RSI: 00007ffd003f99ef RDI: 0000000000000006 [ 209.634200] RBP: 00007ffd003f9a40 R08: 0011861580000000 R09: 0000000000000000 [ 209.636638] R10: 00007f603e8064d0 R11: 0000000000000202 R12: 0000000000000000 [ 209.639050] R13: 00007ffd003f9b70 R14: 00005637df126dd8 R15: 00007f603ea10020 [ 209.641600] </TASK>
Quoted 4 lines
Detected kernel crash!
That was with the revert :-(
I went and looked at the configs that it used to see if that changed. One thing that stands out is that it used to use CONFIG_PREEMPT_VOLUNTARY. Now it's using CONFIG_PREEMPT_LAZY. I'm thinking that because preemption now doesn't happen until tasks go back to user space (and kernel threads do not preempt at all), that this could have delayed the RCU threads much longer.
I'm not sure why the stack trace is always the same. Maybe that's where the biggest delay is caused by hackbench? I'm going to switch it over to PREEMPT_FULL and see if that makes the warning go away. Oh, and when I logged into this box, I noticed that it triggered an OOM due to memory not being freed up fast enough.
All that said, my config is full of a lot of debugging that does have a high overhead which makes this issue much more predominate. It may not even be something to worry about. If switch to PREEMPT_FULL fixes it, then that may be all I do.
Configs that cause overhead:
PROVE_LOCKING
FTRACE_RECORD_RECURSION - keeps track of function trace recursion RING_BUFFER_VALIDATE_TIME_DELTAS - this causes a big overhead with tracing
it tests the timestamps of every event. This requires walking the sub-buffer page and adding the time deltas of each event to make sure it adds up to the current event. That's an O(n^2) operation on the number of events in the sub-buffer.
With the above overhead I do consider this one of those "Doctor it hurts me when I do this. Doctor: Then don't do that" moments. But this test has been running for years with no issues except for catching cases where the timestamp did get out of sync. Hence, I don't want to stop testing this. But if I can find the culprit, I can modify the test to avoid failing due to it.
-- Steve
Quoted 15 lines · Steven Rostedt
Quoted 12 lines · On Fri, 17 Apr 2026 08:43:13 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 9 lines · On Thu, 16 Apr 2026 17:16:11 -0700 "Paul E. McKenney" <[email protected]>…
One "hail Mary" thought is to revert this guy and see if it helps:
d41e37f26b31("rcu: Fixrcu_read_unlock()deadloop due to softirq")This commit fixes a bug, so we cannot revert it in mainline, but there is some reason to believe that there are more bugs beyond the one that it fixed, and it might have (through no fault of its own) made those other bugs more probable.
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Worth a try, anyway!
Hail mary's are worth a try, but the reason they call it a hail mary is because it is unlikely to succeed :-p
True enough!
Quoted 32 lines
Quoted 32 lines
run test ssh -t root@tracetest "trace-cmd record -p function -e syscalls /work/c/hackbench_64 50"
ssh -t root@tracetest "trace-cmd record -p function -e syscalls /work/c/hackbench_64 50" ... [ 209.590500] rcu: INFO:rcu_preemptdetected stalls on CPUs/tasks:[ 209.592620] rcu: Tasks blocked on level-0 rcu_node (CPUs 0-3): P3151/1:b..l [ 209.595266] rcu: (detected by 0, t=6502 jiffies, g=29673, q=186 ncpus=4) [ 209.597557] task:hackbench_64 state:R running task stack:0 pid:3151 tgid:3151 ppid:3144 task_flags:0x400000 flags:0x00080000 [ 209.601871] Call Trace: [ 209.602852] <TASK> [ 209.603752] __schedule+0x4ac/0x12f0 [ 209.605172] preempt_schedule_common+0x26/0xe0 [ 209.606755] ? preempt_schedule_thunk+0x16/0x30 [ 209.608337] preempt_schedule_thunk+0x16/0x30 [ 209.609973] ? _raw_spin_unlock_irqrestore+0x39/0x70 [ 209.611688] _raw_spin_unlock_irqrestore+0x5d/0x70 [ 209.613408] sock_def_readable+0x9c/0x2b0 [ 209.614841] unix_stream_sendmsg+0x2d7/0x710 [ 209.616420] sock_write_iter+0x185/0x190 [ 209.617934] vfs_write+0x457/0x5b0 [ 209.619242] ksys_write+0xc8/0xf0 [ 209.620532] do_syscall_64+0x117/0x1660 [ 209.621936] ? irqentry_exit+0xd9/0x690 [ 209.623319] entry_SYSCALL_64_after_hwframe+0x76/0x7e [ 209.625199] RIP: 0033:0x7f603e8e5190 [ 209.626628] RSP: 002b:00007ffd003f99c8 EFLAGS: 00000202 ORIG_RAX: 0000000000000001 [ 209.629304] RAX: ffffffffffffffda RBX: 00007ffd003f9b58 RCX: 00007f603e8e5190 [ 209.631710] RDX: 0000000000000001 RSI: 00007ffd003f99ef RDI: 0000000000000006 [ 209.634200] RBP: 00007ffd003f9a40 R08: 0011861580000000 R09: 0000000000000000 [ 209.636638] R10: 00007f603e8064d0 R11: 0000000000000202 R12: 0000000000000000 [ 209.639050] R13: 00007ffd003f9b70 R14: 00005637df126dd8 R15: 00007f603ea10020 [ 209.641600] </TASK>Detected kernel crash!
Quoted 8 lines
Quoted 1 line
That was with the revert :-(
I went and looked at the configs that it used to see if that changed. One thing that stands out is that it used to use
CONFIG_PREEMPT_VOLUNTARY. Now it's usingCONFIG_PREEMPT_LAZY. I'm thinking that because preemption now doesn't happen until tasks go back to user space (and kernel threads do not preempt at all), that this could have delayed the RCU threads much longer.
Good point, that could add latency and delay on average, though it should presumably reduce P99 latency/delay.
Quoted 5 lines
I'm not sure why the stack trace is always the same. Maybe that's where the biggest delay is caused by hackbench? I'm going to switch it over to
PREEMPT_FULLand see if that makes the warning go away. Oh, and when I logged into this box, I noticed that it triggered an OOM due to memory not being freed up fast enough.
Sounds as likely a cause as any.
Quoted 4 lines
All that said, my config is full of a lot of debugging that does have a high overhead which makes this issue much more predominate. It may not even be something to worry about. If switch to
PREEMPT_FULLfixes it, then that may be all I do.
I am chasing one where switching to PREEMPT_FULL makes it worse, so that would average things out. ;-)
Quoted 12 lines
Configs that cause overhead:
PROVE_LOCKING
FTRACE_RECORD_RECURSION- keeps track of function trace recursionRING_BUFFER_VALIDATE_TIME_DELTAS- this causes a big overhead with tracing
it tests the timestamps of every event. This requires walking the sub-buffer page and adding the time deltas of each event to make sure it adds up to the current event. That's an O(n^2) operation on the number of events in the sub-buffer.
Quoted 6 lines
With the above overhead I do consider this one of those "Doctor it hurts me when I do this. Doctor: Then don't do that" moments. But this test has been running for years with no issues except for catching cases where the timestamp did get out of sync. Hence, I don't want to stop testing this. But if I can find the culprit, I can modify the test to avoid failing due to it.
Huh. One other possibility is that CONFIG_PREEMPT_NONE=y and its friend CONFIG_PREEMPT_VOLUNTARY=y responded to RCU calls for help at any call to cond_resched() or (in the voluntary case) might_sleep(). Isn't it the case that with CONFIG_PREEMPT_LAZY=y, nothing happens until some other task shows up on that CPU? Maybe RCU needs to be more aggressive about invoking resched_cpu() when the grace period starts getting a bit long in the tooth?
(I am very distracted today, so unlikely to make much progress on this.)
Thanx, Paul
Quoted 7 lines · On Fri, 17 Apr 2026 12:03:22 -0700 "Paul E. McKenney" <[email protected]>…
Huh. One other possibility is that
CONFIG_PREEMPT_NONE=yand its friendCONFIG_PREEMPT_VOLUNTARY=yresponded to RCU calls for help at any call tocond_resched()or (in the voluntary case)might_sleep(). Isn't it the case that withCONFIG_PREEMPT_LAZY=y, nothing happens until some other task shows up on that CPU? Maybe RCU needs to be more aggressive about invokingresched_cpu()when the grace period starts getting a bit long in the tooth?
Perhaps.
Note, I was still able to trigger the issue with PREEMPT_FULL. But anyway, I think I may have found the culprit. It looks to be a __wake_up_common that is waking up too many tasks:
hackbench_64-4695 [001] ..... 328.224508: function: consume_skb <-- unix_stream_read_generic
hackbench_64-4695 [001] ..... 328.224508: function: skb_release_head_state <-- consume_skb
hackbench_64-4695 [001] ..... 328.224508: function: unix_destruct_scm <-- skb_release_head_state
hackbench_64-4695 [001] ..... 328.224508: function: put_pid <-- unix_destruct_scm
hackbench_64-4695 [001] ..... 328.224508: function: sock_wfree <-- unix_destruct_scm
hackbench_64-4695 [001] ..... 328.224509: function: unix_write_space <-- sock_wfree
hackbench_64-4695 [001] ..... 328.224509: function: __rcu_read_lock <-- unix_write_space
hackbench_64-4695 [001] ..... 328.224509: function: __wake_up_sync_key <-- unix_write_space
hackbench_64-4695 [001] ..... 328.224510: function: _raw_spin_lock_irqsave <-- __wake_up_sync_key
hackbench_64-4695 [001] d.... 328.224510: function: preempt_count_add <-- _raw_spin_lock_irqsave
hackbench_64-4695 [001] d..1. 328.224510: function: do_raw_spin_lock <-- _raw_spin_lock_irqsave
hackbench_64-4695 [001] d..1. 328.224511: function: __wake_up_common <-- __wake_up_sync_key
hackbench_64-4695 [001] d..1. 328.224511: function: autoremove_wake_function <-- __wake_up_common
hackbench_64-4695 [001] d..1. 328.224511: function: default_wake_function <-- autoremove_wake_function
hackbench_64-4695 [001] d..1. 328.224512: function: try_to_wake_up <-- autoremove_wake_functionThe above __wake_up_common() goes into a very long loop, so much so that the LAZY_NEED_RESCHED is triggered (look at the 'L' in the flags field of the trace:
hackbench_64-4695 [001] d..4. 328.224582: function: vruntime_eligible <-- __pick_eevdf
hackbench_64-4695 [001] d..4. 328.224582: function: vruntime_eligible <-- __pick_eevdf
hackbench_64-4695 [001] d..4. 328.224584: function: resched_curr_lazy <-- wakeup_preempt
hackbench_64-4695 [001] d..4. 328.224584: function: __resched_curr <-- wakeup_preempt
hackbench_64-4695 [001] dL.4. 328.224584: function: __srcu_check_read_flavor <-- ttwu_do_activate
hackbench_64-4695 [001] dL.4. 328.224585: function: __srcu_check_read_flavor <-- ttwu_do_activate
hackbench_64-4695 [001] dL.4. 328.224585: function: _raw_spin_unlock <-- try_to_wake_up
hackbench_64-4695 [001] dL.4. 328.224585: function: do_raw_spin_unlock <-- _raw_spin_unlock
hackbench_64-4695 [001] dL.4. 328.224586: function: preempt_count_sub <-- _raw_spin_unlock
hackbench_64-4695 [001] dL.3. 328.224586: function: _raw_spin_unlock_irqrestore <-- try_to_wake_up
hackbench_64-4695 [001] dL.3. 328.224586: function: do_raw_spin_unlock <-- _raw_spin_unlock_irqrestore
hackbench_64-4695 [001] dL.3. 328.224586: function: preempt_count_sub <-- _raw_spin_unlock_irqrestore
hackbench_64-4695 [001] dL.2. 328.224586: function: preempt_count_sub <-- try_to_wake_up
hackbench_64-4695 [001] dL.1. 328.224587: function: autoremove_wake_function <-- __wake_up_common
hackbench_64-4695 [001] dL.1. 328.224587: function: default_wake_function <-- autoremove_wake_function
hackbench_64-4695 [001] dL.1. 328.224587: function: try_to_wake_up <-- autoremove_wake_function
hackbench_64-4695 [001] dL.1. 328.224588: function: preempt_count_add <-- try_to_wake_up
hackbench_64-4695 [001] dL.2. 328.224588: function: _raw_spin_lock_irqsave <-- try_to_wake_up
hackbench_64-4695 [001] dL.2. 328.224588: function: preempt_count_add <-- _raw_spin_lock_irqsave
hackbench_64-4695 [001] dL.3. 328.224588: function: do_raw_spin_lock <-- _raw_spin_lock_irqsave
hackbench_64-4695 [001] dL.3. 328.224589: function: select_task_rq_fair <-- try_to_wake_up
hackbench_64-4695 [001] dL.3. 328.224589: function: __rcu_read_lock <-- select_task_rq_fair
hackbench_64-4695 [001] dL.3. 328.224589: function: __rcu_read_unlock <-- select_task_rq_fair
hackbench_64-4695 [001] dL.3. 328.224590: function: ttwu_queue_wakelist <-- try_to_wake_up
hackbench_64-4695 [001] dL.3. 328.224590: function: __smp_call_single_queue <-- ttwu_queue_wakelist
^This goes on for a very long time, and the next tick is hit which causes a full NEED_RESCHED to happen:
hackbench_64-4695 [001] dLh1. 328.229455: function: sched_tick <-- update_process_times
hackbench_64-4695 [001] dLh1. 328.229456: function: arch_scale_freq_tick <-- sched_tick
hackbench_64-4695 [001] dLh1. 328.229456: function: preempt_count_add <-- sched_tick
hackbench_64-4695 [001] dLh2. 328.229457: function: _raw_spin_lock_nested <-- sched_tick
hackbench_64-4695 [001] dLh2. 328.229457: function: preempt_count_add <-- _raw_spin_lock_nested
hackbench_64-4695 [001] dLh3. 328.229458: function: do_raw_spin_lock <-- sched_tick
hackbench_64-4695 [001] dLh3. 328.229470: function: preempt_count_sub <-- sched_tick
hackbench_64-4695 [001] dLh2. 328.229470: function: update_rq_clock <-- sched_tick
hackbench_64-4695 [001] dLh2. 328.229471: function: arch_scale_cpu_capacity <-- update_rq_clock
hackbench_64-4695 [001] dLh2. 328.229472: function: __resched_curr <-- sched_tick
hackbench_64-4695 [001] dNh2. 328.229472: function: task_tick_fair <-- sched_tick
hackbench_64-4695 [001] dNh2. 328.229473: function: update_curr <-- task_tick_fair
hackbench_64-4695 [001] dNh2. 328.229473: function: update_se <-- update_curr
hackbench_64-4695 [001] dNh2. 328.229474: function: cpuacct_charge <-- update_se
hackbench_64-4695 [001] dNh2. 328.229474: function: __cgroup_account_cputime <-- update_se
hackbench_64-4695 [001] dNh2. 328.229475: function: preempt_count_add <-- __cgroup_account_cputime
hackbench_64-4695 [001] dNh3. 328.229476: function: css_rstat_updated <-- __cgroup_account_cputime
hackbench_64-4695 [001] dNh3. 328.229476: function: preempt_count_sub <-- __cgroup_account_cputime
hackbench_64-4695 [001] dNh2. 328.229477: function: dl_server_update <-- update_curr
hackbench_64-4695 [001] dNh2. 328.229477: function: update_curr_dl_se <-- update_curr
hackbench_64-4695 [001] dNh2. 328.229478: function: resched_curr_lazy <-- update_curr
hackbench_64-4695 [001] dNh2. 328.229478: function: __resched_curr <-- update_currSo this task finally gets scheduled out (while holding RCU read lock):
static void unix_write_space(struct sock *sk)
{
struct socket_wq *wq;
rcu_read_lock();
if (unix_writable(sk, READ_ONCE(sk->sk_state))) {
wq = rcu_dereference(sk->sk_wq);
if (skwq_has_sleeper(wq))
wake_up_interruptible_sync_poll(&wq->wait,
EPOLLOUT | EPOLLWRNORM | EPOLLWRBAND);
sk_wake_async_rcu(sk, SOCK_WAKE_SPACE, POLL_OUT);
}
rcu_read_unlock();
}And because the system is very busy, it doesn't get scheduled in for a long time, and RCU complains about a stall:
[ 357.679707] rcu: INFO: rcu_preempt detected stalls on CPUs/tasks: [ 357.810980] rcu: Tasks blocked on level-0 rcu_node (CPUs 0-3): P4695/1:b..l [ 357.813601] rcu: (detected by 2, t=6535 jiffies, g=4125, q=100 ncpus=4) [ 357.816256] task:hackbench_64 state:R running task stack:0 pid:4695 tgid:4695 ppid:4690 task_flags:0x400000 flags:0x00080000 [ 357.821176] Call Trace: [ 357.822382] <TASK> [ 357.823474] __schedule+0x4ac/0x12f0 [ 357.825104] preempt_schedule_common+0x26/0xe0 [ 357.826988] ? preempt_schedule_thunk+0x16/0x30 [ 357.828930] preempt_schedule_thunk+0x16/0x30 [ 357.830788] ? _raw_spin_unlock_irqrestore+0x39/0x70 [ 357.832901] _raw_spin_unlock_irqrestore+0x5d/0x70 [ 357.834884] sock_def_readable+0x9c/0x2b0 [ 357.836633] unix_stream_sendmsg+0x2d7/0x710 [ 357.838423] sock_write_iter+0x185/0x190 [ 357.840084] vfs_write+0x457/0x5b0 [ 357.841568] ksys_write+0xc8/0xf0 [ 357.842914] do_syscall_64+0x117/0x1660 [ 357.844413] ? irqentry_exit+0xd9/0x690
Now I guess the question is, how do we fix this?
Before LAZY_PREEMPT, an rcu_read_lock() would never schedule out. Now, long loops under RCU can schedule out, which can be flagged as an RCU stall. Should we not schedule out when rcu_read_lock() is held?
-- Steve
Quoted 129 lines · Steven Rostedt
Quoted 7 lines · On Fri, 17 Apr 2026 12:03:22 -0700 "Paul E. McKenney" <[email protected]>…
Huh. One other possibility is that
CONFIG_PREEMPT_NONE=yand its friendCONFIG_PREEMPT_VOLUNTARY=yresponded to RCU calls for help at any call tocond_resched()or (in the voluntary case)might_sleep(). Isn't it the case that withCONFIG_PREEMPT_LAZY=y, nothing happens until some other task shows up on that CPU? Maybe RCU needs to be more aggressive about invokingresched_cpu()when the grace period starts getting a bit long in the tooth?Perhaps.
Note, I was still able to trigger the issue with
PREEMPT_FULL. But anyway, I think I may have found the culprit. It looks to be a__wake_up_commonthat is waking up too many tasks:hackbench_64-4695 [001] ..... 328.224508: function: consume_skb <-- unix_stream_read_generic hackbench_64-4695 [001] ..... 328.224508: function: skb_release_head_state <-- consume_skb hackbench_64-4695 [001] ..... 328.224508: function: unix_destruct_scm <-- skb_release_head_state hackbench_64-4695 [001] ..... 328.224508: function: put_pid <-- unix_destruct_scm hackbench_64-4695 [001] ..... 328.224508: function: sock_wfree <-- unix_destruct_scm hackbench_64-4695 [001] ..... 328.224509: function: unix_write_space <-- sock_wfree hackbench_64-4695 [001] ..... 328.224509: function: __rcu_read_lock <-- unix_write_space hackbench_64-4695 [001] ..... 328.224509: function: __wake_up_sync_key <-- unix_write_space hackbench_64-4695 [001] ..... 328.224510: function: _raw_spin_lock_irqsave <-- __wake_up_sync_key hackbench_64-4695 [001] d.... 328.224510: function: preempt_count_add <-- _raw_spin_lock_irqsave hackbench_64-4695 [001] d..1. 328.224510: function: do_raw_spin_lock <-- _raw_spin_lock_irqsave hackbench_64-4695 [001] d..1. 328.224511: function: __wake_up_common <-- __wake_up_sync_key hackbench_64-4695 [001] d..1. 328.224511: function: autoremove_wake_function <-- __wake_up_common hackbench_64-4695 [001] d..1. 328.224511: function: default_wake_function <-- autoremove_wake_function hackbench_64-4695 [001] d..1. 328.224512: function: try_to_wake_up <-- autoremove_wake_functionThe above
__wake_up_common()goes into a very long loop, so much so that theLAZY_NEED_RESCHEDis triggered (look at the 'L' in the flags field of the trace:hackbench_64-4695 [001] d..4. 328.224582: function: vruntime_eligible <-- __pick_eevdf hackbench_64-4695 [001] d..4. 328.224582: function: vruntime_eligible <-- __pick_eevdf hackbench_64-4695 [001] d..4. 328.224584: function: resched_curr_lazy <-- wakeup_preempt hackbench_64-4695 [001] d..4. 328.224584: function: __resched_curr <-- wakeup_preempt hackbench_64-4695 [001] dL.4. 328.224584: function: __srcu_check_read_flavor <-- ttwu_do_activate hackbench_64-4695 [001] dL.4. 328.224585: function: __srcu_check_read_flavor <-- ttwu_do_activate hackbench_64-4695 [001] dL.4. 328.224585: function: _raw_spin_unlock <-- try_to_wake_up hackbench_64-4695 [001] dL.4. 328.224585: function: do_raw_spin_unlock <-- _raw_spin_unlock hackbench_64-4695 [001] dL.4. 328.224586: function: preempt_count_sub <-- _raw_spin_unlock hackbench_64-4695 [001] dL.3. 328.224586: function: _raw_spin_unlock_irqrestore <-- try_to_wake_up hackbench_64-4695 [001] dL.3. 328.224586: function: do_raw_spin_unlock <-- _raw_spin_unlock_irqrestore hackbench_64-4695 [001] dL.3. 328.224586: function: preempt_count_sub <-- _raw_spin_unlock_irqrestore hackbench_64-4695 [001] dL.2. 328.224586: function: preempt_count_sub <-- try_to_wake_up hackbench_64-4695 [001] dL.1. 328.224587: function: autoremove_wake_function <-- __wake_up_common hackbench_64-4695 [001] dL.1. 328.224587: function: default_wake_function <-- autoremove_wake_function hackbench_64-4695 [001] dL.1. 328.224587: function: try_to_wake_up <-- autoremove_wake_function hackbench_64-4695 [001] dL.1. 328.224588: function: preempt_count_add <-- try_to_wake_up hackbench_64-4695 [001] dL.2. 328.224588: function: _raw_spin_lock_irqsave <-- try_to_wake_up hackbench_64-4695 [001] dL.2. 328.224588: function: preempt_count_add <-- _raw_spin_lock_irqsave hackbench_64-4695 [001] dL.3. 328.224588: function: do_raw_spin_lock <-- _raw_spin_lock_irqsave hackbench_64-4695 [001] dL.3. 328.224589: function: select_task_rq_fair <-- try_to_wake_up hackbench_64-4695 [001] dL.3. 328.224589: function: __rcu_read_lock <-- select_task_rq_fair hackbench_64-4695 [001] dL.3. 328.224589: function: __rcu_read_unlock <-- select_task_rq_fair hackbench_64-4695 [001] dL.3. 328.224590: function: ttwu_queue_wakelist <-- try_to_wake_up hackbench_64-4695 [001] dL.3. 328.224590: function: __smp_call_single_queue <-- ttwu_queue_wakelist ^This goes on for a very long time, and the next tick is hit which causes a full
NEED_RESCHEDto happen:hackbench_64-4695 [001] dLh1. 328.229455: function: sched_tick <-- update_process_times hackbench_64-4695 [001] dLh1. 328.229456: function: arch_scale_freq_tick <-- sched_tick hackbench_64-4695 [001] dLh1. 328.229456: function: preempt_count_add <-- sched_tick hackbench_64-4695 [001] dLh2. 328.229457: function: _raw_spin_lock_nested <-- sched_tick hackbench_64-4695 [001] dLh2. 328.229457: function: preempt_count_add <-- _raw_spin_lock_nested hackbench_64-4695 [001] dLh3. 328.229458: function: do_raw_spin_lock <-- sched_tick hackbench_64-4695 [001] dLh3. 328.229470: function: preempt_count_sub <-- sched_tick hackbench_64-4695 [001] dLh2. 328.229470: function: update_rq_clock <-- sched_tick hackbench_64-4695 [001] dLh2. 328.229471: function: arch_scale_cpu_capacity <-- update_rq_clock hackbench_64-4695 [001] dLh2. 328.229472: function: __resched_curr <-- sched_tick hackbench_64-4695 [001] dNh2. 328.229472: function: task_tick_fair <-- sched_tick hackbench_64-4695 [001] dNh2. 328.229473: function: update_curr <-- task_tick_fair hackbench_64-4695 [001] dNh2. 328.229473: function: update_se <-- update_curr hackbench_64-4695 [001] dNh2. 328.229474: function: cpuacct_charge <-- update_se hackbench_64-4695 [001] dNh2. 328.229474: function: __cgroup_account_cputime <-- update_se hackbench_64-4695 [001] dNh2. 328.229475: function: preempt_count_add <-- __cgroup_account_cputime hackbench_64-4695 [001] dNh3. 328.229476: function: css_rstat_updated <-- __cgroup_account_cputime hackbench_64-4695 [001] dNh3. 328.229476: function: preempt_count_sub <-- __cgroup_account_cputime hackbench_64-4695 [001] dNh2. 328.229477: function: dl_server_update <-- update_curr hackbench_64-4695 [001] dNh2. 328.229477: function: update_curr_dl_se <-- update_curr hackbench_64-4695 [001] dNh2. 328.229478: function: resched_curr_lazy <-- update_curr hackbench_64-4695 [001] dNh2. 328.229478: function: __resched_curr <-- update_currSo this task finally gets scheduled out (while holding RCU read lock):
static void
unix_write_space(struct sock *sk){ struct socket_wq *wq; rcu_read_lock(); if (unix_writable(sk, READ_ONCE(sk->sk_state))) { wq = rcu_dereference(sk->sk_wq); if (skwq_has_sleeper(wq)) wake_up_interruptible_sync_poll(&wq->wait, EPOLLOUT | EPOLLWRNORM | EPOLLWRBAND); sk_wake_async_rcu(sk, SOCK_WAKE_SPACE, POLL_OUT); } rcu_read_unlock(); }And because the system is very busy, it doesn't get scheduled in for a long time, and RCU complains about a stall:
[ 357.679707] rcu: INFO: rcu_preempt detected stalls on CPUs/tasks: [ 357.810980] rcu: Tasks blocked on level-0 rcu_node (CPUs 0-3): P4695/1:b..l [ 357.813601] rcu: (detected by 2, t=6535 jiffies, g=4125, q=100 ncpus=4) [ 357.816256] task:hackbench_64 state:R running task stack:0 pid:4695 tgid:4695 ppid:4690 task_flags:0x400000 flags:0x00080000 [ 357.821176] Call Trace: [ 357.822382] <TASK> [ 357.823474] __schedule+0x4ac/0x12f0 [ 357.825104] preempt_schedule_common+0x26/0xe0 [ 357.826988] ? preempt_schedule_thunk+0x16/0x30 [ 357.828930] preempt_schedule_thunk+0x16/0x30 [ 357.830788] ? _raw_spin_unlock_irqrestore+0x39/0x70 [ 357.832901] _raw_spin_unlock_irqrestore+0x5d/0x70 [ 357.834884] sock_def_readable+0x9c/0x2b0 [ 357.836633] unix_stream_sendmsg+0x2d7/0x710 [ 357.838423] sock_write_iter+0x185/0x190 [ 357.840084] vfs_write+0x457/0x5b0 [ 357.841568] ksys_write+0xc8/0xf0 [ 357.842914] do_syscall_64+0x117/0x1660 [ 357.844413] ? irqentry_exit+0xd9/0x690
Quoted 5 lines
Now I guess the question is, how do we fix this?
Before
LAZY_PREEMPT, anrcu_read_lock()would never schedule out. Now, long loops under RCU can schedule out, which can be flagged as an RCU stall. Should we not schedule out whenrcu_read_lock()is held?
You know, with LAZY_PREEMPT, you are supposed to get TREE_RCU, but not PREEMPT_RCU. And that would avoid scheduling out when rcu_read_lock() is held.
Ah, but are you building with PREEMPT_DYNAMIC? That would do it.
Thanx, Paul
Quoted 5 lines · On Sat, 18 Apr 2026 16:01:49 -0700 "Paul E. McKenney" <[email protected]>…
You know, with
LAZY_PREEMPT, you are supposed to getTREE_RCU, but notPREEMPT_RCU. And that would avoid scheduling out whenrcu_read_lock()is held.Ah, but are you building with
PREEMPT_DYNAMIC? That would do it.
Yes, PREEMPT_DYNAMIC is set. I guess I can test it without it set and see if the problem goes away. If that's the case, I'll just disable that for this one test that keeps failing due to that warning.
-- Steve
Quoted 3 lines · On Sat, 18 Apr 2026 19:26:25 -0400 Steven Rostedt <[email protected]> wrote:
Yes,
PREEMPT_DYNAMICis set. I guess I can test it without it set and see if the problem goes away. If that's the case, I'll just disable that for this one test that keeps failing due to that warning.
This looks to be my solution. I usually can trigger the issue with 2 or 3 runs of tracing hackbench. I just finished running it 10 times and it hasn't triggered. I'll let it run a few more times but I'm going to disable PREEMPT_DYNAMIC in my tests, and hopefully it doesn't fail due to this anymore.
-- Steve