Commit d75abd0
mm/memory-failure: use raw_spinlock_t in struct memory_failure_cpu
The memory_failure_cpu structure is a per-cpu structure. Access to its
content requires the use of get_cpu_var() to lock in the current CPU and
disable preemption. The use of a regular spinlock_t for locking purpose
is fine for a non-RT kernel.
Since the integration of RT spinlock support into the v5.15 kernel, a
spinlock_t in a RT kernel becomes a sleeping lock and taking a sleeping
lock in a preemption disabled context is illegal resulting in the
following kind of warning.
[12135.732244] BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:48
[12135.732248] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 270076, name: kworker/0:0
[12135.732252] preempt_count: 1, expected: 0
[12135.732255] RCU nest depth: 2, expected: 2
:
[12135.732420] Hardware name: Dell Inc. PowerEdge R640/0HG0J8, BIOS 2.10.2 02/24/2021
[12135.732423] Workqueue: kacpi_notify acpi_os_execute_deferred
[12135.732433] Call Trace:
[12135.732436] <TASK>
[12135.732450] dump_stack_lvl+0x57/0x81
[12135.732461] __might_resched.cold+0xf4/0x12f
[12135.732479] rt_spin_lock+0x4c/0x100
[12135.732491] memory_failure_queue+0x40/0xe0
[12135.732503] ghes_do_memory_failure+0x53/0x390
[12135.732516] ghes_do_proc.constprop.0+0x229/0x3e0
[12135.732575] ghes_proc+0xf9/0x1a0
[12135.732591] ghes_notify_hed+0x6a/0x150
[12135.732602] notifier_call_chain+0x43/0xb0
[12135.732626] blocking_notifier_call_chain+0x43/0x60
[12135.732637] acpi_ev_notify_dispatch+0x47/0x70
[12135.732648] acpi_os_execute_deferred+0x13/0x20
[12135.732654] process_one_work+0x41f/0x500
[12135.732695] worker_thread+0x192/0x360
[12135.732715] kthread+0x111/0x140
[12135.732733] ret_from_fork+0x29/0x50
[12135.732779] </TASK>
Fix it by using a raw_spinlock_t for locking instead.
Also move the pr_err() out of the lock critical section and after
put_cpu_ptr() to avoid indeterminate latency and the possibility of sleep
with this call.
[[email protected]: don't hold percpu ref across pr_err(), per Miaohe]
Link: https://lkml.kernel.org/r/[email protected]
Link: https://lkml.kernel.org/r/[email protected]
Fixes: 0f383b6 ("locking/spinlock: Provide RT variant")
Signed-off-by: Waiman Long <[email protected]>
Acked-by: Miaohe Lin <[email protected]>
Cc: "Huang, Ying" <[email protected]>
Cc: Juri Lelli <[email protected]>
Cc: Len Brown <[email protected]>
Cc: Naoya Horiguchi <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>1 parent 9d85731 commit d75abd0
1 file changed
+11
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2417 | 2417 | | |
2418 | 2418 | | |
2419 | 2419 | | |
2420 | | - | |
| 2420 | + | |
2421 | 2421 | | |
2422 | 2422 | | |
2423 | 2423 | | |
| |||
2443 | 2443 | | |
2444 | 2444 | | |
2445 | 2445 | | |
| 2446 | + | |
2446 | 2447 | | |
2447 | 2448 | | |
2448 | 2449 | | |
2449 | 2450 | | |
2450 | 2451 | | |
2451 | 2452 | | |
2452 | | - | |
2453 | | - | |
| 2453 | + | |
| 2454 | + | |
| 2455 | + | |
2454 | 2456 | | |
2455 | | - | |
| 2457 | + | |
| 2458 | + | |
| 2459 | + | |
2456 | 2460 | | |
2457 | 2461 | | |
2458 | | - | |
2459 | | - | |
2460 | 2462 | | |
2461 | 2463 | | |
2462 | 2464 | | |
| |||
2469 | 2471 | | |
2470 | 2472 | | |
2471 | 2473 | | |
2472 | | - | |
| 2474 | + | |
2473 | 2475 | | |
2474 | | - | |
| 2476 | + | |
2475 | 2477 | | |
2476 | 2478 | | |
2477 | 2479 | | |
| |||
2501 | 2503 | | |
2502 | 2504 | | |
2503 | 2505 | | |
2504 | | - | |
| 2506 | + | |
2505 | 2507 | | |
2506 | 2508 | | |
2507 | 2509 | | |
| |||
0 commit comments