--- title: "SMP Support - Test Plan" tags: unikraft, smp, synchronization teams: - smp --- # SMP Support - Test Plan ## Types of Test Scenarios - Check functionality (e.g. unit tests, integration tests, positive / negative testing). - Do benchmarking. Baseline values are needed to have data to compare to. - Add test cases if there are regressions. - Use 1, 2 or more CPU cores for the testing setup. - Check different architectures: - x86_64 - Arm64 - Check different platforms: - KVM - linuxu - Xen ## Libraries and Tools Used for Testing - [uktest](https://github.com/unikraft/unikraft/tree/staging/lib/uktest) - [Unikraft support scripts](https://github.com/unikraft/unikraft/tree/staging/support/scripts) ## SMP-safe Unikraft Core - ["Syncronization primitives" PR](https://github.com/unikraft/unikraft/pull/476): - spinlock - mutex - semaphore - reader-writer lock - Note (@Sairaj): "Currently, we are using a global timer, which can only wake up Bootstrap CPU. In the SMP environment we should use the timer provided by the LAPIC. Because of this we cannot use deadline-based waking up on the SMP system." - https://github.com/sairajkodilkar/unikraft/tree/sched-sync - [Unikraft internal libraries](https://github.com/unikraft/unikraft/tree/staging/lib) - posix libraries (TODO: specify which libraries) - ukalloc - ukallocbbuddy - ["lib/ukalloc: Synchronize the bbuddy allocator" PR](https://github.com/unikraft/unikraft/pull/801) - ["A Non-blocking Buddy System for Scalable Memory Allocation on Multi-core Machines" Article](https://arxiv.org/pdf/1804.03436.pdf) - ["SMP-safe memory allocation" doc](https://hackmd.io/@unikraft/HJStgQ1W3) - ukdebug - uksched - uktest - ukvmem - vfscore - [Unikraft platform components](https://github.com/unikraft/unikraft/tree/staging/plat) - common/paging - drivers/virtio - ["driver/virtio-net: Make virtio-net SMP safe" PR](https://github.com/unikraft/unikraft/pull/759) - Global variables to be set to per-cpu variables - ["Add per-lcpu variable definition" PR](https://github.com/unikraft/unikraft/pull/784) - `__uk_sched_thread_current` from https://github.com/unikraft/unikraft/blob/staging/lib/uksched/sched.c - `vmem_active_vas` from https://github.com/unikraft/unikraft/blob/staging/lib/ukvmem/vmem.c - `pg_active_pt` from https://github.com/unikraft/unikraft/blob/staging/plat/common/paging.c ## SMP-safe Memory Allocation - [Unikraft memory allocators](https://github.com/search?q=topic%3Aallocator+org%3Aunikraft&type=Repositories): - [TLSF](https://github.com/unikraft/lib-tlsf) - [Mimalloc](https://github.com/unikraft/lib-mimalloc) - [tinyalloc](https://github.com/unikraft/lib-tinyalloc) ## ISR-safe Code ## References - SMP GitHub project: https://github.com/orgs/unikraft/projects/21 - https://hackmd.io/@unikraft/HyNdSyAki#SMP-safe-Unikraft-Core - https://hackmd.io/@unikraft/HyNdSyAki#SMP-safe-Memory-Allocation - https://hackmd.io/@unikraft/HyNdSyAki#ISR-Safe-Code - https://unikraft.org/blog/2022-06-27-unikraft-synchronization/ - https://unikraft.org/blog/2022-07-19-unikraft-synchronization/ - https://unikraft.org/blog/2022-08-21-unikraft-ioapic/