Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
fe13d43d e5f4afbe

+132 -6
+16
tools/perf/util/pmu.c
··· 31 31 32 32 struct perf_pmu perf_pmu__fake; 33 33 34 + /** 35 + * struct perf_pmu_format - Values from a format file read from 36 + * <sysfs>/devices/cpu/format/ held in struct perf_pmu. 37 + * 38 + * For example, the contents of <sysfs>/devices/cpu/format/event may be 39 + * "config:0-7" and will be represented here as name="event", 40 + * value=PERF_PMU_FORMAT_VALUE_CONFIG and bits 0 to 7 will be set. 41 + */ 34 42 struct perf_pmu_format { 43 + /** @name: The modifier/file name. */ 35 44 char *name; 45 + /** 46 + * @value : Which config value the format relates to. Supported values 47 + * are from PERF_PMU_FORMAT_VALUE_CONFIG to 48 + * PERF_PMU_FORMAT_VALUE_CONFIG_END. 49 + */ 36 50 int value; 51 + /** @bits: Which config bits are set by this format value. */ 37 52 DECLARE_BITMAP(bits, PERF_PMU_FORMAT_BITS); 53 + /** @list: Element on list within struct perf_pmu. */ 38 54 struct list_head list; 39 55 }; 40 56
+116 -6
tools/perf/util/pmu.h
··· 33 33 struct list_head list; 34 34 }; 35 35 36 + /** 37 + * struct perf_pmu - hi 38 + */ 36 39 struct perf_pmu { 40 + /** @name: The name of the PMU such as "cpu". */ 37 41 char *name; 42 + /** 43 + * @alias_name: Optional alternate name for the PMU determined in 44 + * architecture specific code. 45 + */ 38 46 char *alias_name; 47 + /** 48 + * @id: Optional PMU identifier read from 49 + * <sysfs>/bus/event_source/devices/<name>/identifier. 50 + */ 39 51 char *id; 52 + /** 53 + * @type: Perf event attributed type value, read from 54 + * <sysfs>/bus/event_source/devices/<name>/type. 55 + */ 40 56 __u32 type; 57 + /** 58 + * @selectable: Can the PMU name be selected as if it were an event? 59 + */ 41 60 bool selectable; 61 + /** 62 + * @is_uncore: Is the PMU not within the CPU core? Determined by the 63 + * presence of <sysfs>/bus/event_source/devices/<name>/cpumask. 64 + */ 42 65 bool is_uncore; 66 + /** 67 + * @auxtrace: Are events auxiliary events? Determined in architecture 68 + * specific code. 69 + */ 43 70 bool auxtrace; 71 + /** 72 + * @max_precise: Number of levels of :ppp precision supported by the 73 + * PMU, read from 74 + * <sysfs>/bus/event_source/devices/<name>/caps/max_precise. 75 + */ 44 76 int max_precise; 77 + /** 78 + * @default_config: Optional default perf_event_attr determined in 79 + * architecture specific code. 80 + */ 45 81 struct perf_event_attr *default_config; 82 + /** 83 + * @cpus: Empty or the contents of either of: 84 + * <sysfs>/bus/event_source/devices/<name>/cpumask. 85 + * <sysfs>/bus/event_source/devices/<cpu>/cpus. 86 + */ 46 87 struct perf_cpu_map *cpus; 47 - struct list_head format; /* HEAD struct perf_pmu_format -> list */ 48 - struct list_head aliases; /* HEAD struct perf_pmu_alias -> list */ 88 + /** 89 + * @format: Holds the contents of files read from 90 + * <sysfs>/bus/event_source/devices/<name>/format/. The contents specify 91 + * which event parameter changes what config, config1 or config2 bits. 92 + */ 93 + struct list_head format; 94 + /** 95 + * @aliases: List of struct perf_pmu_alias. Each alias corresponds to an 96 + * event read from <sysfs>/bus/event_source/devices/<name>/events/ or 97 + * from json events in pmu-events.c. 98 + */ 99 + struct list_head aliases; 100 + /** @caps_initialized: Has the list caps been initialized? */ 49 101 bool caps_initialized; 102 + /** @nr_caps: The length of the list caps. */ 50 103 u32 nr_caps; 51 - struct list_head caps; /* HEAD struct perf_pmu_caps -> list */ 52 - struct list_head list; /* ELEM */ 104 + /** 105 + * @caps: Holds the contents of files read from 106 + * <sysfs>/bus/event_source/devices/<name>/caps/. 107 + * 108 + * The contents are pairs of the filename with the value of its 109 + * contents, for example, max_precise (see above) may have a value of 3. 110 + */ 111 + struct list_head caps; 112 + /** @list: Element on pmus list in pmu.c. */ 113 + struct list_head list; 114 + /** @hybrid_list: Element on perf_pmu__hybrid_pmus. */ 53 115 struct list_head hybrid_list; 54 116 117 + /** 118 + * @missing_features: Features to inhibit when events on this PMU are 119 + * opened. 120 + */ 55 121 struct { 122 + /** 123 + * @exclude_guest: Disables perf_event_attr exclude_guest and 124 + * exclude_host. 125 + */ 56 126 bool exclude_guest; 57 127 } missing_features; 58 128 }; 59 129 130 + /** @perf_pmu__fake: A special global PMU used for testing. */ 60 131 extern struct perf_pmu perf_pmu__fake; 61 132 62 133 struct perf_pmu_info { ··· 141 70 142 71 #define UNIT_MAX_LEN 31 /* max length for event unit name */ 143 72 73 + /** 74 + * struct perf_pmu_alias - An event either read from sysfs or builtin in 75 + * pmu-events.c, created by parsing the pmu-events json files. 76 + */ 144 77 struct perf_pmu_alias { 78 + /** @name: Name of the event like "mem-loads". */ 145 79 char *name; 80 + /** @desc: Optional short description of the event. */ 146 81 char *desc; 82 + /** @long_desc: Optional long description. */ 147 83 char *long_desc; 84 + /** 85 + * @topic: Optional topic such as cache or pipeline, particularly for 86 + * json events. 87 + */ 148 88 char *topic; 89 + /** 90 + * @str: Comma separated parameter list like 91 + * "event=0xcd,umask=0x1,ldlat=0x3". 92 + */ 149 93 char *str; 150 - struct list_head terms; /* HEAD struct parse_events_term -> list */ 151 - struct list_head list; /* ELEM */ 94 + /** @terms: Owned list of the original parsed parameters. */ 95 + struct list_head terms; 96 + /** @list: List element of struct perf_pmu aliases. */ 97 + struct list_head list; 98 + /** @unit: Units for the event, such as bytes or cache lines. */ 152 99 char unit[UNIT_MAX_LEN+1]; 100 + /** @scale: Value to scale read counter values by. */ 153 101 double scale; 102 + /** 103 + * @per_pkg: Does the file 104 + * <sysfs>/bus/event_source/devices/<pmu_name>/events/<name>.per-pkg or 105 + * equivalent json value exist and have the value 1. 106 + */ 154 107 bool per_pkg; 108 + /** 109 + * @snapshot: Does the file 110 + * <sysfs>/bus/event_source/devices/<pmu_name>/events/<name>.snapshot 111 + * exist and have the value 1. 112 + */ 155 113 bool snapshot; 114 + /** 115 + * @deprecated: Is the event hidden and so not shown in perf list by 116 + * default. 117 + */ 156 118 bool deprecated; 119 + /** 120 + * @metric_expr: A metric expression associated with an event. Doing 121 + * this makes little sense due to scale and unit applying to both. 122 + */ 157 123 char *metric_expr; 124 + /** @metric_name: A name for the metric. unit applying to both. */ 158 125 char *metric_name; 126 + /** @pmu_name: The name copied from struct perf_pmu. */ 159 127 char *pmu_name; 160 128 }; 161 129