Implement multi-core emulation
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- c
- Domain
- backend, operating-systems
Research direction
Start by reading the linked execution paths in main.c:2000-2025 and main.c:1713-1726, then review issue #145, which the issue says must be resolved first. The work spans hart execution, shared memory, interrupts, devices, and GDB, with smoke tests and performance comparisons; completion means parallel multi-hart execution works while single-hart mode remains performant.
Written by the indexing model from the issue text.
Description
Implement multi-core emulation
Support for virtio-gpu introduced a multithreaded model to semu, while the current SMP implementation uses coroutine-based cooperative multitasking. Guest Linux can see multiple harts, but on the host, these harts still take turns running in a single emulator thread (see main.c:2000-2025 and main.c:1713-1726).
Since we have only recently introduced multithreading, now would be a good time to design multi-core emulation. This would allow multiple harts to run in parallel on the host, using multiple processor cores to execute parallel guest workloads while preserving performance in single-hart mode. It would also make semu better suited to testing Linux's multiprocessor behavior and programs that require communication across harts.
The work would broadly include:
- Allow active harts to run on separate host threads, distinguish each hart's own state from state shared by the entire VM, and retain the single-hart execution model.
- Handle shared RAM access,
AMO,LR/SC, andFENCEso that parallel execution conforms to RISC-V memory semantics. - Adapt
HSM,IPI, andRFENCEto handle starting and stopping harts, notifications across harts, and remote synchronization. Interrupts, timers, andWFIwait and wakeup behavior also need to accommodate parallel execution. - Coordinate all harts and devices when pausing, resetting, or shutting down the VM, and allow GDB to inspect each hart, stop execution, and single-step.
- Establish basic smoke tests covering multi-hart boot, parallel workloads, notifications across harts, sleep and wakeup, and shutdown, and compare single-hart and multi-hart performance.
However, the current code architecture makes these changes difficult to implement, as discussed in #145. I think we can start implementing multi-core emulation once #145 is resolved.
- Dominant language
- C
- Stars
- 316
- Forks
- 76
- Avg merge
- 7h 1m
- Merged PRs (30d)
- 1
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sysprog21/semu
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
-
Implement VirtIO PCI transport layerMay be free again @shengwen-tw claimed this 527 days ago, and no pull request is open. Open
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
libreswan/libreswan#3185 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
category:port-update
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
llvm:instcombine
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
llvm/llvm-project#246503 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day