[fix]: enforce HwQueue preemption capability - #29
Open
guohuan78 wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR makes the HAL’s HwQueue::GetMaxSupportedLevel() contract effective by rejecting XQueue creation and dynamic preemption-level changes that exceed a hardware queue’s declared capability, and adds a core unit test to validate Level-2 vs Level-3 behavior in a platform-independent way.
Changes:
- Enforce
GetMaxSupportedLevel()duringXQueueCreateto reject unsupported preemption levels. - Enforce the same capability check in
XQueueSetPreemptLevelfor dynamic level changes. - Add a new Level-2 fake-HwQueue test and wire it into the preempt module’s test build.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| preempt/src/xqueue/xqueue.cpp | Adds capability validation for queue creation and dynamic preemption-level changes. |
| preempt/test/preempt_level_capability_test.cpp | New platform-independent test covering Level-3 rejection on a Level-2 HAL and suspend/resume behavior. |
| preempt/test/CMakeLists.txt | Defines the new test executable, compile options, and registers it via add_test. |
| preempt/CMakeLists.txt | Adds conditional inclusion of the new test subdirectory under BUILD_TEST. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+27
to
+33
| if (level > hwq_shptr->GetMaxSupportedLevel()) { | ||
| XWARN("preempt level %d is not supported by HwQueue 0x" FMT_64X | ||
| ", max supported level is %d", | ||
| static_cast<int>(level), hwq_h, | ||
| hwq_shptr->GetMaxSupportedLevel()); | ||
| return kXSchedErrorNotSupported; | ||
| } |
Comment on lines
+296
to
+301
| const auto hwq_shptr = xq_shptr->GetHwQueue(); | ||
| if (hwq_shptr == nullptr || level > hwq_shptr->GetMaxSupportedLevel()) { | ||
| XWARN("preempt level %d is not supported by XQueue 0x" FMT_64X, | ||
| level, xq); | ||
| return kXSchedErrorNotSupported; | ||
| } |
Comment on lines
+44
to
+46
| if(BUILD_TEST) | ||
| add_subdirectory(test) | ||
| endif() |
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.
Summary
HwQueue::GetMaxSupportedLevel()when creating an XQueue;Motivation
GetMaxSupportedLevel()already expresses each HAL queue's preemption capability, but the core runtime previously treated it as advisory: callers could create or upgrade an XQueue to a level the HAL did not implement. A hardware queue that supports deactivation but not command interruption therefore had no reliable way to reject Level-3.This change makes the existing HAL contract effective without adding any platform-specific behavior.
Scope
This PR contains only core preemption capability validation and its unit test. It does not add LoongGPU code, OpenCL wrappers, scheduler policy, benchmarks, or application artifacts.
Validation
-Wall -Wextra -Werror;git diff --checkpasses.Validation run: https://github.com/guohuan78/xsched/actions/runs/30080294997