Skip to content

feat(scheduler): separated EDF from common clustered scheduling logic - #813

Merged
atsushi421 merged 1 commit into
tier4:mainfrom
romancardenas:refactor/clustered-edf
Nov 24, 2026
Merged

atsushi421 merged 1 commit into
tier4:mainfrom
romancardenas:refactor/clustered-edf

Conversation

@romancardenas

@romancardenas romancardenas commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Description

Separate how clustered tasks run from how EDF orders them. clustered.rs handles CPU affinity, the ready queue, dispatch, and preemption. edf.rs supplies the ordering rule: the task with the earliest absolute deadline runs first among tasks eligible for the current CPU.

The internal ClusteredOrdering trait identifies the scheduler through KIND and supplies (absolute_deadline, ordering_time) once per wake:

Element Purpose
absolute_deadline The real job deadline, stored in the task’s metadata.
ordering_time The primary ready-queue key. The shared scheduler also uses it to derive preemption priority as MAX_TASK_PRIORITY - ordering_time, so earlier values rank higher.

EDF returns (deadline, deadline) because the real deadline also determines its ordering. The shared scheduler separately adds wake_time as the tie-breaker, so the actual EDF queue key remains (deadline, wake_time).

Related links

None.

How was this PR tested?

  • scripts/ci.sh passes on my machine.
  • Ran test_edf on qemu-x86_64. The output logs are:
...
[         5579 INFO] === test_global_edf start ===
[         5879 INFO] global_edf: urgent preempted a filler on cpu 15 [OK]
[         6586 INFO] === test_core_pinning start ===
[         6610 INFO] core_pinning: task on core 1 ran on cpu 1 [OK]
[         6610 INFO] core_pinning: task on core 2 ran on cpu 2 [OK]
[         6611 INFO] core_pinning: task on core 3 ran on cpu 3 [OK]
[         6611 INFO] core_pinning: task on core 4 ran on cpu 4 [OK]
[         6612 INFO] core_pinning: task on core 5 ran on cpu 5 [OK]
[         6613 INFO] core_pinning: task on core 7 ran on cpu 7 [OK]
[         6613 INFO] core_pinning: task on core 11 ran on cpu 11 [OK]
[         6614 INFO] core_pinning: task on core 8 ran on cpu 8 [OK]
[         6614 INFO] core_pinning: task on core 6 ran on cpu 6 [OK]
[         6614 INFO] core_pinning: task on core 12 ran on cpu 12 [OK]
[         6615 INFO] core_pinning: task on core 10 ran on cpu 10 [OK]
[         6617 INFO] core_pinning: task on core 9 ran on cpu 9 [OK]
[         6618 INFO] core_pinning: task on core 13 ran on cpu 13 [OK]
[         6618 INFO] core_pinning: task on core 14 ran on cpu 14 [OK]
[         6619 INFO] core_pinning: task on core 15 ran on cpu 15 [OK]
[         6715 INFO] === test_cluster_affinity start ===
[         6716 INFO] === test_edf_preemption start ===
[         6717 INFO] cluster_affinity: task ran on cpu 2 [OK]
[         6718 INFO] === test_multi_core start ===
[         6718 INFO] === test_empty_set_fallback start ===
[         6719 WARN] awkernel_async_lib/src/task.rs:309: The CPU set must contain at least one core between 1 and 15. Falling back to all worker cores. Given set: CpuMask([0, 0, 0, 0, 0, 0, 0, 0])
[         6719 WARN] awkernel_async_lib/src/task.rs:309: The CPU set must contain at least one core between 1 and 15. Falling back to all worker cores. Given set: CpuMask([65536, 0, 0, 0, 0, 0, 0, 0])
[         6719 INFO] empty_set_fallback: case 1 ran on worker cpu 7 [OK]
[         6720 INFO] empty_set_fallback: case 0 ran on worker cpu 3 [OK]
[         6915 INFO] core_pinning: task on core 7 ran on cpu 7 [OK]
[         6915 INFO] core_pinning: task on core 3 ran on cpu 3 [OK]
[         6915 INFO] core_pinning: task on core 2 ran on cpu 2 [OK]
[         6917 INFO] core_pinning: task on core 6 ran on cpu 6 [OK]
[         6917 INFO] core_pinning: task on core 10 ran on cpu 10 [OK]
[         6917 INFO] core_pinning: task on core 11 ran on cpu 11 [OK]
[         6917 INFO] core_pinning: task on core 8 ran on cpu 8 [OK]
[         6917 INFO] core_pinning: task on core 4 ran on cpu 4 [OK]
[         6917 INFO] core_pinning: task on core 12 ran on cpu 12 [OK]
[         6917 INFO] core_pinning: task on core 9 ran on cpu 9 [OK]
[         6919 INFO] core_pinning: task on core 14 ran on cpu 14 [OK]
[         6929 INFO] core_pinning: task on core 13 ran on cpu 13 [OK]
[         6933 INFO] core_pinning: task on core 5 ran on cpu 5 [OK]
[         6933 INFO] core_pinning: task on core 15 ran on cpu 15 [OK]
[         7020 INFO] cluster_affinity: task ran on cpu 2 [OK]
[         7022 INFO] empty_set_fallback: case 0 ran on worker cpu 11 [OK]
[         7023 INFO] empty_set_fallback: case 1 ran on worker cpu 14 [OK]
[         7216 INFO] core_pinning: task on core 7 ran on cpu 7 [OK]
[         7217 INFO] core_pinning: task on core 3 ran on cpu 3 [OK]
[         7218 INFO] core_pinning: task on core 2 ran on cpu 2 [OK]
[         7218 INFO] core_pinning: task on core 8 ran on cpu 8 [OK]
[         7218 INFO] core_pinning: task on core 10 ran on cpu 10 [OK]
[         7218 INFO] core_pinning: task on core 6 ran on cpu 6 [OK]
[         7219 INFO] core_pinning: task on core 12 ran on cpu 12 [OK]
[         7219 INFO] core_pinning: task on core 4 ran on cpu 4 [OK]
[         7232 INFO] core_pinning: task on core 14 ran on cpu 14 [OK]
[         7247 INFO] core_pinning: task on core 13 ran on cpu 13 [OK]
[         7248 INFO] core_pinning: task on core 15 ran on cpu 15 [OK]
[         7249 INFO] core_pinning: task on core 11 ran on cpu 11 [OK]
[         7251 INFO] core_pinning: task on core 5 ran on cpu 5 [OK]
[         7252 INFO] core_pinning: task on core 9 ran on cpu 9 [OK]
[         7322 INFO] cluster_affinity: task ran on cpu 2 [OK]
[         7324 INFO] empty_set_fallback: case 0 ran on worker cpu 10 [OK]
[         7325 INFO] empty_set_fallback: case 1 ran on worker cpu 12 [OK]
[         7620 DEBUG] applications/tests/test_edf/src/lib.rs:208: light: cpu=1, start=6720217, end=7620464
[         7620 INFO] core_pinning: task on core 1 ran on cpu 1 [OK]
[         7623 INFO] cluster_affinity: task ran on cpu 2 [OK]
[         7923 INFO] cluster_affinity: task ran on cpu 2 [OK]
[         8620 DEBUG] applications/tests/test_edf/src/lib.rs:208: light: cpu=1, start=7720940, end=8620986
[         8621 INFO] core_pinning: task on core 1 ran on cpu 1 [OK]
...
  • Ran test_dag on qemu-x86_64. The output logs are:
...
[         4707 DEBUG] applications/tests/test_dag/src/lib.rs:19: period is 1000000000 [ns]
[         4726 INFO] DAG created successfully
[         4827 DEBUG] applications/tests/test_dag/src/lib.rs:29: value=1 in reactor_source_node
[         4831 DEBUG] applications/tests/test_dag/src/lib.rs:45: value=2 in reactor_node1
[         4832 DEBUG] applications/tests/test_dag/src/lib.rs:78: value=9 in reactor_node3
[         4835 DEBUG] applications/tests/test_dag/src/lib.rs:62: value=4 in reactor_node2
[         4835 DEBUG] applications/tests/test_dag/src/lib.rs:94: value=13 in reactor_node4
[         5826 DEBUG] applications/tests/test_dag/src/lib.rs:29: value=1 in reactor_source_node
[         5827 DEBUG] applications/tests/test_dag/src/lib.rs:45: value=2 in reactor_node1
[         5827 DEBUG] applications/tests/test_dag/src/lib.rs:62: value=4 in reactor_node2
[         5827 DEBUG] applications/tests/test_dag/src/lib.rs:78: value=9 in reactor_node3
[         5827 DEBUG] applications/tests/test_dag/src/lib.rs:94: value=13 in reactor_node4
[         6826 DEBUG] applications/tests/test_dag/src/lib.rs:29: value=1 in reactor_source_node
[         6826 DEBUG] applications/tests/test_dag/src/lib.rs:45: value=2 in reactor_node1
[         6826 DEBUG] applications/tests/test_dag/src/lib.rs:62: value=4 in reactor_node2
[         6826 DEBUG] applications/tests/test_dag/src/lib.rs:78: value=9 in reactor_node3
[         6826 DEBUG] applications/tests/test_dag/src/lib.rs:94: value=13 in reactor_node4
...

Notes for reviewers

This is a behavior-preserving refactor. The two tuple elements are separate so a future scheduler can use a different ordering key without replacing the real deadline. This PR does not add Latest Finish scheduling or change DAG timing.

@atsushi421 atsushi421 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.

The # Implementing a clustered scheduler doc on the Scheduler trait in scheduler.rs and the last paragraph of the EDF section in mdbook/src/internal/scheduler.md still tell a new clustered scheduler to wrap its queue entries in ClusteredTask and to implement queued_cpu_mask() by hand. ClusteredScheduler<O> now does both, so consider pointing these texts to ClusteredOrdering instead. The PRIORITY_LIST prefix and is_clustered() requirement still applies.


scripts/ci.sh runs fmt, the target checks, clippy, udeps, and the host unit tests. None of these reach ClusteredScheduler::wake_task, get_next, or invoke_preemption. Please run test_edf and test_dag on QEMU and add the result to the description, because only those tests exercise the moved code.

Comment thread awkernel_async_lib/src/scheduler/edf.rs Resolved
@romancardenas

Copy link
Copy Markdown
Contributor Author

@atsushi421 I updated the docs and made sure the test applciations work as expected. I modified the description of the PR to include the log traces, as requested.

atsushi421
atsushi421 previously approved these changes Nov 23, 2026
@romancardenas

romancardenas commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

@atsushi421 I had to rebase and fix conflicts with main due to a new merge. Could you review this PR again?

@atsushi421
atsushi421 merged commit 5f96475 into tier4:main Nov 24, 2026
1 check passed
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