hermit-os / hermit-os/kernel

Hermit does not sleep with multiple CPUs when MWAIT is available

Open
#2,706 3 comments 0 reactions 1 assignee Claimed by @stlankes View on GitHub
Dominant language
Rust
Stars
1.5k
Forks
132
Avg merge
1d 14h
Merged PRs (30d)
39

Description

To reproduce:

```rust
use std::thread;
use std::time::Duration;

#[cfg(target_os = "hermit")]
use hermit as _;

fn main() {
loop {
thread::sleep(Duration::from_hours(1));
}
}
```

Build:

```bash
cargo build --target=x86_64-unknown-hermit -Zbuild-std=std,panic_abort --features hermit/smp,hermit/loader --package hello_world
```

Run without issue (no MWAIT):

```bash
qemu-system-x86_64 \
-cpu Skylake-Client \
-smp 2 \
-m 1G \
-display none \
-serial stdio \
-kernel hermit-loader-x86_64-multiboot \
-initrd target/x86_64-unknown-hermit/debug/hello_world
```

Run with MWAIT (use `-cpu max`):

```bash
qemu-system-x86_64 \
-cpu max \
-smp 2 \
-m 1G \
-display none \
-serial stdio \
-kernel hermit-loader-x86_64-multiboot \
-initrd target/x86_64-unknown-hermit/debug/hello_world
```

Now, two CPUs are fully utilized.

Is this expected or a bug?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.