-
Notifications
You must be signed in to change notification settings - Fork 6
feat(sched): add Partitioned EDF scheduler #686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ytakano
wants to merge
22
commits into
tier4:main
Choose a base branch
from
ytakano:partitioned_edf
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
8c0cda5
feat(igc): add on-demand netdump observability
ytakano b4176f8
Address netdump review feedback
ytakano caf9414
feat(sched): add partitioned_gedf.rs
ytakano e26d4a5
fix bugs
ytakano 41a20f0
fix bugs
ytakano 59ec1bd
fix bugs
ytakano 58f7942
fixed
ytakano 146c359
fix
ytakano 576516c
use const fn
ytakano 11690b7
add a test for partitioned EDF
ytakano 225c498
update docs
ytakano 17b10dc
fmt
ytakano 91abfa1
Revert "Address netdump review feedback"
ytakano 830e513
Revert "feat(igc): add on-demand netdump observability"
ytakano 9875069
reflect the review
ytakano 39321f8
fix
ytakano 848a478
reflect the review
ytakano c3aa2ae
docs: add doc comments to get_task_running and partitioned_core
ytakano a5c6aca
fix(sched): fix counter double-increment and panic counter mismatch f…
ytakano 08b9b2b
refactor(sched): manage NUM_PARTITIONED_TASKS_IN_QUEUE via RAII Parti…
ytakano c64e225
refactor(sched): use Option<T> + take() in PartitionedTask<T>
ytakano 4965067
refactor(partitioned_edf): remove unwrap from PartitionedTask<T>
ytakano File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| [package] | ||
| name = "test_partitioned_edf" | ||
| version = "0.1.0" | ||
| edition = "2021" | ||
|
|
||
| [dependencies] | ||
| log = "0.4" | ||
|
|
||
| [dependencies.awkernel_async_lib] | ||
| path = "../../../awkernel_async_lib" | ||
| default-features = false | ||
|
|
||
| [dependencies.awkernel_lib] | ||
| path = "../../../awkernel_lib" | ||
| default-features = false |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| #![no_std] | ||
|
|
||
| extern crate alloc; | ||
| use alloc::string::String; | ||
| use alloc::string::ToString; | ||
|
|
||
| use awkernel_async_lib::sleep; | ||
| use awkernel_async_lib::{scheduler::SchedulerType, spawn}; | ||
| use awkernel_lib::{ | ||
| cpu::{cpu_id, num_cpu}, | ||
| delay::{uptime, wait_microsec}, | ||
| }; | ||
| use core::time::Duration; | ||
|
|
||
| pub async fn run() { | ||
| wait_microsec(2_000_000); | ||
|
|
||
| if num_cpu() < 2 { | ||
| log::warn!("test_partitioned_edf: requires at least 2 CPUs, skipping"); | ||
| return; | ||
| } | ||
|
|
||
| test_core_pinning().await; | ||
| test_edf_preemption().await; | ||
| test_multi_core().await; | ||
|
|
||
| wait_microsec(100_000_000); | ||
| } | ||
|
|
||
| /// Test 1: Verify tasks are pinned to their assigned cores. | ||
| /// Spawns one periodic task per worker core (1..num_cpu()). | ||
| /// Each task checks cpu_id() matches the assigned core. | ||
| async fn test_core_pinning() { | ||
| log::info!("=== test_core_pinning start ==="); | ||
| for core in 1..num_cpu() { | ||
| let core_u16 = core as u16; | ||
| spawn( | ||
| alloc::format!("pinning_core{core}").into(), | ||
| async move { | ||
| for _ in 0..3 { | ||
| let actual = cpu_id(); | ||
| if actual == core { | ||
| log::info!("core_pinning: task on core {core} ran on cpu {actual} [OK]"); | ||
| } else { | ||
| log::error!("core_pinning: task on core {core} ran on cpu {actual} [FAIL]"); | ||
| } | ||
| wait_microsec(100_000); | ||
| sleep(Duration::from_millis(200)).await; | ||
| awkernel_async_lib::r#yield().await; | ||
| } | ||
| }, | ||
| SchedulerType::PartitionedEDF(1_000_000, core_u16), | ||
| ) | ||
| .await; | ||
| } | ||
| } | ||
|
|
||
| /// Test 2: Verify EDF preemption on a single core. | ||
| /// heavy (deadline=9900ms) is preempted by light (deadline=990ms) on core 1. | ||
| async fn test_edf_preemption() { | ||
| log::info!("=== test_edf_preemption start ==="); | ||
| spawn_periodic_task("heavy".to_string(), 9_600_000, 10_000_000, 9_900_000, 1).await; | ||
| spawn_periodic_task("light".to_string(), 900_000, 1_000_000, 990_000, 1).await; | ||
| } | ||
|
|
||
| /// Test 3: Verify core independence when num_cpu >= 3. | ||
| /// Tasks on core 1 and core 2 run in parallel without interfering. | ||
| async fn test_multi_core() { | ||
| if num_cpu() < 3 { | ||
| log::info!("test_multi_core: skipped (num_cpu < 3)"); | ||
| return; | ||
| } | ||
| log::info!("=== test_multi_core start ==="); | ||
| spawn_periodic_task("task_core1".to_string(), 4_000_000, 5_000_000, 4_900_000, 1).await; | ||
| spawn_periodic_task("task_core2".to_string(), 4_000_000, 5_000_000, 4_900_000, 2).await; | ||
| } | ||
|
|
||
| /// Spawn a pseudo-periodic task pinned to `core`. | ||
| async fn spawn_periodic_task( | ||
| task_name: String, | ||
| exe_time: u64, | ||
| period: u64, | ||
| relative_deadline: u64, | ||
| core: u16, | ||
| ) { | ||
| let task_name_clone = task_name.clone(); | ||
| spawn( | ||
| task_name.into(), | ||
| async move { | ||
| loop { | ||
| let start_time = uptime(); | ||
| wait_microsec(exe_time); | ||
| let end_time = uptime(); | ||
| log::debug!( | ||
| "{}: cpu={}, start={}, end={}", | ||
| task_name_clone, | ||
| cpu_id(), | ||
| start_time, | ||
| end_time, | ||
| ); | ||
| sleep(Duration::from_micros(period - exe_time)).await; | ||
| awkernel_async_lib::r#yield().await; | ||
| } | ||
| }, | ||
| SchedulerType::PartitionedEDF(relative_deadline, core), | ||
| ) | ||
| .await; | ||
| } |
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new public method has no doc comment. The semantics of
Some(n)(the assigned core index, expected to be in1..num_cpu()) and the fact that all non-PartitionedEDFvariants returnNoneshould be documented for consumers.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. A doc comment has been added: