Skip to content

feat(sched): merge GEDF into ClusteredEDF and rename it to EDF - #787

Merged
romancardenas merged 2 commits into
mainfrom
feat/merge-gedf-into-edf
Nov 16, 2026
Merged

romancardenas merged 2 commits into
mainfrom
feat/merge-gedf-into-edf

Conversation

@atsushi421

@atsushi421 atsushi421 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR merges GEDF into ClusteredEDF and renames the merged scheduler to EDF. GEDF is ClusteredEDF with every worker core in the CPU set, so one scheduler covers both.

API changes:

  • This PR removes SchedulerType::GEDF(d). Use SchedulerType::EDF(d, CpuSet::all()) instead. spawn removes CPU 0 and out-of-range cores from the set without a warning. CPU 0 runs no tasks, so GEDF tasks never ran on it.
  • SchedulerType::ClusteredEDF(d, set) becomes SchedulerType::EDF(d, set). A one-core set gives partitioned EDF.
  • This PR removes the public module awkernel_async_lib::scheduler::gedf. calculate_and_update_dag_deadline moves to dag.rs as pub(crate), because the EDF scheduler and the DAG unit tests call it.
  • The userland feature test_edf replaces test_gedf and test_clustered_edf.

Other changes:

  • scheduler/clustered_edf.rs becomes scheduler/edf.rs, and ClusteredEDFScheduler becomes EDFScheduler.
  • This PR removes the NOTE in invoke_preemption that says the scheduler requests preemption regardless of the number of idle CPUs. The NOTE came from GEDF. If a core in the task's set is idle, the EDF scheduler does not preempt.
  • test_clustered_edf becomes test_edf. This PR removes test_gedf, because its expected result (light_1 preempts heavy_1) depends on the GEDF policy above. test_dag, test_dvfs, and test_multi_prioritized_scheduler use SchedulerType::EDF.
  • test_edf adds test_global_edf. It fills every worker core with CpuSet::all() tasks and checks that a task with an earlier deadline preempts one of them and that no task runs on CPU 0.
  • After the EDF scheduler enqueues a task, it wakes the primary CPU. Re-wakes from do_preemption and run_main do not go through ArcWake::wake, so before this change an idle worker in the set could stay asleep until the next loop of the primary CPU.
  • Dag::get_or_release_job becomes private, because all its callers are in dag.rs.
  • The scheduler chapter of the mdbook describes the EDF scheduler. This PR does not rebuild the generated docs/.

Behavior changes for former GEDF tasks:

  • Former GEDF tasks and former ClusteredEDF tasks have the same scheduler priority, and the EDF scheduler orders them by absolute deadline. Before this PR, every ClusteredEDF task had priority over every GEDF task. The order of PrioritizedFIFO, PrioritizedRR, and Panicked does not change.
  • If a worker core is idle, a task whose set holds every worker core does not preempt. In the same case, GEDF preempted a running task.
  • While such a task is in the queue, wake_workers() wakes every sleeping worker core. GEDF woke one sleeping core for each queued task. The extra cores find no task and sleep again. ClusteredEDF tasks with a large set already have this cost.
  • Tasks with the same deadline and wake time run in FIFO order. The BinaryHeap of GEDF did not define this order.

Related links

How was this PR tested?

  • scripts/ci.sh passes on my machine.
  • On QEMU (aarch64_virt, 4 CPUs), test_edf logs no [FAIL], and test_global_edf logs [OK]. If the deadline of the urgent task is longer than the deadline of the fillers, test_global_edf logs [FAIL].
  • On QEMU, every node of test_dag runs, and every task of test_multi_prioritized_scheduler starts and finishes, with no panic.

Notes for reviewers

Follow-up PRs stack on this PR in the order #788, #792, #789, #790. They change the idle-core rule of invoke_preemption, fix the underflow of NUM_TASK_IN_QUEUE, change the wake budget of global EDF tasks, and remove the clustered abstraction.

This PR conflicts with #784 and #738, which change scheduler/gedf.rs and SchedulerType::GEDF.

If your local Cargo.lock has awkernel_sync from before tier4/awkernel_sync#1, test_dag on QEMU can hang. Run cargo update -p awkernel_sync before you test.

GEDF is ClusteredEDF with every worker core in the CPU set, so one EDF
scheduler covers both. Remove GEDFScheduler and SchedulerType::GEDF, and
rename ClusteredEDF to EDF. SchedulerType::EDF(d, CpuSet::all()) gives
global EDF, and a one-core CPU set gives partitioned EDF.

- Move calculate_and_update_dag_deadline from gedf.rs to dag.rs as
  pub(crate), because the EDF scheduler and the DAG tests use it.
- Remove the NOTE in invoke_preemption that described the GEDF policy.
  The EDF scheduler does not preempt when a core in the set is idle.
- Rename test_clustered_edf to test_edf and remove test_gedf. Move
  test_dag, test_dvfs, and test_multi_prioritized_scheduler to
  SchedulerType::EDF.

Signed-off-by: atsushi421 <[email protected]>
- Add test_global_edf, which checks that a CpuSet::all() EDF task preempts when every worker is busy and never runs on CPU 0.
- Wake the primary CPU after the EDF scheduler enqueues a task, so re-wakes from do_preemption and run_main also wake an idle worker.
- Make Dag::get_or_release_job private, because all callers are now in dag.rs.
- Pass the task to ClusteredTask::new by value at its last use.

Signed-off-by: atsushi421 <[email protected]>

@romancardenas romancardenas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I added two suggestions, but feel free to decline them.

Comment thread awkernel_async_lib/src/scheduler/edf.rs Resolved
Comment thread awkernel_async_lib/src/scheduler.rs Resolved
@romancardenas
romancardenas merged commit aa301e2 into main Nov 16, 2026
1 check passed
@romancardenas
romancardenas deleted the feat/merge-gedf-into-edf branch November 16, 2026 00:20
atsushi421 added a commit that referenced this pull request Nov 16, 2026
If an idle core of the set took the woken task, the previous commit
skipped preemption. That rule judges only the woken task. It does not
judge again a queued task that a later task pushes off the idle core.
For example, take one idle core and two busy cores that run tasks with
deadlines 50 and 40. If a task with deadline 12 wakes before a task with
deadline 10, the rule queues both without preemption. The idle core
takes the task with deadline 10, and the task with deadline 12 waits
while the tasks with deadlines 50 and 40 run.

If the sets differ, a rule that compares the queue length with the
number of idle cores also fails. For example, cores 2 and 3 are idle,
and the rule queues two tasks. Core 2 can take the one that core 3 can
also run. Then the other task, whose set holds cores 1 and 2, waits
behind a task with a later deadline on core 1.

Now the scheduler ignores idle cores, as the GEDF scheduler did before
PR #787. It chooses the victim among the busy cores of the set. If the
woken task has a higher priority than the task on that core, the
scheduler preempts it. If an idle core can take the task, the preemption
is unneeded. But a sleeping core runs a queued task only after the
primary CPU wakes it. With this rule, the preempted task waits for that
wake instead of the woken task.

If the set of a task holds one core, the behavior does not change. That
set has no busy core while its core is idle.

Signed-off-by: atsushi421 <[email protected]>
romancardenas pushed a commit that referenced this pull request Nov 16, 2026
If an idle core of the set took the woken task, the previous commit
skipped preemption. That rule judges only the woken task. It does not
judge again a queued task that a later task pushes off the idle core.
For example, take one idle core and two busy cores that run tasks with
deadlines 50 and 40. If a task with deadline 12 wakes before a task with
deadline 10, the rule queues both without preemption. The idle core
takes the task with deadline 10, and the task with deadline 12 waits
while the tasks with deadlines 50 and 40 run.

If the sets differ, a rule that compares the queue length with the
number of idle cores also fails. For example, cores 2 and 3 are idle,
and the rule queues two tasks. Core 2 can take the one that core 3 can
also run. Then the other task, whose set holds cores 1 and 2, waits
behind a task with a later deadline on core 1.

Now the scheduler ignores idle cores, as the GEDF scheduler did before
PR #787. It chooses the victim among the busy cores of the set. If the
woken task has a higher priority than the task on that core, the
scheduler preempts it. If an idle core can take the task, the preemption
is unneeded. But a sleeping core runs a queued task only after the
primary CPU wakes it. With this rule, the preempted task waits for that
wake instead of the woken task.

If the set of a task holds one core, the behavior does not change. That
set has no busy core while its core is idle.

Signed-off-by: atsushi421 <[email protected]>
@romancardenas romancardenas mentioned this pull request Nov 16, 2026
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants