aya: perf_map: fix bug when max_entries=0

When a perf map has max_entries=0, max_entries is dynamically set at
load time to the number of possible cpus as reported by
/sys/devices/system/cpu/possible.

This change fixes a bug where instead of setting max_entries to the
number of possible cpus, we were setting it to the cpu index of the last
possible cpu.
pull/1/head
Alessandro Decina 3 years ago
parent 3b7ffd0048
commit 4222b140ec

@ -117,13 +117,12 @@ impl Bpf {
for (_, mut obj) in obj.maps.drain() {
if obj.def.map_type == BPF_MAP_TYPE_PERF_EVENT_ARRAY as u32 && obj.def.max_entries == 0
{
obj.def.max_entries = *possible_cpus()
obj.def.max_entries = possible_cpus()
.map_err(|error| BpfError::FileError {
path: PathBuf::from(POSSIBLE_CPUS),
error,
})?
.last()
.unwrap_or(&0);
.len() as u32;
}
let mut map = Map { obj, fd: None };
let fd = map.create()?;

Loading…
Cancel
Save