perf(agnocast_kmod): optimize exit worker and filter non-Agnocast PIDs#1083
Draft
k1832 wants to merge 3 commits intotier4:mainfrom
Draft
perf(agnocast_kmod): optimize exit worker and filter non-Agnocast PIDs#1083k1832 wants to merge 3 commits intotier4:mainfrom
k1832 wants to merge 3 commits intotier4:mainfrom
Conversation
The exit worker thread previously dequeued exactly one PID per wake-up cycle. When N processes exit simultaneously, this caused N separate sleep/wake context switches. Change to an inner drain loop that processes all queued PIDs before going back to sleep. Signed-off-by: Keita Morisaki <keita.morisaki@tier4.jp>
The kprobe on do_exit fires for every process exit system-wide. Previously, every exit — even unrelated processes — triggered the full enqueue/wake/dequeue/rwsem pipeline before being discarded in process_exit_cleanup. Add an RCU-protected hash lookup in the kprobe handler to skip non-Agnocast PIDs immediately (~50-100 ns) instead of going through the full pipeline (~6-14 us). This eliminates unnecessary rwsem acquisitions that contend with the publish/receive hot path. Changes: - Add rcu_head to process_info for deferred freeing - Use hash_add_rcu/hash_del_rcu/kfree_rcu for proc_info_htable - Use rcu_read_lock + hash_for_each_possible_rcu in kprobe handler - synchronize_rcu in remove_all_process_info at module exit Signed-off-by: Keita Morisaki <keita.morisaki@tier4.jp>
…apping Replace inline (EXIT_QUEUE_SIZE - 1) with a named EXIT_QUEUE_MASK constant. Remove the now-unnecessary comment about EXIT_QUEUE_SIZE being a power of two, since the mask definition makes this self-evident. Signed-off-by: Keita Morisaki <keita.morisaki@tier4.jp>
Member
|
Great |
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.
Description
Three improvements to the process exit handling path:
Drain loop: The exit worker thread previously dequeued exactly one PID per wake-up cycle. When N processes exit simultaneously, this caused N separate sleep/wake context switches. Now all queued PIDs are drained in a single wake-up before going back to sleep.
RCU-based PID filtering: The kprobe on
do_exitfires for every process exit system-wide. Previously, every exit triggered the full enqueue → wake → dequeue → rwsem pipeline before being discarded inprocess_exit_cleanup. Now an RCU-protected hash lookup in the kprobe handler skips non-Agnocast PIDs immediately (~50-100 ns) instead of going through the full pipeline (~6-14 us). This eliminates unnecessary rwsem acquisitions that contend with the publish/receive hot path.EXIT_QUEUE_MASK: Replace inline
(EXIT_QUEUE_SIZE - 1)with a named constant.Related links
How was this PR tested?
bash scripts/e2e_test_1to1(required)bash scripts/e2e_test_2to2(required)Notes for reviewers
rcu_headtoprocess_infoand useshash_add_rcu/hash_del_rcu/kfree_rcuforproc_info_htable. This is a textbook RCU use case: a read-mostly hash table where writes are rare (process add/remove) and reads happen on every system-wide process exit.find_process_infoandprocess_exit_cleanupstill use non-RCU hash iteration underglobal_htables_rwsem, which provides sufficient synchronization. Only the kprobe handler (which cannot sleep) uses RCU.Version Update Label (Required)
need-patch-update