From ef0d1253efcc5a385afc74668d4f28580d328822 Mon Sep 17 00:00:00 2001 From: Dave Tucker Date: Mon, 22 Jul 2024 10:52:13 +0100 Subject: [PATCH] fix(ebpf): Remove PerfEventArray::with_max_entries This API doesn't make sense as the max_entries needs to be set to the number of online CPUs by the loader. Signed-off-by: Dave Tucker --- ebpf/aya-ebpf/src/maps/perf/perf_event_array.rs | 10 +++------- ebpf/aya-ebpf/src/maps/perf/perf_event_byte_array.rs | 10 +++------- xtask/public-api/aya-ebpf.txt | 12 ++++-------- 3 files changed, 10 insertions(+), 22 deletions(-) diff --git a/ebpf/aya-ebpf/src/maps/perf/perf_event_array.rs b/ebpf/aya-ebpf/src/maps/perf/perf_event_array.rs index 6d0e51e8..18f8c995 100644 --- a/ebpf/aya-ebpf/src/maps/perf/perf_event_array.rs +++ b/ebpf/aya-ebpf/src/maps/perf/perf_event_array.rs @@ -17,16 +17,12 @@ unsafe impl Sync for PerfEventArray {} impl PerfEventArray { pub const fn new(flags: u32) -> PerfEventArray { - PerfEventArray::with_max_entries(0, flags) - } - - pub const fn with_max_entries(max_entries: u32, flags: u32) -> PerfEventArray { PerfEventArray { def: UnsafeCell::new(bpf_map_def { type_: BPF_MAP_TYPE_PERF_EVENT_ARRAY, key_size: mem::size_of::() as u32, value_size: mem::size_of::() as u32, - max_entries, + max_entries: 0, map_flags: flags, id: 0, pinning: PinningType::None as u32, @@ -35,13 +31,13 @@ impl PerfEventArray { } } - pub const fn pinned(max_entries: u32, flags: u32) -> PerfEventArray { + pub const fn pinned(flags: u32) -> PerfEventArray { PerfEventArray { def: UnsafeCell::new(bpf_map_def { type_: BPF_MAP_TYPE_PERF_EVENT_ARRAY, key_size: mem::size_of::() as u32, value_size: mem::size_of::() as u32, - max_entries, + max_entries: 0, map_flags: flags, id: 0, pinning: PinningType::ByName as u32, diff --git a/ebpf/aya-ebpf/src/maps/perf/perf_event_byte_array.rs b/ebpf/aya-ebpf/src/maps/perf/perf_event_byte_array.rs index f7cf75cf..2e08ea9c 100644 --- a/ebpf/aya-ebpf/src/maps/perf/perf_event_byte_array.rs +++ b/ebpf/aya-ebpf/src/maps/perf/perf_event_byte_array.rs @@ -16,16 +16,12 @@ unsafe impl Sync for PerfEventByteArray {} impl PerfEventByteArray { pub const fn new(flags: u32) -> PerfEventByteArray { - PerfEventByteArray::with_max_entries(0, flags) - } - - pub const fn with_max_entries(max_entries: u32, flags: u32) -> PerfEventByteArray { PerfEventByteArray { def: UnsafeCell::new(bpf_map_def { type_: BPF_MAP_TYPE_PERF_EVENT_ARRAY, key_size: mem::size_of::() as u32, value_size: mem::size_of::() as u32, - max_entries, + max_entries: 0, map_flags: flags, id: 0, pinning: PinningType::None as u32, @@ -33,13 +29,13 @@ impl PerfEventByteArray { } } - pub const fn pinned(max_entries: u32, flags: u32) -> PerfEventByteArray { + pub const fn pinned(flags: u32) -> PerfEventByteArray { PerfEventByteArray { def: UnsafeCell::new(bpf_map_def { type_: BPF_MAP_TYPE_PERF_EVENT_ARRAY, key_size: mem::size_of::() as u32, value_size: mem::size_of::() as u32, - max_entries, + max_entries: 0, map_flags: flags, id: 0, pinning: PinningType::ByName as u32, diff --git a/xtask/public-api/aya-ebpf.txt b/xtask/public-api/aya-ebpf.txt index 89e66bb5..6e8ff0b7 100644 --- a/xtask/public-api/aya-ebpf.txt +++ b/xtask/public-api/aya-ebpf.txt @@ -356,8 +356,7 @@ impl aya_ebpf::maps::PerfEventArray pub const fn aya_ebpf::maps::PerfEventArray::new(flags: u32) -> aya_ebpf::maps::PerfEventArray pub fn aya_ebpf::maps::PerfEventArray::output(&self, ctx: &C, data: &T, flags: u32) pub fn aya_ebpf::maps::PerfEventArray::output_at_index(&self, ctx: &C, index: u32, data: &T, flags: u32) -pub const fn aya_ebpf::maps::PerfEventArray::pinned(max_entries: u32, flags: u32) -> aya_ebpf::maps::PerfEventArray -pub const fn aya_ebpf::maps::PerfEventArray::with_max_entries(max_entries: u32, flags: u32) -> aya_ebpf::maps::PerfEventArray +pub const fn aya_ebpf::maps::PerfEventArray::pinned(flags: u32) -> aya_ebpf::maps::PerfEventArray impl core::marker::Sync for aya_ebpf::maps::PerfEventArray impl !core::marker::Freeze for aya_ebpf::maps::PerfEventArray impl core::marker::Send for aya_ebpf::maps::PerfEventArray where T: core::marker::Send @@ -385,8 +384,7 @@ impl aya_ebpf::maps::PerfEventByteArray pub const fn aya_ebpf::maps::PerfEventByteArray::new(flags: u32) -> aya_ebpf::maps::PerfEventByteArray pub fn aya_ebpf::maps::PerfEventByteArray::output(&self, ctx: &C, data: &[u8], flags: u32) pub fn aya_ebpf::maps::PerfEventByteArray::output_at_index(&self, ctx: &C, index: u32, data: &[u8], flags: u32) -pub const fn aya_ebpf::maps::PerfEventByteArray::pinned(max_entries: u32, flags: u32) -> aya_ebpf::maps::PerfEventByteArray -pub const fn aya_ebpf::maps::PerfEventByteArray::with_max_entries(max_entries: u32, flags: u32) -> aya_ebpf::maps::PerfEventByteArray +pub const fn aya_ebpf::maps::PerfEventByteArray::pinned(flags: u32) -> aya_ebpf::maps::PerfEventByteArray impl core::marker::Sync for aya_ebpf::maps::PerfEventByteArray impl !core::marker::Freeze for aya_ebpf::maps::PerfEventByteArray impl core::marker::Send for aya_ebpf::maps::PerfEventByteArray @@ -1085,8 +1083,7 @@ impl aya_ebpf::maps::PerfEventArray pub const fn aya_ebpf::maps::PerfEventArray::new(flags: u32) -> aya_ebpf::maps::PerfEventArray pub fn aya_ebpf::maps::PerfEventArray::output(&self, ctx: &C, data: &T, flags: u32) pub fn aya_ebpf::maps::PerfEventArray::output_at_index(&self, ctx: &C, index: u32, data: &T, flags: u32) -pub const fn aya_ebpf::maps::PerfEventArray::pinned(max_entries: u32, flags: u32) -> aya_ebpf::maps::PerfEventArray -pub const fn aya_ebpf::maps::PerfEventArray::with_max_entries(max_entries: u32, flags: u32) -> aya_ebpf::maps::PerfEventArray +pub const fn aya_ebpf::maps::PerfEventArray::pinned(flags: u32) -> aya_ebpf::maps::PerfEventArray impl core::marker::Sync for aya_ebpf::maps::PerfEventArray impl !core::marker::Freeze for aya_ebpf::maps::PerfEventArray impl core::marker::Send for aya_ebpf::maps::PerfEventArray where T: core::marker::Send @@ -1114,8 +1111,7 @@ impl aya_ebpf::maps::PerfEventByteArray pub const fn aya_ebpf::maps::PerfEventByteArray::new(flags: u32) -> aya_ebpf::maps::PerfEventByteArray pub fn aya_ebpf::maps::PerfEventByteArray::output(&self, ctx: &C, data: &[u8], flags: u32) pub fn aya_ebpf::maps::PerfEventByteArray::output_at_index(&self, ctx: &C, index: u32, data: &[u8], flags: u32) -pub const fn aya_ebpf::maps::PerfEventByteArray::pinned(max_entries: u32, flags: u32) -> aya_ebpf::maps::PerfEventByteArray -pub const fn aya_ebpf::maps::PerfEventByteArray::with_max_entries(max_entries: u32, flags: u32) -> aya_ebpf::maps::PerfEventByteArray +pub const fn aya_ebpf::maps::PerfEventByteArray::pinned(flags: u32) -> aya_ebpf::maps::PerfEventByteArray impl core::marker::Sync for aya_ebpf::maps::PerfEventByteArray impl !core::marker::Freeze for aya_ebpf::maps::PerfEventByteArray impl core::marker::Send for aya_ebpf::maps::PerfEventByteArray