Skip to content

Commit

Permalink
Merge pull request #994 from mkroening/smp-ci
Browse files Browse the repository at this point in the history
ci: test everything with SMP
  • Loading branch information
mkroening authored Dec 1, 2023
2 parents 00844f5 + 6ebd36d commit 054d2d6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ jobs:
package: [rusty_demo, httpd, testudp, hello_world]
netdev: [none, virtio-net-pci, rtl8139]
profile: [dev, release]
smp: [1, 4]
exclude:
- arch: riscv64
package: httpd
Expand All @@ -141,6 +142,12 @@ jobs:
arch: aarch64
- package: hello_world
arch: riscv64
# https://github.com/hermit-os/kernel/issues/995
- package: hello_world
smp: 4
# https://github.com/hermit-os/kernel/issues/737
- arch: aarch64
smp: 4
# rtl8139 support does not build on aarch64
- arch: aarch64
netdev: rtl8139
Expand Down Expand Up @@ -224,6 +231,7 @@ jobs:
cargo xtask ci qemu
--arch ${{ matrix.arch }}
--package ${{ matrix.package }}
--smp ${{ matrix.smp }}
${{ matrix.flags }}
${{ matrix.netdev == 'rtl8139' && '--features rtl8139' || '' }}
${{ matrix.netdev != 'none' && format('--netdev {0}', matrix.netdev) || '' }}
Expand Down
2 changes: 1 addition & 1 deletion xtask/src/cargo_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct CargoBuild {

/// Space or comma separated list of features to activate.
#[arg(long)]
features: Vec<String>,
pub features: Vec<String>,
}

pub trait CmdExt {
Expand Down
27 changes: 12 additions & 15 deletions xtask/src/ci/qemu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ pub struct Qemu {
netdev: Option<NetworkDevice>,

/// Create multiple vCPUs.
#[arg(long)]
smp: bool,
#[arg(long, default_value_t = 1)]
smp: usize,

/// Enable the `virtiofsd` virtio-fs vhost-user device daemon.
#[arg(long)]
Expand All @@ -46,7 +46,14 @@ pub enum NetworkDevice {
}

impl Qemu {
pub fn run(self) -> Result<()> {
pub fn run(mut self) -> Result<()> {
if self.smp > 1 {
self.build
.cargo_build
.features
.push("hermit/smp".to_string());
}

self.build.run()?;

let sh = crate::sh()?;
Expand All @@ -63,7 +70,7 @@ impl Qemu {
.args(&["-kernel", format!("../hermit-loader-{arch}").as_ref()])
.args(self.machine_args())
.args(self.cpu_args())
.args(self.smp_args())
.args(&["-smp", &self.smp.to_string()])
.args(self.memory_args())
.args(self.netdev_args())
.args(self.virtiofsd_args());
Expand Down Expand Up @@ -171,14 +178,6 @@ impl Qemu {
}
}

fn smp_args(&self) -> &'static [&'static str] {
if self.smp {
&["-smp", "4"]
} else {
&["-smp", "1"]
}
}

fn memory(&self) -> usize {
let mut memory = 32usize;
if self.build.cargo_build.artifact.arch == Arch::Riscv64 {
Expand All @@ -190,9 +189,7 @@ impl Qemu {
if self.netdev.is_some() {
memory *= 4;
}
if self.smp {
memory *= 4;
}
memory *= self.smp;
if self.build.cargo_build.artifact.arch == Arch::Aarch64 {
memory = memory.max(256);
}
Expand Down

0 comments on commit 054d2d6

Please sign in to comment.