Skip to content
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
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion auraed/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ path = "src/bin/main.rs"
anyhow = { workspace = true }
client = { workspace = true }
aurae-ebpf-shared = { path = "../ebpf-shared" }
aya = { version = "0.13.1", features = ["async_tokio"] }
aya = { version = "0.13.1" }
backoff = { version = "0.4.0", features = ["tokio"] }
bytes = "1.2.1"
clap = { workspace = true }
Expand Down
21 changes: 15 additions & 6 deletions auraed/src/ebpf/perf_buffer_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
use anyhow::Context;
use aya::{
Ebpf,
maps::perf::AsyncPerfEventArray,
maps::perf::PerfEventArray,
util::{nr_cpus, online_cpus},
};
use bytes::BytesMut;
use procfs::page_size;
use std::mem::size_of;
use tokio::sync::broadcast;
use tokio::{
io::{Interest, unix::AsyncFd},
sync::broadcast,
};
use tracing::{error, trace};

use super::perf_event_broadcast::PerfEventBroadcast;
Expand Down Expand Up @@ -66,7 +69,7 @@ pub trait PerfBufferReader<T: Clone + Send + 'static> {
// kernel to userspace. This array contains the per-CPU buffers and is
// indexed by CPU id.
// https://libbpf.readthedocs.io/en/latest/api.html
let mut perf_array = AsyncPerfEventArray::try_from(
let mut perf_array = PerfEventArray::try_from(
bpf.take_map(perf_buffer)
.context("Failed to find '{perf_buffer}' perf event array")?,
)?;
Expand All @@ -81,8 +84,10 @@ pub trait PerfBufferReader<T: Clone + Send + 'static> {
for cpu_id in online_cpus {
trace!("spawning task for cpu {cpu_id}");
// Open the per-CPU buffer for the current CPU id
let mut per_cpu_buffer =
let per_cpu_buffer =
perf_array.open(cpu_id, Some(PER_CPU_BUFFER_SIZE_IN_PAGES))?;
let mut fd =
AsyncFd::with_interest(per_cpu_buffer, Interest::READABLE)?;

// Clone the sender of the event broadcast channel
let per_cpu_tx = tx.clone();
Expand All @@ -99,9 +104,13 @@ pub trait PerfBufferReader<T: Clone + Send + 'static> {

// Start polling the per-CPU buffer for events
loop {
let events = match per_cpu_buffer
.read_events(&mut buffers)
let mut guard = fd
.readable_mut()
.await
.expect("Failed to read from per-CPU event buffer");
let events = match guard
.get_inner_mut()
.read_events(&mut buffers)
{
Ok(events) => events,
Err(error) => {
Expand Down