HPCToolkit
perf_mmap.c File Reference
#include <assert.h>
#include <errno.h>
#include <sys/mman.h>
#include <string.h>
#include <unistd.h>
#include <linux/perf_event.h>
#include <linux/version.h>
#include <hpcrun/messages/messages.h>
#include "perf_mmap.h"
#include "perf-util.h"
#include "perf_barrier.h"
Include dependency graph for perf_mmap.c:

Go to the source code of this file.

Macros

#define MMAP_OFFSET_0   0
 
#define PERF_DATA_PAGE_EXP   1
 
#define PERF_DATA_PAGES   (1 << PERF_DATA_PAGE_EXP)
 
#define PERF_MMAP_SIZE(pagesz)   ((pagesz) * (PERF_DATA_PAGES + 1))
 
#define PERF_TAIL_MASK(pagesz)   (((pagesz) * PERF_DATA_PAGES) - 1)
 

Functions

static void skip_perf_data (pe_mmap_t *current_perf_mmap, size_t sz) __attribute__((unused))
 
static u64 perf_mmap_read_head (pe_mmap_t *hdr)
 
static int num_of_more_perf_data (pe_mmap_t *hdr)
 
static int has_more_perf_data (pe_mmap_t *hdr)
 
static int perf_read (pe_mmap_t *current_perf_mmap, void *buf, size_t bytes_wanted)
 
static int perf_read_header (pe_mmap_t *current_perf_mmap, pe_header_t *hdr)
 
static int perf_read_u32 (pe_mmap_t *current_perf_mmap, u32 *val)
 
static int perf_read_u64 (pe_mmap_t *current_perf_mmap, u64 *val)
 
static void handle_struct_read_format (pe_mmap_t *perf_mmap, int read_format)
 
static int perf_sample_callchain (pe_mmap_t *current_perf_mmap, perf_mmap_data_t *mmap_data)
 
static int parse_buffer (int sample_type, pe_mmap_t *current_perf_mmap, struct perf_event_attr *attr, perf_mmap_data_t *mmap_info)
 
int read_perf_buffer (pe_mmap_t *current_perf_mmap, struct perf_event_attr *attr, perf_mmap_data_t *mmap_info)
 
pe_mmap_tset_mmap (int perf_fd)
 
void perf_unmmap (pe_mmap_t *mmap)
 
void perf_mmap_init ()
 

Variables

static int pagesize = 0
 
static size_t tail_mask = 0
 

Macro Definition Documentation

◆ MMAP_OFFSET_0

#define MMAP_OFFSET_0   0

Definition at line 84 of file perf_mmap.c.

◆ PERF_DATA_PAGE_EXP

#define PERF_DATA_PAGE_EXP   1

Definition at line 86 of file perf_mmap.c.

◆ PERF_DATA_PAGES

#define PERF_DATA_PAGES   (1 << PERF_DATA_PAGE_EXP)

Definition at line 87 of file perf_mmap.c.

◆ PERF_MMAP_SIZE

#define PERF_MMAP_SIZE (   pagesz)    ((pagesz) * (PERF_DATA_PAGES + 1))

Definition at line 89 of file perf_mmap.c.

◆ PERF_TAIL_MASK

#define PERF_TAIL_MASK (   pagesz)    (((pagesz) * PERF_DATA_PAGES) - 1)

Definition at line 90 of file perf_mmap.c.

Function Documentation

◆ handle_struct_read_format()

static void handle_struct_read_format ( pe_mmap_t perf_mmap,
int  read_format 
)
static

Definition at line 228 of file perf_mmap.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ has_more_perf_data()

static int has_more_perf_data ( pe_mmap_t hdr)
static

Definition at line 140 of file perf_mmap.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ num_of_more_perf_data()

static int num_of_more_perf_data ( pe_mmap_t hdr)
static

Definition at line 130 of file perf_mmap.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_buffer()

static int parse_buffer ( int  sample_type,
pe_mmap_t current_perf_mmap,
struct perf_event_attr *  attr,
perf_mmap_data_t mmap_info 
)
static

parse mmapped buffer and copy the values into perf_mmap_data_t mmap_info. we assume mmap_info is already initialized. returns the number of read event attributes

Definition at line 319 of file perf_mmap.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ perf_mmap_init()

void perf_mmap_init ( )

initialize perf_mmap. caller needs to call this in the beginning before calling any API.

Definition at line 537 of file perf_mmap.c.

Here is the caller graph for this function:

◆ perf_mmap_read_head()

static u64 perf_mmap_read_head ( pe_mmap_t hdr)
static

Definition at line 119 of file perf_mmap.c.

Here is the caller graph for this function:

◆ perf_read()

static int perf_read ( pe_mmap_t current_perf_mmap,
void *  buf,
size_t  bytes_wanted 
)
static

Definition at line 151 of file perf_mmap.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ perf_read_header()

static int perf_read_header ( pe_mmap_t current_perf_mmap,
pe_header_t hdr 
)
inlinestatic

Definition at line 195 of file perf_mmap.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ perf_read_u32()

static int perf_read_u32 ( pe_mmap_t current_perf_mmap,
u32 val 
)
inlinestatic

Definition at line 205 of file perf_mmap.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ perf_read_u64()

static int perf_read_u64 ( pe_mmap_t current_perf_mmap,
u64 val 
)
inlinestatic

Definition at line 215 of file perf_mmap.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ perf_sample_callchain()

static int perf_sample_callchain ( pe_mmap_t current_perf_mmap,
perf_mmap_data_t mmap_data 
)
static

Definition at line 268 of file perf_mmap.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ perf_unmmap()

void perf_unmmap ( pe_mmap_t mmap)

Definition at line 527 of file perf_mmap.c.

Here is the caller graph for this function:

◆ read_perf_buffer()

int read_perf_buffer ( pe_mmap_t current_perf_mmap,
struct perf_event_attr *  attr,
perf_mmap_data_t mmap_info 
)

Definition at line 430 of file perf_mmap.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_mmap()

pe_mmap_t* set_mmap ( int  perf_fd)

Definition at line 498 of file perf_mmap.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ skip_perf_data()

static void skip_perf_data ( pe_mmap_t current_perf_mmap,
size_t  sz 
)
static

Definition at line 300 of file perf_mmap.c.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ pagesize

int pagesize = 0
static

Definition at line 108 of file perf_mmap.c.

◆ tail_mask

size_t tail_mask = 0
static

Definition at line 109 of file perf_mmap.c.