mitosis: fix build

Minimal changes to make sure scx_mitosis can build with the latest scx
changes.

Signed-off-by: Dan Schatzberg <schatzberg.dan@gmail.com>
This commit is contained in:
Dan Schatzberg 2024-10-09 08:23:01 -07:00
parent d7576d4b44
commit 347147b10d
6 changed files with 55 additions and 12 deletions

40
Cargo.lock generated
View File

@ -419,6 +419,18 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
[[package]]
name = "cgroupfs"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66348822148cc35473745aaec1dfef694010fc8b437541ef6e64db5c223a0846"
dependencies = [
"nix 0.25.1",
"openat",
"serde",
"thiserror",
]
[[package]] [[package]]
name = "chrono" name = "chrono"
version = "0.4.38" version = "0.4.38"
@ -1112,6 +1124,12 @@ version = "0.4.22"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
[[package]]
name = "maplit"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
[[package]] [[package]]
name = "memchr" name = "memchr"
version = "2.7.4" version = "2.7.4"
@ -1749,6 +1767,28 @@ dependencies = [
"zvariant", "zvariant",
] ]
[[package]]
name = "scx_mitosis"
version = "0.0.4"
dependencies = [
"anyhow",
"bitvec",
"cgroupfs",
"clap",
"ctrlc",
"fb_procfs",
"itertools 0.13.0",
"lazy_static",
"libbpf-rs",
"libc",
"log",
"maplit",
"scx_utils",
"serde",
"serde_json",
"simplelog",
]
[[package]] [[package]]
name = "scx_rlfifo" name = "scx_rlfifo"
version = "1.0.5" version = "1.0.5"

View File

@ -9,5 +9,6 @@ members = ["rust/scx_stats",
"scheds/rust/scx_rustland", "scheds/rust/scx_rustland",
"scheds/rust/scx_rlfifo", "scheds/rust/scx_rlfifo",
"scheds/rust/scx_rusty", "scheds/rust/scx_rusty",
"scheds/rust/scx_layered"] # scx_mitosis temporarily excluded "scheds/rust/scx_layered",
"scheds/rust/scx_mitosis"]
resolver = "2" resolver = "2"

View File

@ -331,7 +331,7 @@ if enable_rust
rust_scheds = ['scx_lavd', 'scx_bpfland', 'scx_rustland', 'scx_rlfifo', rust_scheds = ['scx_lavd', 'scx_bpfland', 'scx_rustland', 'scx_rlfifo',
'scx_rusty', 'scx_rusty',
'scx_layered'] # scx_mitosis temporarily excluded 'scx_layered', 'scx_mitosis']
rust_misc = ['scx_stats', 'scx_stats_derive', 'scx_utils', rust_misc = ['scx_stats', 'scx_stats_derive', 'scx_utils',
'scx_rustland_core', 'scx_rustland_core',
'scx_loader'] 'scx_loader']

View File

@ -19,7 +19,6 @@ libbpf-rs = "0.24.1"
libc = "0.2.137" libc = "0.2.137"
log = "0.4.17" log = "0.4.17"
maplit = "1.0.2" maplit = "1.0.2"
prometheus-client = "0.19"
scx_utils = { path = "../../../rust/scx_utils", version = "1.0.5" } scx_utils = { path = "../../../rust/scx_utils", version = "1.0.5" }
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0" serde_json = "1.0"

View File

@ -126,7 +126,7 @@ struct {
static inline struct cgroup *task_cgroup(struct task_struct *p) static inline struct cgroup *task_cgroup(struct task_struct *p)
{ {
struct cgroup *cgrp = scx_bpf_task_cgroup(p); struct cgroup *cgrp = __COMPAT_scx_bpf_task_cgroup(p);
if (!cgrp) { if (!cgrp) {
scx_bpf_error("Failed to get cgroup for task %d", p->pid); scx_bpf_error("Failed to get cgroup for task %d", p->pid);
} }

View File

@ -10,6 +10,7 @@ use std::collections::BTreeMap;
use std::collections::HashMap; use std::collections::HashMap;
use std::collections::VecDeque; use std::collections::VecDeque;
use std::fs::File; use std::fs::File;
use std::mem::MaybeUninit;
use std::os::fd::AsRawFd; use std::os::fd::AsRawFd;
use std::path::PathBuf; use std::path::PathBuf;
use std::sync::atomic::AtomicBool; use std::sync::atomic::AtomicBool;
@ -27,6 +28,8 @@ use itertools::Itertools;
use libbpf_rs::skel::OpenSkel; use libbpf_rs::skel::OpenSkel;
use libbpf_rs::skel::Skel; use libbpf_rs::skel::Skel;
use libbpf_rs::skel::SkelBuilder; use libbpf_rs::skel::SkelBuilder;
use libbpf_rs::MapCore as _;
use libbpf_rs::OpenObject;
use log::debug; use log::debug;
use log::info; use log::info;
use log::trace; use log::trace;
@ -276,8 +279,8 @@ impl<'a> Scheduler<'a> {
false => "scheduler_tick", false => "scheduler_tick",
}; };
skel.progs_mut() skel.progs
.sched_tick_fentry() .sched_tick_fentry
.set_attach_target(0, Some(sched_tick_name.into())) .set_attach_target(0, Some(sched_tick_name.into()))
.context("Failed to set attach target for sched_tick_fentry()")?; .context("Failed to set attach target for sched_tick_fentry()")?;
@ -388,8 +391,8 @@ impl<'a> Scheduler<'a> {
let cell_idx_slice = unsafe { any_as_u8_slice(&cell_idx_u32) }; let cell_idx_slice = unsafe { any_as_u8_slice(&cell_idx_u32) };
/* XXX: NO_EXIST should be correct here, but it fails */ /* XXX: NO_EXIST should be correct here, but it fails */
self.skel self.skel
.maps() .maps
.cgrp_cell_assignment() .cgrp_cell_assignment
.update(cg_fd_slice, cell_idx_slice, libbpf_rs::MapFlags::ANY) .update(cg_fd_slice, cell_idx_slice, libbpf_rs::MapFlags::ANY)
.with_context(|| { .with_context(|| {
format!("Failed to update cgroup cell assignment for: {}", cg_path) format!("Failed to update cgroup cell assignment for: {}", cg_path)
@ -434,8 +437,8 @@ impl<'a> Scheduler<'a> {
let cg_fd_slice = unsafe { any_as_u8_slice(&cg_fd) }; let cg_fd_slice = unsafe { any_as_u8_slice(&cg_fd) };
if let Some(v) = self if let Some(v) = self
.skel .skel
.maps() .maps
.cgrp_ctx() .cgrp_ctx
.lookup(cg_fd_slice, libbpf_rs::MapFlags::ANY) .lookup(cg_fd_slice, libbpf_rs::MapFlags::ANY)
.with_context(|| { .with_context(|| {
format!( format!(
@ -529,8 +532,8 @@ impl<'a> Scheduler<'a> {
let zero_slice = unsafe { any_as_u8_slice(&zero) }; let zero_slice = unsafe { any_as_u8_slice(&zero) };
if let Some(v) = self if let Some(v) = self
.skel .skel
.maps() .maps
.cpu_ctxs() .cpu_ctxs
.lookup_percpu(zero_slice, libbpf_rs::MapFlags::ANY) .lookup_percpu(zero_slice, libbpf_rs::MapFlags::ANY)
.context("Failed to lookup cpu_ctxs map")? .context("Failed to lookup cpu_ctxs map")?
{ {