---
# System prepended metadata

title: 'SMP WG, February 21, 2023'
tags: [' synchronization', ' smp', unikraft]

---

---
title: "SMP WG, February 21, 2023"
tags: unikraft, smp, synchronization
datetime: 2023-02-21T14:30:00+02:00
location: Online, Discord (https://bit.ly/UnikraftDiscord), the `#monkey-business` voice channel
teams:
- smp
participants:
- Andra
- Razvan V
- Sairaj
- Simon
---

## :dart: Agenda

- Status update
- Next steps

## :closed_book: Discussions

AP:

- Created doc for the SMP test plan: https://hackmd.io/@unikraft/BkQnu4bCs.
- Did reviews for the [synchronization primitives](https://github.com/unikraft/unikraft/pull/476) and [virtio-net multiqueue support](https://github.com/unikraft/unikraft/pull/712) PRs.
- Looking into how to adjust the scheduler to validate the synchronization primitives using a multi-core setup e.g. define [per-CPU variable(s) for the current thread](https://github.com/unikraft/unikraft/blob/staging/lib/uksched/sched.c#L46) (use CPU core ID as index in the array variable) and integrate it in the scheduler orchestration.

RV:

- Looked in the ukalloc buddy, trying to synchronize its implementation.
- Started by using the spinlock.
- Started to use malloc with different CPU cores.
- Could I start with uktest?
- Can start with ukalloc buddy main one.
- When should check the state? After allocation and memory setup ...

Simon K:

- Could alloc, free, alloc, free, and check for failures.
- Can increase, decrease memory size, free, can run on different CPUs.
- Can also have unit tests eventually.
- Could check each allocation is not overllaping.
- Could check free memory, if also makes sense.
- Could do massive allocs of different size, if free operations works.
- Could develop 2 types of test suites: for the generic one ukalloc, and per each memory allocator, based also on the internals e.g. metadata.
- Could check for overlapping regios when using multiple cores.
- Check pair-wise the memory size on the same CPU and different ones.
- The testing setup could crash (e.g. invalid metadata) or could fail.

Sairaj K:

- Created a [PR for SMP-safe virtio-net](https://github.com/unikraft/unikraft/pull/759).
- Try to break the virtio-net for SMP.
- Trying to send data on the same queue using different processors.
- Run http-reply application, but not using SMP, so just checks it is not breaking with these changes.

Simon K:

- Do you use the uknetdev for SMP checks?
- Should use this for testing.

Sairaj K:

- Yes, I use the gen packet app one.
- Could use tap or bridge for this setup. (Discord reference for the previous discussion on this topic: https://discord.com/channels/762976922531528725/883603425076584448/1062596440507023390)
- Can send traffic to a local application on my system.

Simon K:

- Can pick traffic on the other guest, setup 2 VMs.
- Could read about macvtap mode, get network access without passthrough to guest.
- Thinking how to test virtio multiqueue on the receive side.

Sairaj K:

- Can take a look at core libraries, to check for synchronization.
- Marc suggested to take a look into TLS for SMP.
- Could also look into the sched / thread part of uksched.

Simon K:

- Can use cooperative scheduler for a testing setup with one scheduler per CPU.
- Can also schedule a thread for pinning to a certain CPU, migrate threads between schedulling instances.
- Then can setup schedulers per multiple CPUs.
- Can check ukboot for CPU scheduling, provide a function for the SMP API, use sched register.
- Create a thread on CPU A and assign it to CPU B, need spinlock for the API.
- Make the library ecosystem work with SMP e.g. vfscore.
- Also can check the posix libraries, lwip for SMP-safe setup.

## :wrench: TODOs and Decisions

- Add uklock library to the CI system configuration. This is needed for the [synchronization primitives PR](https://github.com/unikraft/unikraft/pull/476). Discord channel discussion: https://discord.com/channels/762976922531528725/857972234201858099/1073559322841329674.
- AP:
    - Adjust the scheduler to validate the synchronization primitives using a multi-core setup e.g. define [per-CPU variable(s) for the current thread](https://github.com/unikraft/unikraft/blob/staging/lib/uksched/sched.c#L46) (use CPU core ID as index in the array variable) and integrate it in the scheduler orchestration
    - Complete the first round of review for the virtio-net multiqueue support PR.
    - Create a list of Unikraft components e.g. libraries, that need synchronization in a multi-core environment. Then we can discuss in the SMP community meeting about priorities and dependencies.
- RV:
    - Identify test cases / failures and necessary synchronization for the ukalloc buddy.
- Sairaj K:
    - Develop a testing setup for the virtio-net multiqueue support when using multiple cores.
    - Help with the synchronization primitives validation.
    - Can then take a look at Unikraft core libraries, to check for necessary synchronization.