Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
3930 commits
Select commit Hold shift + click to select a range
6136111
fix: update unique_ptr
MRNIU Feb 28, 2026
e94ce69
refactor: migrate Singleton<T> to etl::singleton<T> named aliases
MRNIU Feb 28, 2026
d2c1ff2
refactor(arch): move arch-specific singletons out of kernel.h and mak…
MRNIU Feb 28, 2026
41b1a80
refactor(arch): remove static from Interrupt handler arrays
MRNIU Feb 28, 2026
fa41f51
3rd: add cpu_io
MRNIU Feb 28, 2026
36d5cde
refactor(arch): move arch-specific singletons from kernel.h to arch d…
MRNIU Feb 28, 2026
df2d13d
fix: string
MRNIU Feb 28, 2026
9870bde
fix: string
MRNIU Feb 28, 2026
470ed18
refactor: klog
MRNIU Feb 28, 2026
1958b73
refactor: io_buffer
MRNIU Feb 28, 2026
4f07b42
doc: update AGENT.md
MRNIU Feb 28, 2026
edfb305
doc(etl): add ETL integration migration design plan
MRNIU Feb 28, 2026
46a38d4
fix(libc): wrap noexcept in __cplusplus guard for C compilation
MRNIU Feb 28, 2026
79db340
feat(task): add ETL message and router ID registry
MRNIU Feb 28, 2026
dc75be8
refactor(task): replace CloneFlags enum and cpu_affinity with etl::flags
MRNIU Feb 28, 2026
86af6ce
refactor(interrupt): replace InterruptFunc pointer with etl::delegate
MRNIU Feb 28, 2026
906d1d7
refactor(task): replace TaskStatus enum with etl::fsm state machine
MRNIU Feb 28, 2026
89b3fe8
fix(task): address code quality review findings for etl::fsm migration
MRNIU Feb 28, 2026
41fa41c
feat(kernel): add tick and panic observer interfaces using etl::observer
MRNIU Feb 28, 2026
6ccea0b
feat(kernel): add lifecycle and virtio message types for etl::message…
MRNIU Feb 28, 2026
6955faa
docs(plans): add ETL migration implementation plan
MRNIU Feb 28, 2026
9f5b563
Merge branch 'feature/etl-migration'
MRNIU Feb 28, 2026
9070858
fix: task_fsm
MRNIU Feb 28, 2026
809ddf9
refactor: InterruptDelegate
MRNIU Feb 28, 2026
09e2155
style: update include style
MRNIU Feb 28, 2026
96b72c7
refactor: fsm
MRNIU Feb 28, 2026
980f883
refactor: task_control_block
MRNIU Feb 28, 2026
72fb14c
test: fix st
MRNIU Feb 28, 2026
0e9992d
chore(docs): remove superseded etl-migration plan files
MRNIU Feb 28, 2026
929cdd5
feat(expected): add VirtIO/device error codes for device_framework un…
MRNIU Feb 28, 2026
18f5530
feat(device): add platform_config.hpp concrete impl for device_framew…
MRNIU Feb 28, 2026
3022af5
build(device): use BEFORE in TARGET_INCLUDE_DIRECTORIES for platform_…
MRNIU Feb 28, 2026
54846c4
refactor(device_node): replace atomic<bool> with SpinLock-guarded boo…
MRNIU Feb 28, 2026
0d36548
refactor(df_bridge): remove DeviceStorage and ToKernelError, error ty…
MRNIU Feb 28, 2026
3dd1522
refactor(driver_registry): add etl::flat_map index for O(log N) platf…
MRNIU Feb 28, 2026
21618ed
refactor(virtio_blk_driver): remove Traits template param, use unifie…
MRNIU Feb 28, 2026
851605e
refactor(device): remove PlatformTraits template usage, unify error h…
MRNIU Feb 28, 2026
c852757
fix(arch/riscv64): remove PlatformTraits template param from VirtioBl…
MRNIU Feb 28, 2026
42a1176
fix(device): add kMaxSpinIterations to PlatformTraits; use TryBind() …
MRNIU Feb 28, 2026
d77a4d0
chore(submodule): bump device_framework to merged main (440bfe7)
MRNIU Feb 28, 2026
85e2092
refactor(device): delete placeholder and redundant header files
MRNIU Mar 1, 2026
3df49b0
refactor(device): simplify device module — remove Driver concept and …
MRNIU Mar 1, 2026
4c7e161
fix(arch/riscv64,device): update interrupt_main and virtio_blk_driver…
MRNIU Mar 1, 2026
d304efe
docs(device): add device_framework integration design doc
MRNIU Mar 1, 2026
9abe0b3
chore(device): create driver/ subdirectory skeleton
MRNIU Mar 1, 2026
d4de005
feat(device): add traits.hpp inlined from device_framework
MRNIU Mar 1, 2026
ab2ec34
feat(device): add ops/device_ops_base.hpp inlined from device_framework
MRNIU Mar 1, 2026
39cd119
feat(device): add ops/char_device.hpp inlined from device_framework
MRNIU Mar 1, 2026
2310a60
feat(device): add ops/block_device_ops.hpp inlined from device_framework
MRNIU Mar 1, 2026
c7f099c
feat(device): add detail/mmio_accessor.hpp inlined from device_framework
MRNIU Mar 1, 2026
6455a07
feat(device): add detail/storage.hpp inlined from device_framework
MRNIU Mar 1, 2026
1170e44
feat(device): add detail/uart_device.hpp inlined from device_framework
MRNIU Mar 1, 2026
35ec909
feat(device): add detail/ns16550a/ inlined from device_framework
MRNIU Mar 1, 2026
d7cc63e
feat(device): add detail/pl011/ inlined from device_framework
MRNIU Mar 1, 2026
82dc38d
feat(device): add detail/virtio/defs.h + traits.hpp (task 11)
MRNIU Mar 1, 2026
f9a0883
feat(device): add detail/virtio/transport/ (task 12)
MRNIU Mar 1, 2026
cd5f451
feat(device): add detail/virtio/virt_queue/ inlined from device_frame…
MRNIU Mar 1, 2026
fb0b357
feat(device): add detail/virtio/device/ inlined from device_framework
MRNIU Mar 1, 2026
10a21c7
feat(device): add detail/acpi/ inlined from device_framework
MRNIU Mar 1, 2026
18b9d2b
feat(device): add pl011/acpi facade headers and update driver include…
MRNIU Mar 1, 2026
42e5514
refactor(arch): replace device_framework includes with inlined driver…
MRNIU Mar 1, 2026
02344b3
build: remove device_framework from CMake and .gitmodules
MRNIU Mar 1, 2026
9c73cec
chore(device): remove device_framework submodule and platform_config.…
MRNIU Mar 1, 2026
fcaaa63
fix(device): add platform_config.hpp for inlined VirtIO driver and fi…
MRNIU Mar 1, 2026
5eb0af1
style: apply clang-format to VirtIO device and transport headers
MRNIU Mar 1, 2026
25e11e6
docs: remove plan
MRNIU Mar 1, 2026
c4721ff
refactor(device): replace raw array+ptr with etl::vector/flat_map in …
MRNIU Mar 1, 2026
e06ef8c
refactor(device): migrate Ns16550aDriver to etl::delegate, remove Dri…
MRNIU Mar 1, 2026
5968f3e
refactor(device): migrate VirtioBlkDriver to etl::optional + etl::del…
MRNIU Mar 1, 2026
b3f7bb1
refactor(device): delete detail/storage.hpp, superseded by etl::optional
MRNIU Mar 1, 2026
9ae7637
docs(device): update AGENTS.md for ETL refactor
MRNIU Mar 1, 2026
908514d
docs(device): fix duplicate section in AGENTS.md
MRNIU Mar 1, 2026
28c72c9
docs: add device module refactor design document
MRNIU Mar 1, 2026
314bcf9
refactor(device): extract VirtioBlkVfsAdapter to dedicated header
MRNIU Mar 1, 2026
238164a
test(device): add failing tests for VirtioDriver
MRNIU Mar 1, 2026
34f9889
feat(device): add unified VirtioDriver with runtime device-type dispatch
MRNIU Mar 1, 2026
f288f4a
build(device): add virtio_driver.cpp to device library sources
MRNIU Mar 1, 2026
e0cc946
refactor(device): update DeviceInit to use unified VirtioDriver
MRNIU Mar 1, 2026
106936a
refactor(device): ns16550a_driver include ns16550a.hpp directly
MRNIU Mar 1, 2026
2eb8d5f
refactor(device): pl011_driver include pl011.hpp directly
MRNIU Mar 1, 2026
aabc8e5
refactor(device): delete dead ops/ CRTP layer and unused device wrappers
MRNIU Mar 1, 2026
b85c1e9
docs(device): update AGENTS.md for new VirtioDriver architecture
MRNIU Mar 1, 2026
d3a2f18
Merge branch 'feat/device-refactor'
MRNIU Mar 1, 2026
c3b0dda
3rd: update
MRNIU Mar 1, 2026
a75047b
refactor(device): restructure drivers into per-driver subdirectories
MRNIU Mar 1, 2026
9c0c06d
refactor: device
MRNIU Mar 1, 2026
133682b
feat(device,fdt): add ForEachDeviceNode filter and split device_manager
MRNIU Mar 1, 2026
76f06c2
refactor(device): assert-harden mmio_helper and use ForEachDeviceNode
MRNIU Mar 1, 2026
b3b9d8e
refactor: device
MRNIU Mar 1, 2026
e42bd46
refactor: device
MRNIU Mar 1, 2026
3c42396
refactor(virtio): reorganize device/ into per-type subdirectories
MRNIU Mar 1, 2026
22555d1
refactor(virtio): modernize VirtioBlk with std::array
MRNIU Mar 1, 2026
0da72d6
Merge branch 'refactor/virtio-restructure'
MRNIU Mar 1, 2026
641875a
3rd: update cpu_io
MRNIU Mar 1, 2026
a4a0c40
refactor: device
MRNIU Mar 1, 2026
1f7bb59
feat: mmio_accessor
MRNIU Mar 1, 2026
2d4cce0
feat(arch/riscv64): add etl_putchar shim for ETL print support
MRNIU Mar 1, 2026
57092c5
feat(arch/aarch64): add etl_putchar shim for ETL print support
MRNIU Mar 1, 2026
2a74038
feat(arch/x86_64): add etl_putchar shim for ETL print support
MRNIU Mar 1, 2026
1946f47
refactor(device): migrate klog calls to ETL format syntax
MRNIU Mar 1, 2026
1e163e4
refactor(task): migrate klog calls to ETL format syntax
MRNIU Mar 1, 2026
8da36b0
refactor(arch): migrate klog calls to ETL format syntax
MRNIU Mar 1, 2026
88cdf93
refactor(src): migrate klog calls to ETL format syntax
MRNIU Mar 1, 2026
1b17db5
docs: update
MRNIU Mar 1, 2026
aa513c2
docs: update
MRNIU Mar 1, 2026
c976afd
feat(klog): rewrite kernel_log.hpp with type-safe {} format syntax
MRNIU Mar 1, 2026
840b076
docs: update
MRNIU Mar 1, 2026
8615148
refactor(libc): remove nanoprintf, replace sk_printf with emit helpers
MRNIU Mar 1, 2026
a4cf7bc
Merge branch 'refactor/remove-nanoprintf'
MRNIU Mar 1, 2026
d04e882
3rd: update cpu_io
MRNIU Mar 1, 2026
c62eeb5
refactor(libc): replace sk_putchar with etl_putchar
MRNIU Mar 1, 2026
96413b2
refactor(klog): simplify kernel_log — 8 complexity fixes
MRNIU Mar 1, 2026
e2687f5
refactor: replace nanoprintf with etl
MRNIU Mar 1, 2026
743b67f
docs: remove plans
MRNIU Mar 1, 2026
c8a5890
feat: remove kstd::ostream
MRNIU Mar 1, 2026
7c7fecd
refactor: sk_print_str
MRNIU Mar 1, 2026
347ee5f
style: replace __attribute__ with [[xxx]]
MRNIU Mar 2, 2026
f23f126
style: replace __attribute__ with [[xxx]]
MRNIU Mar 2, 2026
0948aff
fix: backtrace
MRNIU Mar 2, 2026
5c1f87f
fix: virtio
MRNIU Mar 2, 2026
179f164
refactor: device
MRNIU Mar 2, 2026
c3de0cf
refactor(device): unify driver singletons to etl::singleton
MRNIU Mar 2, 2026
4c00570
refactor: device
MRNIU Mar 2, 2026
3c14990
docs: remove etl docs
MRNIU Mar 2, 2026
e1546c4
fix(device): resolve singleton alias forward-reference in GetEntry()
MRNIU Mar 2, 2026
6256fc9
feat(device): add DmaRegion type and IoBuffer::ToDmaRegion()
MRNIU Mar 2, 2026
2cc08bb
refactor(device): replace void* DMA with DmaRegion + VirtToPhys abstr…
MRNIU Mar 2, 2026
adf9435
Merge branch 'feature/dma-region'
MRNIU Mar 2, 2026
5bb1b83
refactor: sk_print_str
MRNIU Mar 2, 2026
2cbffc9
refactor: device
MRNIU Mar 2, 2026
659ba02
feat(log): add per-CPU lock-free LogLineRaw/LogStreamRaw interfaces
MRNIU Mar 2, 2026
91a3e1c
fix(arch): use lock-free klog::raw_err in DumpStack to prevent deadlock
MRNIU Mar 2, 2026
0a6a968
refactor: klog
MRNIU Mar 2, 2026
b8926c5
refactor: klog
MRNIU Mar 2, 2026
af170d6
refactor: klog
MRNIU Mar 2, 2026
89e4b4a
3rd: add stb and EasyLogger
MRNIU Mar 3, 2026
ba5b96a
3rd: add stb and EasyLogger
MRNIU Mar 3, 2026
6a102e2
3rd: add stb and EasyLogger
MRNIU Mar 3, 2026
4ef9b5f
3rd: add stb and EasyLogger
MRNIU Mar 3, 2026
b1d9e6c
docs(log): add MPMC log refactor design and implementation plan
MRNIU Mar 3, 2026
4665623
refactor(log): rewrite kernel_log.hpp with MPMC lock-free queue
MRNIU Mar 3, 2026
9f448a2
refactor(log): migrate src/main.cpp to new klog API
MRNIU Mar 3, 2026
affc4b1
refactor(log): migrate src/arch/x86_64/ to new klog API
MRNIU Mar 3, 2026
090c62f
refactor(log): migrate src/arch/riscv64/ to new klog API
MRNIU Mar 3, 2026
f9ed87e
refactor(log): migrate src/arch/aarch64/ to new klog API
MRNIU Mar 3, 2026
4b865d1
refactor(log): migrate src/memory/ to new klog API
MRNIU Mar 3, 2026
ba65624
refactor(log): migrate src/device/ to new klog API
MRNIU Mar 3, 2026
a4e1236
refactor(log): migrate src/task/ to new klog API
MRNIU Mar 3, 2026
a8fd75b
refactor(log): migrate src/filesystem/ to new klog API
MRNIU Mar 3, 2026
7811ccd
refactor(log): migrate remaining headers and syscall to new klog API
MRNIU Mar 3, 2026
19f9e53
refactor(log): update commented-out klog calls in spinlock.hpp to new…
MRNIU Mar 3, 2026
74b328a
fix(log): replace __always_inline with inline on variadic klog functions
MRNIU Mar 3, 2026
a3413c5
fix(log): add missing cpu_io.h include for GetCurrentCoreId
MRNIU Mar 3, 2026
e852253
feat: mpsc log
MRNIU Mar 4, 2026
263ecbb
Merge branch 'refactor/mpmc-log'
MRNIU Mar 4, 2026
f822a01
feat: etl format
MRNIU Mar 4, 2026
96eac4e
fix: etl format
MRNIU Mar 7, 2026
1f46c1a
style: update
MRNIU Mar 7, 2026
282baaa
style: update
MRNIU Mar 7, 2026
d6cea43
feat: log with core id
MRNIU Mar 7, 2026
2c10805
feat: log with core id
MRNIU Mar 7, 2026
2cc9ac3
feat: working on smp
MRNIU Mar 7, 2026
e9dca22
3rd: update etl
MRNIU Mar 8, 2026
65655c8
3rd: update etl
MRNIU Mar 8, 2026
abe8f87
style: update
MRNIU Mar 9, 2026
61a774f
fix: add boot_task
MRNIU Mar 9, 2026
4fa5a9b
fix: move TimerInit to main
MRNIU Mar 9, 2026
71c14ee
fix: move TimerInit to main
MRNIU Mar 9, 2026
138a17d
doc: update AGENTS.md
MRNIU Mar 10, 2026
4b62f82
style: update
MRNIU Mar 10, 2026
d6f8c39
style: update
MRNIU Mar 10, 2026
f6f4413
style: update
MRNIU Mar 10, 2026
5368836
style: update
MRNIU Mar 10, 2026
de15a46
style: update
MRNIU Mar 10, 2026
3c51b6c
style: update
MRNIU Mar 10, 2026
912116b
style: use pragma once
MRNIU Mar 10, 2026
7d192b0
style: update
MRNIU Mar 10, 2026
7e58bd5
style(arch,filesystem,memory): update headers to coding standards
MRNIU Mar 10, 2026
714cad4
style: use trailing return types in .cpp and arch.h
MRNIU Mar 10, 2026
e19ce72
style: update
MRNIU Mar 11, 2026
f4a952b
style: update
MRNIU Mar 11, 2026
ad9f9fa
style: update
MRNIU Mar 11, 2026
0468109
style: update
MRNIU Mar 11, 2026
b32fcf6
style: update
MRNIU Mar 11, 2026
9ede4b1
style: update
MRNIU Mar 11, 2026
0aff049
style: update
MRNIU Mar 11, 2026
7062582
style: update
MRNIU Mar 11, 2026
120f937
style: update
MRNIU Mar 11, 2026
c12081f
style: update
MRNIU Mar 13, 2026
d269b9e
style: update
MRNIU Mar 13, 2026
0e14242
style: update
MRNIU Mar 13, 2026
6d06d10
style: update
MRNIU Mar 13, 2026
e30f707
style: update
MRNIU Mar 13, 2026
d55a4cd
style: update
MRNIU Mar 13, 2026
2ef12ea
style: update
MRNIU Mar 13, 2026
1b2c35a
style: update
MRNIU Mar 13, 2026
32b2b01
style: update
MRNIU Mar 13, 2026
378df42
style: update
MRNIU Mar 13, 2026
2fbdff5
style: update
MRNIU Mar 16, 2026
401fdf8
style: update
MRNIU Mar 16, 2026
550166e
style: update
MRNIU Mar 16, 2026
3ab5d4a
docs: update AGENTS.md
MRNIU Mar 16, 2026
b640df2
test: fix st
MRNIU Mar 16, 2026
16e9a00
style: update
MRNIU Mar 16, 2026
490b88f
style: update
MRNIU Mar 16, 2026
dd2a75d
test: fix st
MRNIU Mar 17, 2026
69a10d4
test: fix st
MRNIU Mar 17, 2026
a6dcb17
test: fix st
MRNIU Mar 17, 2026
3d264d3
docs: update AGENTS.md
MRNIU Mar 18, 2026
d3549d1
fix: warnning
MRNIU Mar 18, 2026
da0693c
fix(multi): address Copilot review findings across IO APIC, VFS, devi…
MRNIU Mar 18, 2026
a34714f
test: update devcontainer
MRNIU Mar 19, 2026
7527168
merge: upstream
MRNIU Mar 19, 2026
c953681
test: update devcontainer
MRNIU Mar 19, 2026
b4f72e6
test: update devcontainer
MRNIU Mar 19, 2026
bee7635
test: update devcontainer
MRNIU Mar 19, 2026
aa94bf0
Merge remote-tracking branch 'upstream'
MRNIU Mar 19, 2026
dc52556
feat: working on signal
MRNIU Mar 19, 2026
7610c3d
test: fix st
MRNIU Mar 19, 2026
5574c2a
fix: update st
MRNIU Mar 20, 2026
7eb2168
fix: st
MRNIU Mar 20, 2026
1508849
test: update ci
MRNIU Mar 20, 2026
f8c39cc
test: update ci
MRNIU Mar 20, 2026
33e0169
fix(cmake): create /srv/tftp directory before symlinking
MRNIU Mar 20, 2026
6f96431
fix(devcontainer): create /srv/tftp for QEMU built-in TFTP server
MRNIU Mar 20, 2026
7def88e
fix(devcontainer): add libssl-dev for U-Boot build
MRNIU Mar 20, 2026
34c0230
fix(devcontainer): add aarch64-linux-gnu-cpp alternative for OP-TEE b…
MRNIU Mar 20, 2026
37b0f52
feat(syscall): wire signal and affinity syscalls into dispatcher
MRNIU Mar 20, 2026
fa40d05
test(task): add yield system test
MRNIU Mar 20, 2026
cec4251
test: claen main.cpp
MRNIU Mar 20, 2026
3cbfa88
test(task): add fork system test
MRNIU Mar 20, 2026
49b1998
test(task): add signal, affinity, tick, zombie_reap, stress system tests
MRNIU Mar 20, 2026
5e6e1d6
fix: st
MRNIU Mar 20, 2026
bcd9be6
test: fix st
MRNIU Mar 20, 2026
82ae3a9
test: working on st
MRNIU Mar 20, 2026
ceba98c
fix: st
MRNIU Mar 20, 2026
4d8800e
fix: timer seq bug
MRNIU Mar 20, 2026
aca5734
fix: timer seq bug
MRNIU Mar 20, 2026
3fc9132
feat: remove x86_64
MRNIU Mar 20, 2026
3b3697b
fix(ci): use virtio-net-device and correct codecov path for ARM runner
MRNIU Mar 20, 2026
5f214f8
perf(ci): parallelize jobs, prebuilt Docker image, caching and shallo…
MRNIU Mar 20, 2026
eece767
test(task): add balance work-stealing unit tests
MRNIU Mar 20, 2026
81ca14e
chore(misc): remove outdated TODO/FIXME comments
MRNIU Mar 20, 2026
23e295a
feat(task): implement Balance() work-stealing load balancer
MRNIU Mar 20, 2026
cf5e379
feat(task): integrate Balance() into TickUpdate() on 64-tick interval
MRNIU Mar 20, 2026
1009da0
docs(task): update AGENTS.md to reflect Balance() implementation
MRNIU Mar 20, 2026
45ae6c8
feat: balance
MRNIU Mar 20, 2026
dd0ebb6
fix(ci): add safe.directory config for container submodule checkout
MRNIU Mar 20, 2026
6873c05
Merge branch 'main' into fix/ci-safe-directory
MRNIU Mar 20, 2026
a36e60e
fix(ci): detect riscv64 system test failures by checking output
MRNIU Mar 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ jobs:
fetch-depth: 1

- name: Shallow submodule init
run: git submodule update --init --recursive --depth 1
run: |
git config --global --add safe.directory '*'
git submodule update --init --recursive --depth 1
Comment on lines +36 to +37
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

git config --global --add safe.directory '*' disables Git's ownership safety checks for all directories inside the container, which is overly broad for CI and can mask genuine repo ownership issues. Prefer adding only the workspace + submodule directories (e.g., add $GITHUB_WORKSPACE and each submodule path via git submodule foreach --recursive ...) so the safety bypass is scoped to the checkout.

Suggested change
git config --global --add safe.directory '*'
git submodule update --init --recursive --depth 1
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git submodule update --init --recursive --depth 1
git submodule foreach --recursive 'git config --global --add safe.directory "$PWD"'

Copilot uses AI. Check for mistakes.

- name: Cache CMake build (riscv64)
uses: actions/cache@v4
Expand All @@ -51,7 +53,9 @@ jobs:
run: |
for i in $(seq 1 $SYSTEM_TEST_RUNS); do
echo "=== riscv64 System Test Run $i/$SYSTEM_TEST_RUNS ==="
if ! timeout 300 cmake --build build_riscv64 --target system_test_run; then
timeout 300 cmake --build build_riscv64 --target system_test_run > /tmp/st_out_$i.txt 2>&1 || true
cat /tmp/st_out_$i.txt
if ! grep -q "Failed: 0" /tmp/st_out_$i.txt; then
echo "riscv64 system test run $i/$SYSTEM_TEST_RUNS FAILED"
exit 1
fi
Expand Down Expand Up @@ -80,7 +84,9 @@ jobs:
fetch-depth: 1

- name: Shallow submodule init
run: git submodule update --init --recursive --depth 1
run: |
git config --global --add safe.directory '*'
git submodule update --init --recursive --depth 1

- name: Cache CMake build (aarch64)
uses: actions/cache@v4
Expand Down
8 changes: 3 additions & 5 deletions src/arch/aarch64/link.ld
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,9 @@ SECTIONS
*(.dynbss)
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
/* Align here to ensure that the .bss section occupies space up to
_end. Align after .bss to ensure correct alignment even if the
.bss section disappears because there are no input sections.
FIXME: Why do we need it? When there is no .bss section, we do not
pad the .data section. */
/* Align here to ensure that the .bss section occupies space up to
_end. Align after .bss to ensure correct alignment even if the
.bss section disappears because there are no input sections. */
. = ALIGN(. != 0 ? 64 / 8 : 1);
}
_bss_end__ = .; __bss_end__ = .;
Expand Down
6 changes: 2 additions & 4 deletions src/arch/riscv64/link.ld
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,8 @@ SECTIONS {
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
/* Align here to ensure that the .bss section occupies space up to
_end. Align after .bss to ensure correct alignment even if the
.bss section disappears because there are no input sections.
FIXME: Why do we need it? When there is no .bss section, we do not
pad the .data section. */
_end. Align after .bss to ensure correct alignment even if the
.bss section disappears because there are no input sections. */
. = ALIGN(. != 0 ? 64 / 8 : 1);
}
. = ALIGN(64 / 8);
Expand Down
2 changes: 1 addition & 1 deletion src/task/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ mutex.cpp # Mutex implementation (uses SpinLock internally)
- Schedulers own their internal run queues — TaskManager dispatches to per-policy schedulers
- `TaskManagerSingleton::instance()` (defined in `task_manager.hpp`) is the global entry point
- TCB contains arch-specific context pointer — populated by `switch.S`
- TODO in `task_manager.cpp`: task stealing across cores (not yet implemented)
- `Balance()` in `task_manager.cpp`: cross-core work-stealing (steals kNormal tasks from most-loaded core, called every 64 ticks)

## ANTI-PATTERNS
- **DO NOT** call Schedule() before TaskManager initialization in boot sequence
Expand Down
78 changes: 76 additions & 2 deletions src/task/task_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,82 @@ auto TaskManager::FindTask(Pid pid) -> TaskControlBlock* {
}

auto TaskManager::Balance() -> void {
// 算法留空
// TODO: 检查其他核心的运行队列长度,如果比当前核心长,则窃取任务
auto current_core = cpu_io::GetCurrentCoreId();
auto& current_sched = cpu_schedulers_[current_core];

// 获取当前核心 kNormal 队列长度(无锁快速检查)
size_t current_load = 0;
if (current_sched.schedulers[static_cast<uint8_t>(SchedPolicy::kNormal)]) {
current_load =
current_sched.schedulers[static_cast<uint8_t>(SchedPolicy::kNormal)]
->GetQueueSize();
}

// 寻找负载最高的核心
size_t max_load = 0;
size_t max_core = current_core;

for (size_t core_id = 0; core_id < SIMPLEKERNEL_MAX_CORE_COUNT; ++core_id) {
if (core_id == current_core) {
continue;
}
auto& other_sched = cpu_schedulers_[core_id];
if (other_sched.schedulers[static_cast<uint8_t>(SchedPolicy::kNormal)]) {
size_t load =
other_sched.schedulers[static_cast<uint8_t>(SchedPolicy::kNormal)]
->GetQueueSize();
if (load > max_load) {
max_load = load;
max_core = core_id;
}
}
}

// 仅当差值 > 1 时才窃取(避免 ping-pong)
if (max_core == current_core || max_load <= current_load + 1) {
return;
}

// 按核心 ID 顺序获取锁,防止死锁
auto& source_sched = cpu_schedulers_[max_core];
size_t first_core = (current_core < max_core) ? current_core : max_core;
size_t second_core = (current_core < max_core) ? max_core : current_core;

LockGuard<SpinLock> lock_first(cpu_schedulers_[first_core].lock);
LockGuard<SpinLock> lock_second(cpu_schedulers_[second_core].lock);

// 重新检查(持锁后条件可能已变化)
auto* source_scheduler =
source_sched.schedulers[static_cast<uint8_t>(SchedPolicy::kNormal)].get();
auto* dest_scheduler =
current_sched.schedulers[static_cast<uint8_t>(SchedPolicy::kNormal)]
.get();

if (!source_scheduler || !dest_scheduler) {
return;
}

size_t source_load = source_scheduler->GetQueueSize();
size_t dest_load = dest_scheduler->GetQueueSize();

if (source_load <= dest_load + 1) {
return;
}

auto* stolen = source_scheduler->PickNext();
if (!stolen) {
return;
}

if (stolen->aux && stolen->aux->cpu_affinity.value() != UINT64_MAX &&
!(stolen->aux->cpu_affinity.value() & (1UL << current_core))) {
source_scheduler->Enqueue(stolen);
return;
}

dest_scheduler->Enqueue(stolen);
klog::Debug("Balance: Stole task '{}' (pid={}) from core {} to core {}",
stolen->name, stolen->pid, max_core, current_core);
}

auto TaskManager::ReapTask(TaskControlBlock* task) -> void {
Expand Down
4 changes: 4 additions & 0 deletions src/task/tick_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ auto TaskManager::TickUpdate() -> void {
}
}

if (cpu_sched.scheduler_started && (cpu_sched.local_tick % 64) == 0) {
Balance();
}

if (need_preempt && cpu_sched.scheduler_started) {
Schedule();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_test/aarch64_minimal/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @copyright Copyright The SimpleKernel Contributors
* @brief TODO: Add description
* @brief AArch64 minimal boot test
*/

#include <cstdarg>
Expand Down
1 change: 1 addition & 0 deletions tests/system_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ ADD_EXECUTABLE (
tick_test.cpp
zombie_reap_test.cpp
stress_test.cpp
balance_test.cpp
${CMAKE_SOURCE_DIR}/src/syscall.cpp
${CMAKE_SOURCE_DIR}/src/io_buffer.cpp)

Expand Down
Loading
Loading