xen: Fix dispatching of event handlers on multi-CPU platforms#2172
Open
francescolavra wants to merge 5 commits into
Open
xen: Fix dispatching of event handlers on multi-CPU platforms#2172francescolavra wants to merge 5 commits into
francescolavra wants to merge 5 commits into
Conversation
added 5 commits
July 6, 2026 11:59
This avoids a separate memory allocation for the vector struct. As part of this change, add the vector_init() and vector_deinit() generic functions to the runtime library.
Remove fields that are only used during initialization. This will allow avoiding early allocation of the struct xen_platform_info when the static structure is replaced with a dynamically allocated one in a future commit.
…ed one This change, which decreases memory requirements on non-Xen platforms, is being made in preparation for a commit that will add a new (somewhat large) field (`vcpu_evtchn_enable`) to this struct.
The Xen interrupt handler is invoking the handlers of all pending events whose port numbers belong to the same `evtchn_pending` array element as the element for which there is a pending event for the current vCPU. This means that the handler for an event bound to a given vCPU can potentially be executed on a different vCPU. This creates issues in event handlers (such as `xennet_event_handler()` that assume they are always run sequentially and cannot run in parallel on different vCPUs. Fix the Xen interrupt handler so that it only invokes handlers for events bound to the current vCPU. The issue with seemingly spurious interrupts mentioned in a comment in the interrupt handler function cannot be reproduced (tested on t2.nano, t2.medium and t2.2xlarge AWS instances), thus the `evtchn_mask` array is no longer used. In addition, allow device drivers to request that their event handler is bound to a specific vCPU (via the newly defined xen_bind_evtchn() function); this allows spreading the interrupt load among different vCPUs.
Initialize the `retval` variable to fix "error: variable 'retval' is uninitialized when passed as a const pointer argument here [-Werror,-Wuninitialized-const-pointer]" when compiling with clang on a Mac host.
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.
The Xen interrupt handler is invoking the handlers of all pending events whose port numbers belong to the same
evtchn_pendingarray element as the element for which there is a pending event for the current vCPU. This means that the handler for an event bound to a given vCPU can potentially be executed on a different vCPU. This creates issues in event handlers (such asxennet_event_handler()that assume they are always run sequentially and cannot run in parallel on different vCPUs.This change set fixes the Xen interrupt handler so that it only invokes handlers for events bound to the current vCPU.
In addition, Xen device drivers can now request that their event handler is bound to a specific vCPU (via the newly defined
xen_bind_evtchn()function) instead of the default vCPU 0; this allows spreading the interrupt load for different devices among different vCPUs.