Repository navigation
Conversation
rfuchs
reviewed
Nov 12, 2026
| } | ||
|
|
||
| // streams that are each other's sinks would retry against each other | ||
| static mutex_t kernelize_lock = MUTEX_STATIC_INIT; |
Member
There was a problem hiding this comment.
Global mutex for data that is not global is a no-no
Author
There was a problem hiding this comment.
Moved it into the call: kernelize() is the only place that holds the locks of two streams at once, and streams that are each other's sinks are always in one call (connect, inject and mesh merge the calls), so call->kernelize_lock serializes exactly those, and other calls no longer wait.
…ut limit kernelize_one() takes each sink's lock with a trylock, and kernelize() starts over at once when one is busy. kernelize() is the only place that holds the locks of two streams at once, and streams that are each other's sinks hold their own lock while they try the other's, so two kernelize() of one call start over against each other. After a change of subscriptions all of them are kernelized on their next packet, at the same moment. With about eight or more such streams the restarts do not end: the threads spin with the call's master lock held, the streams' sockets are no longer read, the log fills with "Kernelizing media stream" lines, and commands for the call are not answered. A lock in the call, taken ahead of the stream's own lock, runs one kernelize() of the call at a time. A sink's trylock then only meets a holder of that single lock, which waits for nothing while it holds it, so the restart ends. Streams that are each other's sinks are in one call, as connect, inject and mesh merge their calls, and kernelize() of other calls does not wait. A stream with more than RTPE_MAX_FORWARD_DESTINATIONS outputs, two per sink, was pushed to the kernel anyway: the module answered EINVAL, each output ENOENT, and the stream was still marked kernelized. It now takes the no_kernel path. The limit itself is left as it is. It came with 01a10c0, where it sized the array of outputs in struct rtpengine_list_entry; that struct is gone, and until now the module's check was its only use.
nickakt
force-pushed
the
fix/kernelize-livelock
branch
from
November 12, 2026 13:53
0dd5acd to
5c1a48b
Compare
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.
kernelize_one()takes each sink's lock with a trylock, andkernelize()starts over at once when one is busy.kernelize()is the only place that holds the locks of two streams at once, and streams that are each other's sinks hold their own lock while they try the other's, so twokernelize()of one call start over against each other. After a change of subscriptions all of them are kernelized on their next packet, at the same moment. With about eight or more such streams the restarts do not end: the threads spin with the call's master lock held, the streams' sockets are no longer read, the log fills with "Kernelizing media stream" lines, and commands for the call are not answered.A lock in the call, taken ahead of the stream's own lock, runs one
kernelize()of the call at a time. A sink's trylock then only meets a holder of that single lock, which waits for nothing while it holds it, so the restart ends. Streams that are each other's sinks are in one call, as connect, inject and mesh merge their calls, andkernelize()of other calls does not wait.A stream with more than
RTPE_MAX_FORWARD_DESTINATIONSoutputs, two per sink, was pushed to the kernel anyway: the module answered EINVAL, each output ENOENT, and the stream was still marked kernelized. It now takes theno_kernelpath.The limit itself is left as it is. It came with 01a10c0, where it sized the array of outputs in
struct rtpengine_list_entry; that struct is gone, and until now the module's check was its only use.