aya: expose run_time_ns and run_cnt fields in ProgramInfo

Added functions to expose run_time_ns & run_cnt statistics from
ProgramInfo/bpf_prog_info.
pull/979/head^2
tyrone-wu 11 months ago
parent ba51589b0d
commit 34c744c082
No known key found for this signature in database
GPG Key ID: 978B1A1B79210AD6

@ -1099,6 +1099,22 @@ impl ProgramInfo {
Ok(ProgramFd(fd))
}
/// The duration the program has been running, in nanoseconds.
///
/// Note this field is only updated for as long as [`BPF_ENABLE_STATS`](crate::Ebpf::enable_stats_fd)
/// is enabled with [`BPF_STATS_RUN_TIME`](aya_obj::BpfStatsType::RunTime) type set.
pub fn run_time_ns(&self) -> u64 {
self.0.run_time_ns
}
/// The number of times the program has ran.
///
/// Note this field is only updated for as long as [`BPF_ENABLE_STATS`](crate::Ebpf::enable_stats_fd)
/// is enabled with [`BPF_STATS_RUN_TIME`](aya_obj::BpfStatsType::RunTime) type set.
pub fn run_cnt(&self) -> u64 {
self.0.run_cnt
}
/// Loads a program from a pinned path in bpffs.
pub fn from_pin<P: AsRef<Path>>(path: P) -> Result<Self, ProgramError> {
use std::os::unix::ffi::OsStrExt as _;

@ -98,6 +98,8 @@ fn list_loaded_programs() {
prog.verified_instruction_count();
prog.loaded_at();
prog.fd().unwrap();
prog.run_time_ns();
prog.run_cnt();
}
#[test]

@ -7930,6 +7930,8 @@ pub fn aya::programs::ProgramInfo::memory_locked(&self) -> core::result::Result<
pub fn aya::programs::ProgramInfo::name(&self) -> &[u8]
pub fn aya::programs::ProgramInfo::name_as_str(&self) -> core::option::Option<&str>
pub fn aya::programs::ProgramInfo::program_type(&self) -> u32
pub fn aya::programs::ProgramInfo::run_cnt(&self) -> u64
pub fn aya::programs::ProgramInfo::run_time_ns(&self) -> u64
pub fn aya::programs::ProgramInfo::size_jitted(&self) -> u32
pub fn aya::programs::ProgramInfo::size_translated(&self) -> u32
pub fn aya::programs::ProgramInfo::tag(&self) -> u64

Loading…
Cancel
Save