mirror of
https://github.com/JakeHillion/scx.git
synced 2024-11-26 11:30:22 +00:00
Revert "scx_rustland_core: use new consume_raw() libbpf-rs API"
In order to use the new consume_raw() API we need to depend on a version
of libbpf-rs that is not released yet.
Apparently adding such dependency may introduce a potential dependency
conflict with libbpf-sys.
Therefore, revert this change and go back to the previous consume() API.
One a new version of libbpf-rs will be out we can update all our
dependencies to use the new libbpf-rs and re-apply this patch to
scx_rustland_core.
Fixes: 7c8c5fd
("scx_rustland_core: use new consume_raw() libbpf-rs API")
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
This commit is contained in:
parent
b7c06b9ed9
commit
bd2c18afd5
@ -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" }
|
||||
|
@ -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,
|
||||
@ -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.
|
||||
@ -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),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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" }
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user