38#ifndef __CPU_KVM_PERFEVENT_HH__
39#define __CPU_KVM_PERFEVENT_HH__
41#include <linux/perf_event.h>
46#include "config/have_perf_attr_exclude_host.hh"
90 attr.sample_period = period;
103 attr.wakeup_events = events;
145#if HAVE_PERF_ATTR_EXCLUDE_HOST == 1
284 uint64_t
read()
const;
342 int fcntl(
int cmd,
long p1);
343 int fcntl(
int cmd,
void *p1) {
return fcntl(cmd, (
long)p1); }
356 int ioctl(
int request,
long p1);
357 int ioctl(
int request,
void *p1) {
return ioctl(request, (
long)p1); }
367 void read(
void *buf,
size_t size)
const;
PerfEvent counter configuration.
PerfKvmCounterConfig & samplePeriod(uint64_t period)
Set the initial sample period (overflow count) of an event.
struct perf_event_attr attr
Underlying perf_event_attr structure describing the counter.
PerfKvmCounterConfig & disabled(bool val)
Don't start the performance counter automatically when attaching it.
PerfKvmCounterConfig & exclude_host(bool val)
Exclude the events from the host (i.e., only include events from the guest system).
PerfKvmCounterConfig & exclude_hv(bool val)
Exclude the hyper visor (i.e., only include events from the guest system).
PerfKvmCounterConfig & pinned(bool val)
Force the group to be on the active all the time (i.e., disallow multiplexing).
PerfKvmCounterConfig & wakeupEvents(uint32_t events)
Set the number of samples that need to be triggered before reporting data as being available on the p...
PerfKvmCounterConfig(uint32_t type, uint64_t config)
Initialize PerfEvent counter configuration structure.
int ringNumPages
Total number of pages in ring buffer.
pid_t sysGettid()
Get the TID of the current thread.
void attach(PerfKvmCounterConfig &config, pid_t tid, const PerfKvmCounter &parent)
Attach a counter and make it a member of an existing counter group.
PerfKvmCounter(PerfKvmCounterConfig &config, pid_t tid)
Create and attach a new counter group.
int fcntl(int cmd, long p1)
PerfEvent fnctl interface.
void enableSignals(int signal)
Enable signal delivery on counter overflow.
void mmapPerf(int pages)
MMAP the PerfEvent file descriptor.
PerfKvmCounter()
Create a new counter, but don't attach it.
struct perf_event_mmap_page * ringBuffer
Memory mapped PerfEvent sample ring buffer.
long pageSize
Cached host page size.
void period(uint64_t period)
Update the period of an overflow counter.
uint64_t read() const
Read the current value of a counter.
int ioctl(int request, void *p1)
void attach(PerfKvmCounterConfig &config, pid_t tid)
Attach a counter.
int fd
PerfEvent file descriptor associated with counter.
void detach()
Detach a counter from PerfEvent.
int ioctl(int request, long p1)
PerfEvent ioctl interface.
bool attached() const
Check if a counter is attached.
PerfKvmCounter(const PerfKvmCounter &that)
void refresh(int refresh)
Enable a counter for a fixed number of events.
int fcntl(int cmd, void *p1)
PerfKvmCounter & operator=(const PerfKvmCounter &that)
void enableSignals(pid_t tid, int signal)
Enable signal delivery to a thread on counter overflow.
void start()
Start counting.
void stop()
Stop counting.
Copyright (c) 2024 Arm Limited All rights reserved.