Repository navigation
multikernel: take the pending message lock as a raw spinlock - #55
Merged
congwang-mk merged 1 commit intoNov 24, 2026
Merged
Conversation
mk_msg_pending_complete() runs from the multikernel IPI handler, in hard
interrupt context and under the raw mk_drain_lock. It takes
mk_pending_msgs_lock, a spinlock_t, which becomes a sleeping lock on
PREEMPT_RT. With PROVE_RAW_LOCK_NESTING, the host reports this on the
first halt ACK of every spawn:
[ BUG: Invalid wait context ]
swapper/0/0 is trying to lock:
(mk_pending_msgs_lock){....}-{3:3}, at: mk_msg_pending_complete+0x34/0x8c
context-{2:2}
1 lock held by swapper/0/0:
#0: (mk_drain_lock){-...}-{2:2}, at: multikernel_interrupt_handler
Call Trace:
mk_msg_pending_complete+0x34/0x8c
mk_system_msg_handler+0xcc/0x170
mk_message_type_ipi_callback+0x50/0xa0
mk_ipi_drain_ring+0xca/0x124
multikernel_interrupt_handler+0xb0/0xf0
The lock only guards a list add, a list walk that calls complete(), and
a list delete. The allocation and the kfree() are already outside it,
and complete() is safe under a raw lock, so make it a raw spinlock.
Fixes: 4f676d2 ("multikernel: Add messaging layer for inter-kernel communication")
Signed-off-by: Utkarsh Maurya <projects.utkarshMaurya@gmail.com>
This was referenced Nov 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
mk_msg_pending_complete()runs from the multikernel IPI handler in hard interrupt context, under the rawmk_drain_lock, and takesmk_pending_msgs_lock, aspinlock_t(a sleeping lock on PREEMPT_RT). WithPROVE_RAW_LOCK_NESTINGthe host reports it on the first halt ACK of a spawn (RISC-V, #49 head b4be1bf):The lock only guards a list add, a walk that calls
complete(), and a list delete; the allocation andkfree()are already outside it, andcomplete()is safe under a raw lock. Make it a raw spinlock.Tested: RISC-V QEMU virt (aia=aplic-imsic, OpenSBI v1.8.1), #49 head b4be1bf with #55–#59 applied: spawn, graceful and forced halt, re-spawn, 20 start/halt rounds, hart and memory hotplug, poweroff/reboot inside the spawn, 28 spawns, no lockdep report on the host. Builds on current master (fca2f47): x86_64 clang W=1 with no new warnings, also with PCI=n and with MULTIKERNEL=n; checkpatch --strict clean.