Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • O OSKernel2026-StellarOS
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Terraform modules
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • StellarOS
  • OSKernel2026-StellarOS
  • Merge requests
  • !15

Feat/smp

  • Review changes

  • Download
  • Patches
  • Plain diff
Merged StellarOS requested to merge feat/smp into main Mar 25, 2026
  • Overview 2
  • Commits 27
  • Pipelines 0
  • Changes 42

Created by: Alic3r3L1cwhk

This pull request introduces comprehensive support for SMP (Symmetric Multiprocessing) and a global blocking/waiting model in the kernel, along with significant improvements to the VirtIO block device driver and per-CPU data structures. It also refactors the PLIC (interrupt controller) driver for multi-core awareness and updates build scripts and documentation to reflect these enhancements. The changes lay the groundwork for robust multi-core operation, scalable synchronization primitives, and a unified I/O blocking interface.

SMP and Per-CPU Infrastructure

  • Added per-CPU data structures in os/src/cpu/mod.rs, including a static array for CPUs, runtime CPU count detection, and per-hart initialization and scheduling support. The kernel now uses the tp register to index per-CPU state, supporting efficient, zero-overhead per-core data access.
  • The kernel boot sequence (os/src/entry.asm) now supports multi-core initialization, assigning each hart a unique stack and setting up the tp register for per-hart data access.
  • Kernel configuration (os/src/config.rs) now includes compile-time SMP core count (SMP_COUNT), stack sizing, and a maximum CPU limit, generated via build.rs and Makefile integration. [1] [2] [3] [4] [5] [6]

VirtIO Block Device Driver Overhaul

  • Refactored the block device driver (os/src/drivers/block.rs) to use a completion-based model: requests are submitted non-blocking, and tasks block on a wait queue until completion, which is triggered by device interrupts. This replaces previous busy-spin polling and enables efficient SMP-safe I/O. IRQ handling is now explicit and integrated with the new SMP-aware PLIC configuration. [1] [2]

PLIC (Interrupt Controller) SMP Support

  • The PLIC driver (os/src/drivers/plic.rs) is now fully SMP-aware, dynamically computing context numbers per hart and supporting per-hart interrupt enable/disable, threshold, and claim/complete operations. This ensures correct interrupt routing and handling on all cores. [1] [2]
  • Block device and other drivers now enable interrupts for all harts and properly set priorities, leveraging the new PLIC interface.

Unified Kernel Synchronization and I/O Blocking

  • Documentation and code comments detail the transition to global wait queues (WaitQueue) and unified poll/epoll interfaces for all I/O objects, reducing special cases and improving scalability. [1] [2]

Build System and Documentation

  • The build system (Makefile, os/Makefile, os/Cargo.toml, os/build.rs) now supports configurable SMP core counts, propagating this information to the kernel at compile time and ensuring all tools and scripts are SMP-aware. [1] [2] [3] [4] [5]
  • The README.md has been updated with detailed progress on SMP, per-core scheduling, global blocking, and new I/O models, as well as expanded build/test instructions. [1] [2]

Summary of Key Changes:

SMP and Per-CPU Support

  • Introduced per-CPU data structures, runtime CPU count detection, and per-hart initialization and scheduling in os/src/cpu/mod.rs.
  • Boot code and kernel config updated for multi-core stack allocation and compile-time SMP core count, with Makefile/build system integration. [1] [2] [3] [4] [5] [6] [7]

Device Drivers and Interrupts

  • VirtIO block driver refactored for completion-based, SMP-safe I/O; IRQ handling generalized and integrated with wait queues. [1] [2]
  • PLIC driver fully SMP-aware, with per-hart context calculation and interrupt management. [1] [2]

Synchronization and I/O Model

  • Unified wait queue and poll/epoll interfaces for all I/O objects, as documented and implemented across the kernel. [1] [2]

Build and Documentation

  • Build scripts and documentation updated to reflect SMP support, new features, and testing procedures. [1] [2] [3] [4] [5] [6] [7]

These changes collectively enable robust multi-core operation, scalable kernel synchronization, and a modern, unified I/O blocking model.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: feat/smp