Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "scx_rustland_core: use new consume_raw() libbpf-rs API" #183

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rust/scx_rustland_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ include = [

[dependencies]
anyhow = "1.0"
libbpf-rs = { git = "https://github.com/libbpf/libbpf-rs.git#af3296c00d74fd50b311adc7f931563be137cd8b" }
libbpf-rs = "0.22.0"
libc = "0.2.137"
buddy-alloc = "0.5.1"
scx_utils = { path = "../scx_utils", version = "0.6" }
Expand Down
17 changes: 6 additions & 11 deletions rust/scx_rustland_core/src/bpf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,6 @@ struct AlignedBuffer([u8; BUFSIZE]);

static mut BUF: AlignedBuffer = AlignedBuffer([0; BUFSIZE]);

// Special negative error code for libbpf to stop after consuming just one item from a BPF
// ring buffer.
const LIBBPF_STOP: i32 = -255;

impl<'cb> BpfScheduler<'cb> {
pub fn init(
slice_us: u64,
Expand Down Expand Up @@ -225,7 +221,7 @@ impl<'cb> BpfScheduler<'cb> {
// Maybe we should fix this to stop processing items from the ring buffer also when a
// value > 0 is returned.
//
LIBBPF_STOP
-255
}

// Initialize online CPUs counter.
Expand Down Expand Up @@ -376,16 +372,15 @@ impl<'cb> BpfScheduler<'cb> {
// Receive a task to be scheduled from the BPF dispatcher.
//
// NOTE: if task.cpu is negative the task is exiting and it does not require to be scheduled.
pub fn dequeue_task(&mut self) -> Result<Option<QueuedTask>, i32> {
match self.queued.consume_raw() {
0 => Ok(None),
LIBBPF_STOP => {
pub fn dequeue_task(&mut self) -> Result<Option<QueuedTask>, libbpf_rs::Error> {
match self.queued.consume() {
Ok(()) => Ok(None),
Err(error) if error.kind() == libbpf_rs::ErrorKind::Other => {
// A valid task is received, convert data to a proper task struct.
let task = unsafe { EnqueuedMessage::from_bytes(&BUF.0).to_queued_task() };
Ok(Some(task))
}
res if res < 0 => Err(res),
res => panic!("Unexpected return value from libbpf-rs::consume_raw(): {}", res),
Err(error) => Err(error),
}
}

Expand Down
2 changes: 1 addition & 1 deletion scheds/rust/scx_rlfifo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license = "GPL-2.0-only"
[dependencies]
anyhow = "1.0.65"
ctrlc = { version = "3.1", features = ["termination"] }
libbpf-rs = { git = "https://github.com/libbpf/libbpf-rs.git#af3296c00d74fd50b311adc7f931563be137cd8b" }
libbpf-rs = "0.22.0"
libc = "0.2.137"
scx_utils = { path = "../../../rust/scx_utils", version = "0.6" }
scx_rustland_core = { path = "../../../rust/scx_rustland_core", version = "0.1" }
Expand Down
2 changes: 1 addition & 1 deletion scheds/rust/scx_rustland/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ anyhow = "1.0.65"
clap = { version = "4.1", features = ["derive", "env", "unicode", "wrap_help"] }
ctrlc = { version = "3.1", features = ["termination"] }
fb_procfs = "0.7.0"
libbpf-rs = { git = "https://github.com/libbpf/libbpf-rs.git#af3296c00d74fd50b311adc7f931563be137cd8b" }
libbpf-rs = "0.22.0"
libc = "0.2.137"
log = "0.4.17"
ordered-float = "3.4.0"
Expand Down