Repository navigation
Protect homa_tx_pool_core with a local lock - #141
Open
Stuartwastaken wants to merge 1 commit into
Open
Stuartwastaken wants to merge 1 commit into
Stuartwastaken wants to merge 1 commit into
Conversation
* homa_tx_pool_alloc relied on local_bh_disable to keep other tasks away from the per-core page. On PREEMPT_RT that only disables migration, so two sendmsg calls on one core could hand out the same bytes or put the cached page twice.
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.
On PREEMPT_RT, local_bh_disable() no longer keeps other tasks off the core: unless CONFIG_PREEMPT_RT_NEEDS_BH_LOCK is set, it only disables migration (kernel/softirq.c). So the per-core page state that homa_tx_pool_alloc uses isn't protected there, and two sendmsg calls on one core can interleave in __homa_tx_pool_alloc_frag. Both can read the same tx_core->allocated and get overlapping fragments, so one message goes out with the other's data, or both can put the same cached page when replacing it.
This adds a local_lock_t to homa_tx_pool_core and takes it with local_lock_nested_bh inside the BH-disabled section, the same pattern as napi_alloc_cache in net/core/skbuff.c. Outside RT it compiles to a lockdep annotation. The new unit-test mocks check that the lock is only taken with BHs disabled and is released by the end of each test, so the existing homa_tx_pool tests cover both exits of homa_tx_pool_alloc. All unit tests and the smoke tests pass. I don't have an RT kernel, so this hasn't been run under PREEMPT_RT.