Created by: Alic3r3L1cwhk
This pull request introduces several important improvements for SMP (Symmetric Multi-Processing) support, especially around TLB (Translation Lookaside Buffer) shootdown, and refactors locking for better safety and performance. It also adds new system calls and improves file system and memory management code. The most significant changes are grouped and summarized below:
SMP and TLB Shootdown Support
- Added a TLB shootdown mechanism: introduced
TlbShootdownMsg, per-CPU TLB shootdown queues, and functionstlb_shootdownandhandle_tlb_shootdownto ensure TLB consistency across CPUs when page tables are modified. This is now called insys_munmapandsys_mprotectafter unmapping or changing permissions. [1] [2] [3] [4] [5] [6]
Locking and Concurrency Refactoring
- Replaced uses of
spin::MutexwithSpinNoIrqLockin the FAT32 filesystem module, improving SMP safety and reducing interrupt-related deadlocks. All FAT32 operations now useexclusive_access()instead of.lock(). [1] [2] [3] [4] [5] [6] [7] - Removed unnecessary console output locks and simplified output handling by introducing
print_bytesfor direct byte output. This also affects theSbiConsoleOutimplementation. [1] [2] [3] [4]
System Call Additions and Improvements
- Added implementations for
sys_fsyncandsys_fdatasync, returning success or error codes as appropriate (no-op for ramdisk). - Improved
sys_faccessatwith null pointer checks and logging.
Memory and Page Table Management
- Fixed
sys_mprotectto update only page table flags instead of remapping pages, preserving page contents. Also ensures TLB shootdown is performed after permission changes. - Minor export fix for
PTEFlagsinmm/mod.rsand improved imports. [1] [2]
Wait Queue Documentation and Behavior
- Updated documentation to clarify SMP safety and locking semantics for
WaitQueue. Improved wakeup methods to release locks before waking tasks, reducing risk of nested locks and deadlocks. [1] [2] [3] [4] [5] [6]
These changes collectively improve SMP safety, TLB consistency, and kernel robustness, while also refactoring code for clarity and maintainability.