Merge pull request #36 from danielocfb/topic/libbpf-rs-update

rust: Update libbpf-rs & libbpf-cargo to 0.22
This commit is contained in:
Tejun Heo 2023-12-14 12:41:20 -10:00 committed by GitHub
commit 52381a9764
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 31 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "scx_utils"
version = "0.3.3"
version = "0.4.0"
edition = "2021"
authors = ["Tejun Heo <tj@kernel.org>"]
license = "GPL-2.0-only"
@ -12,7 +12,7 @@ anyhow = "1.0"
bindgen = "0.69"
glob = "0.3"
lazy_static = "1.4"
libbpf-cargo = "0.21"
libbpf-cargo = "0.22"
regex = "1.10"
sscanf = "0.4"
tar = "0.4"

View File

@ -13,16 +13,16 @@ clap = { version = "4.1", features = ["derive", "env", "unicode", "wrap_help"] }
ctrlc = { version = "3.1", features = ["termination"] }
fb_procfs = "0.7"
lazy_static = "1.4"
libbpf-rs = "0.21"
libbpf-rs = "0.22"
libc = "0.2"
log = "0.4"
scx_utils = { path = "../../../rust/scx_utils", version = "0.3" }
scx_utils = { path = "../../../rust/scx_utils", version = "0.4" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
simplelog = "0.12"
[build-dependencies]
scx_utils = { path = "../../../rust/scx_utils", version = "0.3" }
scx_utils = { path = "../../../rust/scx_utils", version = "0.4" }
[features]
enable_backtrace = []

View File

@ -1122,10 +1122,10 @@ struct Scheduler<'a> {
impl<'a> Scheduler<'a> {
fn init_layers(skel: &mut OpenBpfSkel, specs: &Vec<LayerSpec>) -> Result<()> {
skel.rodata().nr_layers = specs.len() as u32;
skel.rodata_mut().nr_layers = specs.len() as u32;
for (spec_i, spec) in specs.iter().enumerate() {
let layer = &mut skel.bss().layers[spec_i];
let layer = &mut skel.bss_mut().layers[spec_i];
for (or_i, or) in spec.matches.iter().enumerate() {
for (and_i, and) in or.iter().enumerate() {
@ -1176,12 +1176,12 @@ impl<'a> Scheduler<'a> {
let mut skel = skel_builder.open().context("Failed to open BPF program")?;
// Initialize skel according to @opts.
skel.rodata().debug = opts.verbose as u32;
skel.rodata().slice_ns = opts.slice_us * 1000;
skel.rodata().nr_possible_cpus = *NR_POSSIBLE_CPUS as u32;
skel.rodata().smt_enabled = cpu_pool.nr_cpus > cpu_pool.nr_cores;
skel.rodata_mut().debug = opts.verbose as u32;
skel.rodata_mut().slice_ns = opts.slice_us * 1000;
skel.rodata_mut().nr_possible_cpus = *NR_POSSIBLE_CPUS as u32;
skel.rodata_mut().smt_enabled = cpu_pool.nr_cpus > cpu_pool.nr_cores;
for cpu in cpu_pool.all_cpus.iter_ones() {
skel.rodata().all_cpus[cpu / 8] |= 1 << (cpu % 8);
skel.rodata_mut().all_cpus[cpu / 8] |= 1 << (cpu % 8);
}
Self::init_layers(&mut skel, &layer_specs)?;
@ -1274,7 +1274,7 @@ impl<'a> Scheduler<'a> {
{
Self::update_bpf_layer_cpumask(
&self.layers[idx],
&mut self.skel.bss().layers[idx],
&mut self.skel.bss_mut().layers[idx],
);
updated = true;
}
@ -1288,7 +1288,7 @@ impl<'a> Scheduler<'a> {
let nr_available_cpus = available_cpus.count_ones();
for idx in 0..self.layers.len() {
let layer = &mut self.layers[idx];
let bpf_layer = &mut self.skel.bss().layers[idx];
let bpf_layer = &mut self.skel.bss_mut().layers[idx];
match &layer.kind {
LayerKind::Open { .. } => {
layer.cpus.copy_from_bitslice(&available_cpus);
@ -1299,7 +1299,7 @@ impl<'a> Scheduler<'a> {
}
}
self.skel.bss().fallback_cpu = self.cpu_pool.fallback_cpu as u32;
self.skel.bss_mut().fallback_cpu = self.cpu_pool.fallback_cpu as u32;
for (lidx, layer) in self.layers.iter().enumerate() {
self.nr_layer_cpus_min_max[lidx] = (

View File

@ -13,15 +13,15 @@ clap = { version = "4.1", features = ["derive", "env", "unicode", "wrap_help"] }
ctrlc = { version = "3.1", features = ["termination"] }
fb_procfs = "0.7.0"
hex = "0.4.3"
libbpf-rs = "0.21.0"
libbpf-rs = "0.22.0"
libc = "0.2.137"
log = "0.4.17"
ordered-float = "3.4.0"
scx_utils = { path = "../../../rust/scx_utils", version = "0.3" }
scx_utils = { path = "../../../rust/scx_utils", version = "0.4" }
simplelog = "0.12.0"
[build-dependencies]
scx_utils = { path = "../../../rust/scx_utils", version = "0.3" }
scx_utils = { path = "../../../rust/scx_utils", version = "0.4" }
[features]
enable_backtrace = []

View File

@ -435,7 +435,7 @@ impl Tuner {
.read_stat()?
.cpus_map
.ok_or_else(|| anyhow!("Expected cpus_map to exist"))?;
let ti = &mut skel.bss().tune_input;
let ti = &mut skel.bss_mut().tune_input;
let mut dom_nr_cpus = vec![0; self.top.nr_doms];
let mut dom_util_sum = vec![0.0; self.top.nr_doms];
@ -629,7 +629,7 @@ impl<'a, 'b, 'c> LoadBalancer<'a, 'b, 'c> {
// XXX - We can't read task_ctx inline because self.skel.bss()
// borrows mutably and thus conflicts with self.skel.maps().
const MAX_PIDS: u64 = bpf_intf::consts_MAX_DOM_ACTIVE_PIDS as u64;
let active_pids = &mut self.skel.bss().dom_active_pids[dom as usize];
let active_pids = &mut self.skel.bss_mut().dom_active_pids[dom as usize];
let mut pids = vec![];
let (mut ridx, widx) = (active_pids.read_idx, active_pids.write_idx);
@ -910,16 +910,16 @@ impl<'a> Scheduler<'a> {
Topology::from_cache_level(opts.cache_level, nr_cpus)?
});
skel.rodata().nr_doms = top.nr_doms as u32;
skel.rodata().nr_cpus = top.nr_cpus as u32;
skel.rodata_mut().nr_doms = top.nr_doms as u32;
skel.rodata_mut().nr_cpus = top.nr_cpus as u32;
for (cpu, dom) in top.cpu_dom.iter().enumerate() {
skel.rodata().cpu_dom_id_map[cpu] = dom.unwrap_or(0) as u32;
skel.rodata_mut().cpu_dom_id_map[cpu] = dom.unwrap_or(0) as u32;
}
for (dom, cpus) in top.dom_cpus.iter().enumerate() {
let raw_cpus_slice = cpus.as_raw_slice();
let dom_cpumask_slice = &mut skel.rodata().dom_cpumasks[dom];
let dom_cpumask_slice = &mut skel.rodata_mut().dom_cpumasks[dom];
let (left, _) = dom_cpumask_slice.split_at_mut(raw_cpus_slice.len());
left.clone_from_slice(cpus.as_raw_slice());
info!(
@ -930,13 +930,13 @@ impl<'a> Scheduler<'a> {
);
}
skel.rodata().slice_ns = opts.slice_us * 1000;
skel.rodata().load_half_life = (opts.load_half_life * 1000000000.0) as u32;
skel.rodata().kthreads_local = opts.kthreads_local;
skel.rodata().fifo_sched = opts.fifo_sched;
skel.rodata().switch_partial = opts.partial;
skel.rodata().greedy_threshold = opts.greedy_threshold;
skel.rodata().debug = opts.verbose as u32;
skel.rodata_mut().slice_ns = opts.slice_us * 1000;
skel.rodata_mut().load_half_life = (opts.load_half_life * 1000000000.0) as u32;
skel.rodata_mut().kthreads_local = opts.kthreads_local;
skel.rodata_mut().fifo_sched = opts.fifo_sched;
skel.rodata_mut().switch_partial = opts.partial;
skel.rodata_mut().greedy_threshold = opts.greedy_threshold;
skel.rodata_mut().debug = opts.verbose as u32;
// Attach.
let mut skel = skel.load().context("Failed to load BPF program")?;