perf pmu: Add data structure documentation

Add documentation to 'struct perf_pmu' and the associated structs of
'perf_pmu_alias' and 'perf_pmu_format'.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Caleb Biggers <caleb.biggers@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Perry Taylor <perry.taylor@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Rob Herring <robh@kernel.org>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Weilin Wang <weilin.wang@intel.com>
Cc: Xin Gao <gaoxin@cdjrlc.com>
Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Link: http://lore.kernel.org/lkml/20221114210723.2749751-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Ian Rogers 2022-11-14 13:07:15 -08:00 committed by Arnaldo Carvalho de Melo
parent e5f4afbe39
commit fe13d43d07
2 changed files with 132 additions and 6 deletions

View file

@ -31,10 +31,26 @@
struct perf_pmu perf_pmu__fake;
/**
* struct perf_pmu_format - Values from a format file read from
* <sysfs>/devices/cpu/format/ held in struct perf_pmu.
*
* For example, the contents of <sysfs>/devices/cpu/format/event may be
* "config:0-7" and will be represented here as name="event",
* value=PERF_PMU_FORMAT_VALUE_CONFIG and bits 0 to 7 will be set.
*/
struct perf_pmu_format {
/** @name: The modifier/file name. */
char *name;
/**
* @value : Which config value the format relates to. Supported values
* are from PERF_PMU_FORMAT_VALUE_CONFIG to
* PERF_PMU_FORMAT_VALUE_CONFIG_END.
*/
int value;
/** @bits: Which config bits are set by this format value. */
DECLARE_BITMAP(bits, PERF_PMU_FORMAT_BITS);
/** @list: Element on list within struct perf_pmu. */
struct list_head list;
};

View file

@ -33,30 +33,101 @@ struct perf_pmu_caps {
struct list_head list;
};
/**
* struct perf_pmu - hi
*/
struct perf_pmu {
/** @name: The name of the PMU such as "cpu". */
char *name;
/**
* @alias_name: Optional alternate name for the PMU determined in
* architecture specific code.
*/
char *alias_name;
/**
* @id: Optional PMU identifier read from
* <sysfs>/bus/event_source/devices/<name>/identifier.
*/
char *id;
/**
* @type: Perf event attributed type value, read from
* <sysfs>/bus/event_source/devices/<name>/type.
*/
__u32 type;
/**
* @selectable: Can the PMU name be selected as if it were an event?
*/
bool selectable;
/**
* @is_uncore: Is the PMU not within the CPU core? Determined by the
* presence of <sysfs>/bus/event_source/devices/<name>/cpumask.
*/
bool is_uncore;
/**
* @auxtrace: Are events auxiliary events? Determined in architecture
* specific code.
*/
bool auxtrace;
/**
* @max_precise: Number of levels of :ppp precision supported by the
* PMU, read from
* <sysfs>/bus/event_source/devices/<name>/caps/max_precise.
*/
int max_precise;
/**
* @default_config: Optional default perf_event_attr determined in
* architecture specific code.
*/
struct perf_event_attr *default_config;
/**
* @cpus: Empty or the contents of either of:
* <sysfs>/bus/event_source/devices/<name>/cpumask.
* <sysfs>/bus/event_source/devices/<cpu>/cpus.
*/
struct perf_cpu_map *cpus;
struct list_head format; /* HEAD struct perf_pmu_format -> list */
struct list_head aliases; /* HEAD struct perf_pmu_alias -> list */
/**
* @format: Holds the contents of files read from
* <sysfs>/bus/event_source/devices/<name>/format/. The contents specify
* which event parameter changes what config, config1 or config2 bits.
*/
struct list_head format;
/**
* @aliases: List of struct perf_pmu_alias. Each alias corresponds to an
* event read from <sysfs>/bus/event_source/devices/<name>/events/ or
* from json events in pmu-events.c.
*/
struct list_head aliases;
/** @caps_initialized: Has the list caps been initialized? */
bool caps_initialized;
/** @nr_caps: The length of the list caps. */
u32 nr_caps;
struct list_head caps; /* HEAD struct perf_pmu_caps -> list */
struct list_head list; /* ELEM */
/**
* @caps: Holds the contents of files read from
* <sysfs>/bus/event_source/devices/<name>/caps/.
*
* The contents are pairs of the filename with the value of its
* contents, for example, max_precise (see above) may have a value of 3.
*/
struct list_head caps;
/** @list: Element on pmus list in pmu.c. */
struct list_head list;
/** @hybrid_list: Element on perf_pmu__hybrid_pmus. */
struct list_head hybrid_list;
/**
* @missing_features: Features to inhibit when events on this PMU are
* opened.
*/
struct {
/**
* @exclude_guest: Disables perf_event_attr exclude_guest and
* exclude_host.
*/
bool exclude_guest;
} missing_features;
};
/** @perf_pmu__fake: A special global PMU used for testing. */
extern struct perf_pmu perf_pmu__fake;
struct perf_pmu_info {
@ -70,21 +141,60 @@ struct perf_pmu_info {
#define UNIT_MAX_LEN 31 /* max length for event unit name */
/**
* struct perf_pmu_alias - An event either read from sysfs or builtin in
* pmu-events.c, created by parsing the pmu-events json files.
*/
struct perf_pmu_alias {
/** @name: Name of the event like "mem-loads". */
char *name;
/** @desc: Optional short description of the event. */
char *desc;
/** @long_desc: Optional long description. */
char *long_desc;
/**
* @topic: Optional topic such as cache or pipeline, particularly for
* json events.
*/
char *topic;
/**
* @str: Comma separated parameter list like
* "event=0xcd,umask=0x1,ldlat=0x3".
*/
char *str;
struct list_head terms; /* HEAD struct parse_events_term -> list */
struct list_head list; /* ELEM */
/** @terms: Owned list of the original parsed parameters. */
struct list_head terms;
/** @list: List element of struct perf_pmu aliases. */
struct list_head list;
/** @unit: Units for the event, such as bytes or cache lines. */
char unit[UNIT_MAX_LEN+1];
/** @scale: Value to scale read counter values by. */
double scale;
/**
* @per_pkg: Does the file
* <sysfs>/bus/event_source/devices/<pmu_name>/events/<name>.per-pkg or
* equivalent json value exist and have the value 1.
*/
bool per_pkg;
/**
* @snapshot: Does the file
* <sysfs>/bus/event_source/devices/<pmu_name>/events/<name>.snapshot
* exist and have the value 1.
*/
bool snapshot;
/**
* @deprecated: Is the event hidden and so not shown in perf list by
* default.
*/
bool deprecated;
/**
* @metric_expr: A metric expression associated with an event. Doing
* this makes little sense due to scale and unit applying to both.
*/
char *metric_expr;
/** @metric_name: A name for the metric. unit applying to both. */
char *metric_name;
/** @pmu_name: The name copied from struct perf_pmu. */
char *pmu_name;
};