Linux Perf
pmu.c File Reference
#include <linux/list.h>
#include <linux/compiler.h>
#include <sys/types.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdarg.h>
#include <dirent.h>
#include <api/fs/fs.h>
#include <locale.h>
#include <regex.h>
#include "util.h"
#include "pmu.h"
#include "parse-events.h"
#include "cpumap.h"
#include "header.h"
#include "pmu-events/pmu-events.h"
#include "cache.h"
#include "string2.h"
Include dependency graph for pmu.c:

Go to the source code of this file.

Classes

struct  perf_pmu_format
 
struct  sevent
 

Macros

#define EVENT_SOURCE_DEVICE_PATH   "/bus/event_source/devices/"
 
#define CPUS_TEMPLATE_UNCORE   "%s/bus/event_source/devices/%s/cpumask"
 
#define CPUS_TEMPLATE_CPU   "%s/bus/event_source/devices/%s/cpus"
 

Functions

int perf_pmu_parse (struct list_head *list, char *name)
 
static LIST_HEAD (pmus)
 
int perf_pmu__format_parse (char *dir, struct list_head *head)
 
static int pmu_format (const char *name, struct list_head *format)
 
static int convert_scale (const char *scale, char **end, double *sval)
 
static int perf_pmu__parse_scale (struct perf_pmu_alias *alias, char *dir, char *name)
 
static int perf_pmu__parse_unit (struct perf_pmu_alias *alias, char *dir, char *name)
 
static int perf_pmu__parse_per_pkg (struct perf_pmu_alias *alias, char *dir, char *name)
 
static int perf_pmu__parse_snapshot (struct perf_pmu_alias *alias, char *dir, char *name)
 
static int __perf_pmu__new_alias (struct list_head *list, char *dir, char *name, char *desc, char *val, char *long_desc, char *topic, char *unit, char *perpkg, char *metric_expr, char *metric_name)
 
static int perf_pmu__new_alias (struct list_head *list, char *dir, char *name, FILE *file)
 
static bool pmu_alias_info_file (char *name)
 
static int pmu_aliases_parse (char *dir, struct list_head *head)
 
static int pmu_aliases (const char *name, struct list_head *head)
 
static int pmu_alias_terms (struct perf_pmu_alias *alias, struct list_head *terms)
 
static int pmu_type (const char *name, __u32 *type)
 
static void pmu_read_sysfs (void)
 
static struct cpu_map__pmu_cpumask (const char *path)
 
static struct cpu_mappmu_cpumask (const char *name)
 
static bool pmu_is_uncore (const char *name)
 
static int is_arm_pmu_core (const char *name)
 
char *__weak get_cpuid_str (struct perf_pmu *pmu __maybe_unused)
 
int strcmp_cpuid_str (const char *mapcpuid, const char *cpuid)
 
static char * perf_pmu__getcpuid (struct perf_pmu *pmu)
 
struct pmu_events_mapperf_pmu__find_map (struct perf_pmu *pmu)
 
static void pmu_add_cpu_aliases (struct list_head *head, struct perf_pmu *pmu)
 
struct perf_event_attr *__weak perf_pmu__get_default_config (struct perf_pmu *pmu __maybe_unused)
 
static struct perf_pmupmu_lookup (const char *name)
 
static struct perf_pmupmu_find (const char *name)
 
struct perf_pmuperf_pmu__scan (struct perf_pmu *pmu)
 
struct perf_pmuperf_pmu__find (const char *name)
 
static struct perf_pmu_formatpmu_find_format (struct list_head *formats, const char *name)
 
__u64 perf_pmu__format_bits (struct list_head *formats, const char *name)
 
static void pmu_format_value (unsigned long *format, __u64 value, __u64 *v, bool zero)
 
static __u64 pmu_format_max_value (const unsigned long *format)
 
static int pmu_resolve_param_term (struct parse_events_term *term, struct list_head *head_terms, __u64 *value)
 
static char * pmu_formats_string (struct list_head *formats)
 
static int pmu_config_term (struct list_head *formats, struct perf_event_attr *attr, struct parse_events_term *term, struct list_head *head_terms, bool zero, struct parse_events_error *err)
 
int perf_pmu__config_terms (struct list_head *formats, struct perf_event_attr *attr, struct list_head *head_terms, bool zero, struct parse_events_error *err)
 
int perf_pmu__config (struct perf_pmu *pmu, struct perf_event_attr *attr, struct list_head *head_terms, struct parse_events_error *err)
 
static struct perf_pmu_aliaspmu_find_alias (struct perf_pmu *pmu, struct parse_events_term *term)
 
static int check_info_data (struct perf_pmu_alias *alias, struct perf_pmu_info *info)
 
int perf_pmu__check_alias (struct perf_pmu *pmu, struct list_head *head_terms, struct perf_pmu_info *info)
 
int perf_pmu__new_format (struct list_head *list, char *name, int config, unsigned long *bits)
 
void perf_pmu__set_format (unsigned long *bits, long from, long to)
 
static int sub_non_neg (int a, int b)
 
static char * format_alias (char *buf, int len, struct perf_pmu *pmu, struct perf_pmu_alias *alias)
 
static char * format_alias_or (char *buf, int len, struct perf_pmu *pmu, struct perf_pmu_alias *alias)
 
static int cmp_sevent (const void *a, const void *b)
 
static void wordwrap (char *s, int start, int max, int corr)
 
void print_pmu_events (const char *event_glob, bool name_only, bool quiet_flag, bool long_desc, bool details_flag)
 
bool pmu_have_event (const char *pname, const char *name)
 
static FILE * perf_pmu__open_file (struct perf_pmu *pmu, const char *name)
 
int perf_pmu__scan_file (struct perf_pmu *pmu, const char *name, const char *fmt,...)
 

Variables

FILE * perf_pmu_in
 

Macro Definition Documentation

◆ CPUS_TEMPLATE_CPU

#define CPUS_TEMPLATE_CPU   "%s/bus/event_source/devices/%s/cpus"

Definition at line 500 of file pmu.c.

◆ CPUS_TEMPLATE_UNCORE

#define CPUS_TEMPLATE_UNCORE   "%s/bus/event_source/devices/%s/cpumask"

Definition at line 499 of file pmu.c.

◆ EVENT_SOURCE_DEVICE_PATH

#define EVENT_SOURCE_DEVICE_PATH   "/bus/event_source/devices/"

Definition at line 32 of file pmu.c.

Function Documentation

◆ __perf_pmu__new_alias()

static int __perf_pmu__new_alias ( struct list_head *  list,
char *  dir,
char *  name,
char *  desc,
char *  val,
char *  long_desc,
char *  topic,
char *  unit,
char *  perpkg,
char *  metric_expr,
char *  metric_name 
)
static

Definition at line 237 of file pmu.c.

Here is the call graph for this function:

◆ __pmu_cpumask()

static struct cpu_map* __pmu_cpumask ( const char *  path)
static

Definition at line 481 of file pmu.c.

Here is the call graph for this function:

◆ check_info_data()

static int check_info_data ( struct perf_pmu_alias alias,
struct perf_pmu_info info 
)
static

Definition at line 1077 of file pmu.c.

◆ cmp_sevent()

static int cmp_sevent ( const void *  a,
const void *  b 
)
static

Definition at line 1239 of file pmu.c.

◆ convert_scale()

static int convert_scale ( const char *  scale,
char **  end,
double *  sval 
)
static

Definition at line 103 of file pmu.c.

Here is the call graph for this function:

◆ format_alias()

static char* format_alias ( char *  buf,
int  len,
struct perf_pmu pmu,
struct perf_pmu_alias alias 
)
static

Definition at line 1196 of file pmu.c.

Here is the call graph for this function:

◆ format_alias_or()

static char* format_alias_or ( char *  buf,
int  len,
struct perf_pmu pmu,
struct perf_pmu_alias alias 
)
static

Definition at line 1222 of file pmu.c.

◆ get_cpuid_str()

char* __weak get_cpuid_str ( struct perf_pmu *pmu  __maybe_unused)

Definition at line 575 of file pmu.c.

◆ is_arm_pmu_core()

static int is_arm_pmu_core ( const char *  name)
static

Definition at line 545 of file pmu.c.

◆ LIST_HEAD()

static LIST_HEAD ( pmus  )
static

◆ perf_pmu__check_alias()

int perf_pmu__check_alias ( struct perf_pmu pmu,
struct list_head *  head_terms,
struct perf_pmu_info info 
)

Definition at line 1106 of file pmu.c.

Here is the call graph for this function:

◆ perf_pmu__config()

int perf_pmu__config ( struct perf_pmu pmu,
struct perf_event_attr *  attr,
struct list_head *  head_terms,
struct parse_events_error err 
)

Definition at line 1035 of file pmu.c.

Here is the call graph for this function:

◆ perf_pmu__config_terms()

int perf_pmu__config_terms ( struct list_head *  formats,
struct perf_event_attr *  attr,
struct list_head *  head_terms,
bool  zero,
struct parse_events_error err 
)

Definition at line 1014 of file pmu.c.

Here is the call graph for this function:

◆ perf_pmu__find()

struct perf_pmu* perf_pmu__find ( const char *  name)

Definition at line 778 of file pmu.c.

Here is the call graph for this function:

◆ perf_pmu__find_map()

struct pmu_events_map* perf_pmu__find_map ( struct perf_pmu pmu)

Definition at line 628 of file pmu.c.

Here is the call graph for this function:

◆ perf_pmu__format_bits()

__u64 perf_pmu__format_bits ( struct list_head *  formats,
const char *  name 
)

Definition at line 806 of file pmu.c.

Here is the call graph for this function:

◆ perf_pmu__format_parse()

int perf_pmu__format_parse ( char *  dir,
struct list_head *  head 
)

Definition at line 43 of file pmu.c.

Here is the call graph for this function:

◆ perf_pmu__get_default_config()

struct perf_event_attr* __weak perf_pmu__get_default_config ( struct perf_pmu *pmu  __maybe_unused)

Definition at line 702 of file pmu.c.

◆ perf_pmu__getcpuid()

static char* perf_pmu__getcpuid ( struct perf_pmu pmu)
static

Definition at line 608 of file pmu.c.

Here is the call graph for this function:

◆ perf_pmu__new_alias()

static int perf_pmu__new_alias ( struct list_head *  list,
char *  dir,
char *  name,
FILE *  file 
)
static

Definition at line 295 of file pmu.c.

Here is the call graph for this function:

◆ perf_pmu__new_format()

int perf_pmu__new_format ( struct list_head *  list,
char *  name,
int  config,
unsigned long *  bits 
)

Definition at line 1160 of file pmu.c.

Here is the call graph for this function:

◆ perf_pmu__open_file()

static FILE* perf_pmu__open_file ( struct perf_pmu pmu,
const char *  name 
)
static

Definition at line 1412 of file pmu.c.

◆ perf_pmu__parse_per_pkg()

static int perf_pmu__parse_per_pkg ( struct perf_pmu_alias alias,
char *  dir,
char *  name 
)
static

Definition at line 203 of file pmu.c.

◆ perf_pmu__parse_scale()

static int perf_pmu__parse_scale ( struct perf_pmu_alias alias,
char *  dir,
char *  name 
)
static

Definition at line 140 of file pmu.c.

Here is the call graph for this function:

◆ perf_pmu__parse_snapshot()

static int perf_pmu__parse_snapshot ( struct perf_pmu_alias alias,
char *  dir,
char *  name 
)
static

Definition at line 220 of file pmu.c.

◆ perf_pmu__parse_unit()

static int perf_pmu__parse_unit ( struct perf_pmu_alias alias,
char *  dir,
char *  name 
)
static

Definition at line 172 of file pmu.c.

◆ perf_pmu__scan()

struct perf_pmu* perf_pmu__scan ( struct perf_pmu pmu)

Definition at line 763 of file pmu.c.

Here is the call graph for this function:

◆ perf_pmu__scan_file()

int perf_pmu__scan_file ( struct perf_pmu pmu,
const char *  name,
const char *  fmt,
  ... 
)

Definition at line 1431 of file pmu.c.

Here is the call graph for this function:

◆ perf_pmu__set_format()

void perf_pmu__set_format ( unsigned long *  bits,
long  from,
long  to 
)

Definition at line 1177 of file pmu.c.

Here is the call graph for this function:

◆ perf_pmu_parse()

int perf_pmu_parse ( struct list_head *  list,
char *  name 
)

◆ pmu_add_cpu_aliases()

static void pmu_add_cpu_aliases ( struct list_head *  head,
struct perf_pmu pmu 
)
static

Definition at line 660 of file pmu.c.

Here is the call graph for this function:

◆ pmu_alias_info_file()

static bool pmu_alias_info_file ( char *  name)
inlinestatic

Definition at line 310 of file pmu.c.

◆ pmu_alias_terms()

static int pmu_alias_terms ( struct perf_pmu_alias alias,
struct list_head *  terms 
)
static

Definition at line 396 of file pmu.c.

Here is the call graph for this function:

◆ pmu_aliases()

static int pmu_aliases ( const char *  name,
struct list_head *  head 
)
static

Definition at line 375 of file pmu.c.

Here is the call graph for this function:

◆ pmu_aliases_parse()

static int pmu_aliases_parse ( char *  dir,
struct list_head *  head 
)
static

Definition at line 331 of file pmu.c.

Here is the call graph for this function:

◆ pmu_config_term()

static int pmu_config_term ( struct list_head *  formats,
struct perf_event_attr *  attr,
struct parse_events_term term,
struct list_head *  head_terms,
bool  zero,
struct parse_events_error err 
)
static

Definition at line 908 of file pmu.c.

Here is the call graph for this function:

◆ pmu_cpumask()

static struct cpu_map* pmu_cpumask ( const char *  name)
static

Definition at line 502 of file pmu.c.

Here is the call graph for this function:

◆ pmu_find()

static struct perf_pmu* pmu_find ( const char *  name)
static

Definition at line 752 of file pmu.c.

◆ pmu_find_alias()

static struct perf_pmu_alias* pmu_find_alias ( struct perf_pmu pmu,
struct parse_events_term term 
)
static

Definition at line 1046 of file pmu.c.

Here is the call graph for this function:

◆ pmu_find_format()

static struct perf_pmu_format* pmu_find_format ( struct list_head *  formats,
const char *  name 
)
static

Definition at line 795 of file pmu.c.

◆ pmu_format()

static int pmu_format ( const char *  name,
struct list_head *  format 
)
static

Definition at line 82 of file pmu.c.

Here is the call graph for this function:

◆ pmu_format_max_value()

static __u64 pmu_format_max_value ( const unsigned long *  format)
static

Definition at line 842 of file pmu.c.

◆ pmu_format_value()

static void pmu_format_value ( unsigned long *  format,
__u64  value,
__u64 *  v,
bool  zero 
)
static

Definition at line 825 of file pmu.c.

◆ pmu_formats_string()

static char* pmu_formats_string ( struct list_head *  formats)
static

Definition at line 882 of file pmu.c.

Here is the call graph for this function:

◆ pmu_have_event()

bool pmu_have_event ( const char *  pname,
const char *  name 
)

Definition at line 1396 of file pmu.c.

Here is the call graph for this function:

◆ pmu_is_uncore()

static bool pmu_is_uncore ( const char *  name)
static

Definition at line 527 of file pmu.c.

Here is the call graph for this function:

◆ pmu_lookup()

static struct perf_pmu* pmu_lookup ( const char *  name)
static

Definition at line 707 of file pmu.c.

Here is the call graph for this function:

◆ pmu_read_sysfs()

static void pmu_read_sysfs ( void  )
static

Definition at line 454 of file pmu.c.

Here is the call graph for this function:

◆ pmu_resolve_param_term()

static int pmu_resolve_param_term ( struct parse_events_term term,
struct list_head *  head_terms,
__u64 *  value 
)
static

Definition at line 860 of file pmu.c.

◆ pmu_type()

static int pmu_type ( const char *  name,
__u32 *  type 
)
static

Definition at line 425 of file pmu.c.

◆ print_pmu_events()

void print_pmu_events ( const char *  event_glob,
bool  name_only,
bool  quiet_flag,
bool  long_desc,
bool  details_flag 
)

Definition at line 1277 of file pmu.c.

Here is the call graph for this function:

◆ strcmp_cpuid_str()

int strcmp_cpuid_str ( const char *  mapcpuid,
const char *  cpuid 
)

Definition at line 584 of file pmu.c.

◆ sub_non_neg()

static int sub_non_neg ( int  a,
int  b 
)
static

Definition at line 1189 of file pmu.c.

◆ wordwrap()

static void wordwrap ( char *  s,
int  start,
int  max,
int  corr 
)
static

Definition at line 1256 of file pmu.c.

Here is the call graph for this function:

Variable Documentation

◆ perf_pmu_in

FILE* perf_pmu_in