Skip to contentSkip to conversation

Hwmon PMUs

PATCH Superseded Ian Rogers 4 participants 18 messages Oct 22, 2024 – Oct 26, 2024 perf events

v6 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Ian Rogers

author reviewer
#0 lore raw

v6 cover Hwmon PMUs

Following the convention of the tool PMU, create a hwmon PMU that exposes hwmon data for reading. For example, the following shows reading the CPU temperature and 2 fan speeds alongside the uncore frequency:

```
$ perf stat -e temp_cpu,fan1,hwmon_thinkpad/fan2/,tool/num_cpus_online/ -M UNCORE_FREQ -I 1000
     1.001153138              52.00 'C   temp_cpu
     1.001153138              2,588 rpm  fan1
     1.001153138              2,482 rpm  hwmon_thinkpad/fan2/
     1.001153138                  8      tool/num_cpus_online/
     1.001153138      1,077,101,397      UNC_CLOCK.SOCKET                 #     1.08 UNCORE_FREQ
     1.001153138      1,012,773,595      duration_time
...
```

Additional data on the hwmon events is in perf list:

```
$ perf list
...
hwmon:
...
  temp_core_0 OR temp2
       [Temperature in unit coretemp named Core 0. crit=100'C,max=100'C crit_alarm=0'C. Unit:
        hwmon_coretemp]
...
```

v6: Add string.h #include for issue reported by kernel test robot.
v5: Fix asan issue in parse_hwmon_filename caught by a TMA metric.
v4: Drop merged patches 1 to 10. Separate adding the hwmon_pmu from
the update to perf_pmu to use it. Try to make source of literal strings clearer via named #defines. Fix a number of GCC warnings.
v3: Rebase, add Namhyung's acked-by to patches 1 to 10.
v2: Address Namhyung's review feedback. Rebase dropping 4 patches
applied by Arnaldo, fix build breakage reported by Arnaldo.

Ian Rogers (5):
tools api io: Ensure line_len_out is always initialized perf hwmon_pmu: Add a tool PMU exposing events from hwmon in sysfs perf pmu: Add calls enabling the hwmon_pmu
perf test: Add hwmon "PMU" test
perf docs: Document tool and hwmon events

 tools/lib/api/io.h                     |   1 +
 tools/perf/Documentation/perf-list.txt |  15 +
 tools/perf/tests/Build                 |   1 +
 tools/perf/tests/builtin-test.c        |   1 +
 tools/perf/tests/hwmon_pmu.c           | 243 ++++++++
 tools/perf/tests/tests.h               |   1 +
 tools/perf/util/Build                  |   1 +
 tools/perf/util/evsel.c                |   9 +
 tools/perf/util/hwmon_pmu.c            | 821 +++++++++++++++++++++++++
 tools/perf/util/hwmon_pmu.h            | 154 +++++
 tools/perf/util/pmu.c                  |  20 +
 tools/perf/util/pmu.h                  |   2 +
 tools/perf/util/pmus.c                 |   9 +
 tools/perf/util/pmus.h                 |   3 +
 14 files changed, 1281 insertions(+)
 create mode 100644 tools/perf/tests/hwmon_pmu.c
 create mode 100644 tools/perf/util/hwmon_pmu.c
 create mode 100644 tools/perf/util/hwmon_pmu.h
Signature · 1 line
2.47.0.163.g1226f6d8fa-goog
author reviewer
#1 lore raw

PATCH v6 1/5 tools api io: Ensure line_len_out is always initialized

Ensure initialization to avoid compiler warnings about potential use of uninitialized variables.

---
 tools/lib/api/io.h | 1 +
 1 file changed, 1 insertion(+)
tools/lib/api/io.h +1 -0
index d3eb04d1bc89..1731996b2c32 100644
@@ -189,6 +189,7 @@ static inline ssize_t io__getdelim(struct io *io, char **line_out, size_t *line_
 err_out:
 	free(line);
 	*line_out = NULL;
+	*line_len_out = 0;
 	return -ENOMEM;
 }
 
Signature · 1 line
2.47.0.163.g1226f6d8fa-goog
author reviewer
#2 lore raw

PATCH v6 2/5 perf hwmon_pmu: Add a tool PMU exposing events from hwmon in sysfs

In reply to Ian Rogers

Add a tool PMU for hwmon events but don't enable.

The hwmon sysfs ABI is defined in Documentation/hwmon/sysfs-interface.rst. Create a PMU that reads the hwmon input and can be used in perf stat and metrics much as an uncore PMU can.

For example, when enabled by a later patch, the following shows reading the CPU temperature and 2 fan speeds alongside the uncore frequency:

```
$ perf stat -e temp_cpu,fan1,hwmon_thinkpad/fan2/,tool/num_cpus_online/ -M UNCORE_FREQ -I 1000
     1.001153138              52.00 'C   temp_cpu
     1.001153138              2,588 rpm  fan1
     1.001153138              2,482 rpm  hwmon_thinkpad/fan2/
     1.001153138                  8      tool/num_cpus_online/
     1.001153138      1,077,101,397      UNC_CLOCK.SOCKET                 #     1.08 UNCORE_FREQ
     1.001153138      1,012,773,595      duration_time
...
```

The PMUs are named from /sys/class/hwmon/hwmon<num>/name and have an alias of hwmon<num>.

Hwmon data is presented in multiple <type><number>_<item> files. The <type><number> is used to identify the event as is the <type> followed by the contents of the <type>_label file if it exists. The <type><number>_input file gives the data read by perf.

When enabled by a later patch, in perf list the other hwmon <item> files are used to give a richer description, for example:

```
hwmon:
  temp1
       [Temperature in unit acpitz named temp1. Unit: hwmon_acpitz]
  in0
       [Voltage in unit bat0 named in0. Unit: hwmon_bat0]
  temp_core_0 OR temp2
       [Temperature in unit coretemp named Core 0. crit=100'C,max=100'C crit_alarm=0'C. Unit:
        hwmon_coretemp]
  temp_core_1 OR temp3
       [Temperature in unit coretemp named Core 1. crit=100'C,max=100'C crit_alarm=0'C. Unit:
        hwmon_coretemp]
...
  temp_package_id_0 OR temp1
       [Temperature in unit coretemp named Package id 0. crit=100'C,max=100'C crit_alarm=0'C.
        Unit: hwmon_coretemp]
  temp1
       [Temperature in unit iwlwifi_1 named temp1. Unit: hwmon_iwlwifi_1]
  temp_composite OR temp1
       [Temperature in unit nvme named Composite. alarm=0'C,crit=86.85'C,max=75.85'C,
        min=-273.15'C. Unit: hwmon_nvme]
  temp_sensor_1 OR temp2
       [Temperature in unit nvme named Sensor 1. max=65261.8'C,min=-273.15'C. Unit: hwmon_nvme]
  temp_sensor_2 OR temp3
       [Temperature in unit nvme named Sensor 2. max=65261.8'C,min=-273.15'C. Unit: hwmon_nvme]
  fan1
       [Fan in unit thinkpad named fan1. Unit: hwmon_thinkpad]
  fan2
       [Fan in unit thinkpad named fan2. Unit: hwmon_thinkpad]
...
  temp_cpu OR temp1
       [Temperature in unit thinkpad named CPU. Unit: hwmon_thinkpad]
  temp_gpu OR temp2
       [Temperature in unit thinkpad named GPU. Unit: hwmon_thinkpad]
  curr1
       [Current in unit ucsi_source_psy_usbc000_0 named curr1. max=1.5A. Unit:
        hwmon_ucsi_source_psy_usbc000_0]
  in0
       [Voltage in unit ucsi_source_psy_usbc000_0 named in0. max=5V,min=5V. Unit:
        hwmon_ucsi_source_psy_usbc000_0]
```

As there may be multiple hwmon devices a range of PMU types are reserved for their use and to identify the PMU as belonging to the hwmon types.

---
 tools/perf/util/Build       |   1 +
 tools/perf/util/hwmon_pmu.c | 821 ++++++++++++++++++++++++++++++++++++
 tools/perf/util/hwmon_pmu.h | 154 +++++++
 tools/perf/util/pmu.h       |   2 +
 4 files changed, 978 insertions(+)
 create mode 100644 tools/perf/util/hwmon_pmu.c
 create mode 100644 tools/perf/util/hwmon_pmu.h
tools/perf/util/Build +1 -0
index 1eedead5f2f2..78b990c04f71 100644
@@ -83,6 +83,7 @@ perf-util-y += pmu.o
 perf-util-y += pmus.o
 perf-util-y += pmu-flex.o
 perf-util-y += pmu-bison.o
+perf-util-y += hwmon_pmu.o
 perf-util-y += tool_pmu.o
 perf-util-y += svghelper.o
 perf-util-$(CONFIG_LIBTRACEEVENT) += trace-event-info.o
tools/perf/util/hwmon_pmu.c new file +821 -0

821 lines not on this page · raw message

tools/perf/util/hwmon_pmu.h new file +154 -0

154 lines not on this page · raw message

tools/perf/util/pmu.h +2 -0
index e400db9e9eb1..10f23f48479b 100644
@@ -37,6 +37,8 @@ struct perf_pmu_caps {
 };
 
 enum {
+	PERF_PMU_TYPE_HWMON_START = 0xFFFF0000,
+	PERF_PMU_TYPE_HWMON_END   = 0xFFFFFFFD,
 	PERF_PMU_TYPE_TOOL = 0xFFFFFFFE,
 	PERF_PMU_TYPE_FAKE = 0xFFFFFFFF,
 };
Signature · 1 line
2.47.0.163.g1226f6d8fa-goog
#3 lore raw

Re: [PATCH v6 2/5] perf hwmon_pmu: Add a tool PMU exposing events from hwmon in sysfs

kernel test robot noticed the following build errors:

Hi Ian,

kernel test robot noticed the following build errors:

[auto build test ERROR on perf-tools-next/perf-tools-next]
[also build test ERROR on next-20241024]
[cannot apply to tip/perf/core perf-tools/perf-tools linus/master acme/perf/core v6.12-rc4] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Ian-Rogers/tools-api-io-Ensure-line_len_out-is-always-initialized/20241023-020925
base:   https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git perf-tools-next
patch link:    https://lore.kernel.org/r/20241022180623.463131-3-irogers%40google.com
patch subject: [PATCH v6 2/5] perf hwmon_pmu: Add a tool PMU exposing events from hwmon in sysfs
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241025/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

Makefile.config:648: No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR

     PERF_VERSION = 6.12.rc3.g05bfa0ab5537
   util/hwmon_pmu.c: In function 'parse_hwmon_filename':
>> util/hwmon_pmu.c:176:9: error: implicit declaration of function 'strlcpy'; did you mean 'strncpy'? [-Werror=implicit-function-declaration]
     176 |         strlcpy(fn_type, filename, sizeof(fn_type));
         |         ^~~~~~~
         |         strncpy

cc1: all warnings being treated as errors
make[7]: *** [tools/build/Makefile.build:106: tools/perf/util/hwmon_pmu.o] Error 1 make[7]: *** Waiting for unfinished jobs....
make[6]: *** [tools/build/Makefile.build:158: util] Error 2
make[5]: *** [Makefile.perf:789: tools/perf/perf-util-in.o] Error 2 make[5]: *** Waiting for unfinished jobs....
make[4]: *** [Makefile.perf:292: sub-make] Error 2
make[3]: *** [Makefile:76: all] Error 2

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#4 lore raw

Re: [PATCH v6 2/5] perf hwmon_pmu: Add a tool PMU exposing events from hwmon in sysfs

In reply to Ian Rogers
kernel test robot noticed the following build errors:

Hi Ian,

kernel test robot noticed the following build errors:

[auto build test ERROR on perf-tools-next/perf-tools-next]
[also build test ERROR on next-20241024]
[cannot apply to tip/perf/core perf-tools/perf-tools linus/master acme/perf/core v6.12-rc4] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Ian-Rogers/tools-api-io-Ensure-line_len_out-is-always-initialized/20241023-020925
base:   https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git perf-tools-next
patch link:    https://lore.kernel.org/r/20241022180623.463131-3-irogers%40google.com
patch subject: [PATCH v6 2/5] perf hwmon_pmu: Add a tool PMU exposing events from hwmon in sysfs
compiler: clang version 19.1.2 (https://github.com/llvm/llvm-project 7ba7d8e2f7b6445b60679da826210cdde29eaf8b)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241025/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

Makefile.config:648: No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR

     PERF_VERSION = 6.12.rc3.g05bfa0ab5537
>> util/hwmon_pmu.c:176:2: error: call to undeclared library function 'strlcpy' with type 'unsigned long (char *, const char *, unsigned long)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     176 |         strlcpy(fn_type, filename, sizeof(fn_type));
         |         ^

util/hwmon_pmu.c:176:2: note: include the header <string.h> or explicitly provide a declaration for 'strlcpy' 1 error generated.
make[7]: *** [tools/build/Makefile.build:106: tools/perf/util/hwmon_pmu.o] Error 1
make[7]: *** Waiting for unfinished jobs....
make[6]: *** [tools/build/Makefile.build:158: util] Error 2
make[5]: *** [Makefile.perf:789: tools/perf/perf-util-in.o] Error 2
make[5]: *** Waiting for unfinished jobs....
make[4]: *** [Makefile.perf:292: sub-make] Error 2
make[3]: *** [Makefile:76: all] Error 2

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
author reviewer
#5 lore raw

PATCH v6 3/5 perf pmu: Add calls enabling the hwmon_pmu

In reply to Ian Rogers

Add the base PMU calls necessary for hwmon_pmu(s) to be created/deleted and events found, listed, opened and read.

---
 tools/perf/util/evsel.c |  9 +++++++++
 tools/perf/util/pmu.c   | 20 ++++++++++++++++++++
 tools/perf/util/pmus.c  |  2 ++
 3 files changed, 31 insertions(+)
tools/perf/util/evsel.c +9 -0
index 14663ad14c53..a1cbf82a9753 100644
@@ -55,6 +55,7 @@
 #include "off_cpu.h"
 #include "pmu.h"
 #include "pmus.h"
+#include "hwmon_pmu.h"
 #include "tool_pmu.h"
 #include "rlimit.h"
 #include "../perf-sys.h"
@@ -1801,6 +1802,9 @@ int evsel__read_counter(struct evsel *evsel, int cpu_map_idx, int thread)
 	if (evsel__is_tool(evsel))
 		return evsel__tool_pmu_read(evsel, cpu_map_idx, thread);
 
+	if (evsel__is_hwmon(evsel))
+		return evsel__hwmon_pmu_read(evsel, cpu_map_idx, thread);
+
 	if (evsel__is_retire_lat(evsel))
 		return evsel__read_retire_lat(evsel, cpu_map_idx, thread);
 
@@ -2246,6 +2250,11 @@ static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus,
 					    start_cpu_map_idx,
 					    end_cpu_map_idx);
 	}
+	if (evsel__is_hwmon(evsel)) {
+		return evsel__hwmon_pmu_open(evsel, threads,
+					     start_cpu_map_idx,
+					     end_cpu_map_idx);
+	}
 
 	for (idx = start_cpu_map_idx; idx < end_cpu_map_idx; idx++) {
 
tools/perf/util/pmu.c +20 -0
index 0789758598c0..a02df2c80f42 100644
@@ -18,6 +18,7 @@
 #include "debug.h"
 #include "evsel.h"
 #include "pmu.h"
+#include "hwmon_pmu.h"
 #include "pmus.h"
 #include "tool_pmu.h"
 #include <util/pmu-bison.h>
@@ -1529,6 +1530,9 @@ int perf_pmu__config_terms(const struct perf_pmu *pmu,
 {
 	struct parse_events_term *term;
 
+	if (perf_pmu__is_hwmon(pmu))
+		return hwmon_pmu__config_terms(pmu, attr, terms, err);
+
 	list_for_each_entry(term, &terms->terms, list) {
 		if (pmu_config_term(pmu, attr, term, terms, zero, apply_hardcoded, err))
 			return -EINVAL;
@@ -1661,6 +1665,11 @@ int perf_pmu__check_alias(struct perf_pmu *pmu, struct parse_events_terms *head_
 	info->scale    = 0.0;
 	info->snapshot = false;
 
+	if (perf_pmu__is_hwmon(pmu)) {
+		ret = hwmon_pmu__check_alias(head_terms, info, err);
+		goto out;
+	}
+
 	/* Fake PMU doesn't rewrite terms. */
 	if (perf_pmu__is_fake(pmu))
 		goto out;
@@ -1834,6 +1843,8 @@ bool perf_pmu__have_event(struct perf_pmu *pmu, const char *name)
 		return false;
 	if (perf_pmu__is_tool(pmu) && tool_pmu__skip_event(name))
 		return false;
+	if (perf_pmu__is_hwmon(pmu))
+		return hwmon_pmu__have_event(pmu, name);
 	if (perf_pmu__find_alias(pmu, name, /*load=*/ true) != NULL)
 		return true;
 	if (pmu->cpu_aliases_added || !pmu->events_table)
@@ -1845,6 +1856,9 @@ size_t perf_pmu__num_events(struct perf_pmu *pmu)
 {
 	size_t nr;
 
+	if (perf_pmu__is_hwmon(pmu))
+		return hwmon_pmu__num_events(pmu);
+
 	pmu_aliases_parse(pmu);
 	nr = pmu->sysfs_aliases + pmu->sys_json_aliases;
 
@@ -1908,6 +1922,9 @@ int perf_pmu__for_each_event(struct perf_pmu *pmu, bool skip_duplicate_pmus,
 	int ret = 0;
 	struct strbuf sb;
 
+	if (perf_pmu__is_hwmon(pmu))
+		return hwmon_pmu__for_each_event(pmu, state, cb);
+
 	strbuf_init(&sb, /*hint=*/ 0);
 	pmu_aliases_parse(pmu);
 	pmu_add_cpu_aliases(pmu);
@@ -2303,6 +2320,9 @@ int perf_pmu__pathname_fd(int dirfd, const char *pmu_name, const char *filename,
 
 void perf_pmu__delete(struct perf_pmu *pmu)
 {
+	if (perf_pmu__is_hwmon(pmu))
+		hwmon_pmu__exit(pmu);
+
 	perf_pmu__del_formats(&pmu->format);
 	perf_pmu__del_aliases(pmu);
 	perf_pmu__del_caps(pmu);
tools/perf/util/pmus.c +2 -0
index 107de86c2637..5c3e88adb9e6 100644
@@ -15,6 +15,7 @@
 #include "evsel.h"
 #include "pmus.h"
 #include "pmu.h"
+#include "hwmon_pmu.h"
 #include "tool_pmu.h"
 #include "print-events.h"
 #include "strbuf.h"
@@ -234,6 +235,7 @@ static void pmu_read_sysfs(bool core_only)
 	if (!core_only) {
 		tool_pmu = perf_pmus__tool_pmu();
 		list_add_tail(&tool_pmu->list, &other_pmus);
+		perf_pmus__read_hwmon_pmus(&other_pmus);
 	}
 	list_sort(NULL, &other_pmus, pmus_cmp);
 	if (!list_empty(&core_pmus)) {
Signature · 1 line
2.47.0.163.g1226f6d8fa-goog
author reviewer
#6 lore raw

PATCH v6 4/5 perf test: Add hwmon "PMU" test

In reply to Ian Rogers

Based on a mix of the sysfs PMU test (for creating the reference files) and the tool PMU test, test that parsing given hwmon events with there aliases creates the expected config values.

---
 tools/perf/tests/Build          |   1 +
 tools/perf/tests/builtin-test.c |   1 +
 tools/perf/tests/hwmon_pmu.c    | 243 ++++++++++++++++++++++++++++++++
 tools/perf/tests/tests.h        |   1 +
 tools/perf/util/pmus.c          |   7 +
 tools/perf/util/pmus.h          |   3 +
 6 files changed, 256 insertions(+)
 create mode 100644 tools/perf/tests/hwmon_pmu.c
tools/perf/tests/Build +1 -0
index 03cbdf7c50a0..f80bb46a9fc4 100644
@@ -66,6 +66,7 @@ perf-test-y += sigtrap.o
 perf-test-y += event_groups.o
 perf-test-y += symbols.o
 perf-test-y += util.o
+perf-test-y += hwmon_pmu.o
 perf-test-y += tool_pmu.o
 
 ifeq ($(SRCARCH),$(filter $(SRCARCH),x86 arm arm64 powerpc))
tools/perf/tests/builtin-test.c +1 -0
index 50533446e747..7a550a37f615 100644
@@ -73,6 +73,7 @@ static struct test_suite *generic_tests[] = {
 	&suite__PERF_RECORD,
 	&suite__pmu,
 	&suite__pmu_events,
+	&suite__hwmon_pmu,
 	&suite__tool_pmu,
 	&suite__dso_data,
 	&suite__perf_evsel__roundtrip_name_test,
tools/perf/tests/hwmon_pmu.c new file +243 -0

243 lines not on this page · raw message

tools/perf/tests/tests.h +1 -0
index 1ed76d4156b6..260daa77eb06 100644
@@ -83,6 +83,7 @@ DECLARE_SUITE(perf_evsel__tp_sched_test);
 DECLARE_SUITE(syscall_openat_tp_fields);
 DECLARE_SUITE(pmu);
 DECLARE_SUITE(pmu_events);
+DECLARE_SUITE(hwmon_pmu);
 DECLARE_SUITE(tool_pmu);
 DECLARE_SUITE(attr);
 DECLARE_SUITE(dso_data);
tools/perf/util/pmus.c +7 -0
index 5c3e88adb9e6..451c6e00ad70 100644
@@ -733,6 +733,13 @@ struct perf_pmu *perf_pmus__add_test_pmu(int test_sysfs_dirfd, const char *name)
 	return perf_pmu__lookup(&other_pmus, test_sysfs_dirfd, name, /*eager_load=*/true);
 }
 
+struct perf_pmu *perf_pmus__add_test_hwmon_pmu(int hwmon_dir,
+					       const char *sysfs_name,
+					       const char *name)
+{
+	return hwmon_pmu__new(&other_pmus, hwmon_dir, sysfs_name, name);
+}
+
 struct perf_pmu *perf_pmus__fake_pmu(void)
 {
 	static struct perf_pmu fake = {
tools/perf/util/pmus.h +3 -0
index e1742b56eec7..a0cb0eb2ff97 100644
@@ -30,6 +30,9 @@ bool perf_pmus__supports_extended_type(void);
 char *perf_pmus__default_pmu_name(void);
 
 struct perf_pmu *perf_pmus__add_test_pmu(int test_sysfs_dirfd, const char *name);
+struct perf_pmu *perf_pmus__add_test_hwmon_pmu(int hwmon_dir,
+					       const char *sysfs_name,
+					       const char *name);
 struct perf_pmu *perf_pmus__fake_pmu(void);
 
 #endif /* __PMUS_H */
Signature · 1 line
2.47.0.163.g1226f6d8fa-goog
#7 lore raw

Re: [PATCH v6 4/5] perf test: Add hwmon "PMU" test

kernel test robot noticed the following build errors:

Hi Ian,

kernel test robot noticed the following build errors:

[auto build test ERROR on perf-tools-next/perf-tools-next]
[also build test ERROR on next-20241025]
[cannot apply to tip/perf/core perf-tools/perf-tools linus/master acme/perf/core v6.12-rc4] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Ian-Rogers/tools-api-io-Ensure-line_len_out-is-always-initialized/20241023-020925
base:   https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git perf-tools-next
patch link:    https://lore.kernel.org/r/20241022180623.463131-5-irogers%40google.com
patch subject: [PATCH v6 4/5] perf test: Add hwmon "PMU" test
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241025/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

Makefile.config:648: No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR

     PERF_VERSION = 6.12.rc3.g57afdf292ab4
   tests/hwmon_pmu.c: In function 'do_test':
>> tests/hwmon_pmu.c:149:17: error: implicit declaration of function 'strlcpy'; did you mean 'strncpy'? [-Werror=implicit-function-declaration]
     149 |                 strlcpy(str, test_event, sizeof(str));
         |                 ^~~~~~~
         |                 strncpy
   cc1: all warnings being treated as errors
   make[7]: *** [tools/build/Makefile.build:105: tools/perf/tests/hwmon_pmu.o] Error 1
   make[7]: *** Waiting for unfinished jobs....
   util/hwmon_pmu.c: In function 'parse_hwmon_filename':
   util/hwmon_pmu.c:176:9: error: implicit declaration of function 'strlcpy'; did you mean 'strncpy'? [-Werror=implicit-function-declaration]
     176 |         strlcpy(fn_type, filename, sizeof(fn_type));
         |         ^~~~~~~
         |         strncpy

cc1: all warnings being treated as errors
make[7]: *** [tools/build/Makefile.build:105: tools/perf/util/hwmon_pmu.o] Error 1 make[7]: *** Waiting for unfinished jobs....
make[6]: *** [tools/build/Makefile.build:158: tests] Error 2 make[5]: *** [Makefile.perf:777: tools/perf/perf-test-in.o] Error 2 make[5]: *** Waiting for unfinished jobs....
make[6]: *** [tools/build/Makefile.build:158: util] Error 2
make[5]: *** [Makefile.perf:789: tools/perf/perf-util-in.o] Error 2 make[4]: *** [Makefile.perf:292: sub-make] Error 2
make[3]: *** [Makefile:76: all] Error 2

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
author reviewer
#8 lore raw

PATCH v6 5/5 perf docs: Document tool and hwmon events

In reply to Ian Rogers

Add a few paragraphs on tool and hwmon events.

---
 tools/perf/Documentation/perf-list.txt | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
tools/perf/Documentation/perf-list.txt +15 -0
index 14621f39b375..d0c65fad419a 100644
@@ -243,6 +243,21 @@ For accessing trace point events perf needs to have read access to
 /sys/kernel/tracing, even when perf_event_paranoid is in a relaxed
 setting.
 
+TOOL/HWMON EVENTS
+-----------------
+
+Some events don't have an associated PMU instead reading values
+available to software without perf_event_open. As these events don't
+support sampling they can only really be read by tools like perf stat.
+
+Tool events provide times and certain system parameters. Examples
+include duration_time, user_time, system_time and num_cpus_online.
+
+Hwmon events provide easy access to hwmon sysfs data typically in
+/sys/class/hwmon. This information includes temperatures, fan speeds
+and energy usage.
+
+
 TRACING
 -------
 
Signature · 1 line
2.47.0.163.g1226f6d8fa-goog
maintainer
#9 lore raw
In reply to Ian Rogers

Hi Ian,

Quoted 36 lines · Ian Rogers

Following the convention of the tool PMU, create a hwmon PMU that exposes hwmon data for reading. For example, the following shows reading the CPU temperature and 2 fan speeds alongside the uncore frequency:

```
$ perf stat -e temp_cpu,fan1,hwmon_thinkpad/fan2/,tool/num_cpus_online/ -M UNCORE_FREQ -I 1000
     1.001153138              52.00 'C   temp_cpu
     1.001153138              2,588 rpm  fan1
     1.001153138              2,482 rpm  hwmon_thinkpad/fan2/
     1.001153138                  8      tool/num_cpus_online/
     1.001153138      1,077,101,397      UNC_CLOCK.SOCKET                 #     1.08 UNCORE_FREQ
     1.001153138      1,012,773,595      duration_time
...
```

Additional data on the hwmon events is in perf list:

```
$ perf list
...
hwmon:
...
  temp_core_0 OR temp2
       [Temperature in unit coretemp named Core 0. crit=100'C,max=100'C crit_alarm=0'C. Unit:
        hwmon_coretemp]
...
```

v6: Add string.h #include for issue reported by kernel test robot.
v5: Fix asan issue in parse_hwmon_filename caught by a TMA metric.
v4: Drop merged patches 1 to 10. Separate adding the hwmon_pmu from
the update to perf_pmu to use it. Try to make source of literal strings clearer via named #defines. Fix a number of GCC warnings.
v3: Rebase, add Namhyung's acked-by to patches 1 to 10.
v2: Address Namhyung's review feedback. Rebase dropping 4 patches
applied by Arnaldo, fix build breakage reported by Arnaldo.

Quoted 6 lines

Ian Rogers (5):
tools api io: Ensure line_len_out is always initialized perf hwmon_pmu: Add a tool PMU exposing events from hwmon in sysfs perf pmu: Add calls enabling the hwmon_pmu
perf test: Add hwmon "PMU" test
perf docs: Document tool and hwmon events

I think the patch 2 can be easily splitted into core and other parts like dealing with aliases and units. I believe it'd be helpful for others (like me) to understand how it works.

Please take a look at 'perf/hwmon-pmu' branch in:

https://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git

Thanks,
Namhyung

Quoted 23 lines
 tools/lib/api/io.h                     |   1 +
 tools/perf/Documentation/perf-list.txt |  15 +
 tools/perf/tests/Build                 |   1 +
 tools/perf/tests/builtin-test.c        |   1 +
 tools/perf/tests/hwmon_pmu.c           | 243 ++++++++
 tools/perf/tests/tests.h               |   1 +
 tools/perf/util/Build                  |   1 +
 tools/perf/util/evsel.c                |   9 +
 tools/perf/util/hwmon_pmu.c            | 821 +++++++++++++++++++++++++
 tools/perf/util/hwmon_pmu.h            | 154 +++++
 tools/perf/util/pmu.c                  |  20 +
 tools/perf/util/pmu.h                  |   2 +
 tools/perf/util/pmus.c                 |   9 +
 tools/perf/util/pmus.h                 |   3 +
 14 files changed, 1281 insertions(+)
 create mode 100644 tools/perf/tests/hwmon_pmu.c
 create mode 100644 tools/perf/util/hwmon_pmu.c
 create mode 100644 tools/perf/util/hwmon_pmu.h
Signature · 1 line
2.47.0.163.g1226f6d8fa-goog
author reviewer
#10 lore raw
Quoted 47 lines · Namhyung Kim

Hi Ian,

Quoted 36 lines · Ian Rogers

Following the convention of the tool PMU, create a hwmon PMU that exposes hwmon data for reading. For example, the following shows reading the CPU temperature and 2 fan speeds alongside the uncore frequency:

```
$ perf stat -e temp_cpu,fan1,hwmon_thinkpad/fan2/,tool/num_cpus_online/ -M UNCORE_FREQ -I 1000
     1.001153138              52.00 'C   temp_cpu
     1.001153138              2,588 rpm  fan1
     1.001153138              2,482 rpm  hwmon_thinkpad/fan2/
     1.001153138                  8      tool/num_cpus_online/
     1.001153138      1,077,101,397      UNC_CLOCK.SOCKET                 #     1.08 UNCORE_FREQ
     1.001153138      1,012,773,595      duration_time
...
```

Additional data on the hwmon events is in perf list:

```
$ perf list
...
hwmon:
...
  temp_core_0 OR temp2
       [Temperature in unit coretemp named Core 0. crit=100'C,max=100'C crit_alarm=0'C. Unit:
        hwmon_coretemp]
...
```

v6: Add string.h #include for issue reported by kernel test robot.
v5: Fix asan issue in parse_hwmon_filename caught by a TMA metric.
v4: Drop merged patches 1 to 10. Separate adding the hwmon_pmu from
the update to perf_pmu to use it. Try to make source of literal strings clearer via named #defines. Fix a number of GCC warnings.
v3: Rebase, add Namhyung's acked-by to patches 1 to 10.
v2: Address Namhyung's review feedback. Rebase dropping 4 patches
applied by Arnaldo, fix build breakage reported by Arnaldo.

Quoted 6 lines

Ian Rogers (5):
tools api io: Ensure line_len_out is always initialized perf hwmon_pmu: Add a tool PMU exposing events from hwmon in sysfs perf pmu: Add calls enabling the hwmon_pmu
perf test: Add hwmon "PMU" test
perf docs: Document tool and hwmon events

Quoted 7 lines

I think the patch 2 can be easily splitted into core and other parts like dealing with aliases and units. I believe it'd be helpful for others (like me) to understand how it works.

Please take a look at 'perf/hwmon-pmu' branch in:

https://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git

Thanks Namhyung but I'm not really seeing this making anything simpler and I can see significant new bugs. Your new patch:
https://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git/commit/?h=perf/hwmon-pmu&id=85c78b5bf71fb3e67ae815f7b2d044648fa08391
Has taken about 40% out of patch 2, but done so by splitting function declarations from their definitions, enum declarations from any use, etc. It also adds in code like:

snprintf(buf, sizeof(buf), "%s_input", evsel->name);

but this would be a strange thing to do. The evsel->name is rewritten by fallback logic, so cycles may become cycles:u if kernel profiling is restricted. This is why we have metric-id in the evsel as we cannot rely on the evsel->name not mutating when looking up events for the sake of metrics. Using the name as part of a sysfs filename lookup doesn't make sense to me as now the evsel fallback logic can break a hwmon event. In the original patch the code was:

snprintf(buf, sizeof(buf), "%s%d_input", hwmon_type_strs[key.type], key.num);

where those two values are constants and key.type and key.num both values embedded in the config value the evsel fallback logic won't change. But bringing in the code that does that basically brings in all of the rest of patch 2.

So the patch is adding a PMU that looks broken, so rather than simplifying things it just creates a broken intermediate state and should that be fixed for the benefit of bisects?
It also complicates understanding as the declarations of functions and enums have kernel-doc, but now the definitions of enums and functions are split apart. For me, to understand the code I'd want to squash the patches back together again so I could see a declaration with its definition.

Thanks,
Ian

maintainer
#11 lore raw
Quoted 54 lines · Ian Rogers
Quoted 53 lines · Namhyung Kim

Hi Ian,

Quoted 36 lines · Ian Rogers

Following the convention of the tool PMU, create a hwmon PMU that exposes hwmon data for reading. For example, the following shows reading the CPU temperature and 2 fan speeds alongside the uncore frequency:

```
$ perf stat -e temp_cpu,fan1,hwmon_thinkpad/fan2/,tool/num_cpus_online/ -M UNCORE_FREQ -I 1000
     1.001153138              52.00 'C   temp_cpu
     1.001153138              2,588 rpm  fan1
     1.001153138              2,482 rpm  hwmon_thinkpad/fan2/
     1.001153138                  8      tool/num_cpus_online/
     1.001153138      1,077,101,397      UNC_CLOCK.SOCKET                 #     1.08 UNCORE_FREQ
     1.001153138      1,012,773,595      duration_time
...
```

Additional data on the hwmon events is in perf list:

```
$ perf list
...
hwmon:
...
  temp_core_0 OR temp2
       [Temperature in unit coretemp named Core 0. crit=100'C,max=100'C crit_alarm=0'C. Unit:
        hwmon_coretemp]
...
```

v6: Add string.h #include for issue reported by kernel test robot.
v5: Fix asan issue in parse_hwmon_filename caught by a TMA metric.
v4: Drop merged patches 1 to 10. Separate adding the hwmon_pmu from
the update to perf_pmu to use it. Try to make source of literal strings clearer via named #defines. Fix a number of GCC warnings.
v3: Rebase, add Namhyung's acked-by to patches 1 to 10.
v2: Address Namhyung's review feedback. Rebase dropping 4 patches
applied by Arnaldo, fix build breakage reported by Arnaldo.

Quoted 6 lines

Ian Rogers (5):
tools api io: Ensure line_len_out is always initialized perf hwmon_pmu: Add a tool PMU exposing events from hwmon in sysfs perf pmu: Add calls enabling the hwmon_pmu
perf test: Add hwmon "PMU" test
perf docs: Document tool and hwmon events

I think the patch 2 can be easily splitted into core and other parts like dealing with aliases and units. I believe it'd be helpful for others (like me) to understand how it works.

Please take a look at 'perf/hwmon-pmu' branch in:

Quoted 7 lines
Quoted 1 line

https://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git

Thanks Namhyung but I'm not really seeing this making anything simpler and I can see significant new bugs. Your new patch:
https://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git/commit/?h=perf/hwmon-pmu&id=85c78b5bf71fb3e67ae815f7b2d044648fa08391
Has taken about 40% out of patch 2, but done so by splitting function declarations from their definitions, enum declarations from any use,

Yeah, it's just because I was lazy and you can split header files too (and please do so).

Quoted 6 lines

etc. It also adds in code like:

snprintf(buf, sizeof(buf), "%s_input", evsel->name);

but this would be a strange thing to do. The evsel->name is rewritten by fallback logic, so cycles may become cycles:u if kernel profiling

I know it doesn't work but just want to highlight how it's supposed to work. Eventually what we need is a correct file name. In fact, I think it'd work if we can pass a correct event name probably like:

perf stat -e hwmon5/name=fan1/ true

Quoted 5 lines

is restricted. This is why we have metric-id in the evsel as we cannot rely on the evsel->name not mutating when looking up events for the sake of metrics. Using the name as part of a sysfs filename lookup doesn't make sense to me as now the evsel fallback logic can break a hwmon event. In the original patch the code was:

The fallback logic is used only if the kernel returns an error. Thus it'd be fine as long as it correctly finds the sysfs filename. But it's not used in the final code and the change is a simple one-liner.

Quoted 7 lines

snprintf(buf, sizeof(buf), "%s%d_input", hwmon_type_strs[key.type], key.num);

where those two values are constants and key.type and key.num both values embedded in the config value the evsel fallback logic won't change. But bringing in the code that does that basically brings in all of the rest of patch 2.

Right, that's why I did that way.

Quoted 4 lines

So the patch is adding a PMU that looks broken, so rather than simplifying things it just creates a broken intermediate state and should that be fixed for the benefit of bisects?

Actually it's not broken since it's not enabled yet. :)

Quoted 5 lines

It also complicates understanding as the declarations of functions and enums have kernel-doc, but now the definitions of enums and functions are split apart. For me, to understand the code I'd want to squash the patches back together again so I could see a declaration with its definition.

Yep, please move the declarations to the patch 3.

Thanks,
Namhyung

author reviewer
#12 lore raw
Quoted 71 lines · Namhyung Kim
Quoted 54 lines · Ian Rogers
Quoted 53 lines · Namhyung Kim

Hi Ian,

Quoted 36 lines · Ian Rogers

Following the convention of the tool PMU, create a hwmon PMU that exposes hwmon data for reading. For example, the following shows reading the CPU temperature and 2 fan speeds alongside the uncore frequency:

```
$ perf stat -e temp_cpu,fan1,hwmon_thinkpad/fan2/,tool/num_cpus_online/ -M UNCORE_FREQ -I 1000
     1.001153138              52.00 'C   temp_cpu
     1.001153138              2,588 rpm  fan1
     1.001153138              2,482 rpm  hwmon_thinkpad/fan2/
     1.001153138                  8      tool/num_cpus_online/
     1.001153138      1,077,101,397      UNC_CLOCK.SOCKET                 #     1.08 UNCORE_FREQ
     1.001153138      1,012,773,595      duration_time
...
```

Additional data on the hwmon events is in perf list:

```
$ perf list
...
hwmon:
...
  temp_core_0 OR temp2
       [Temperature in unit coretemp named Core 0. crit=100'C,max=100'C crit_alarm=0'C. Unit:
        hwmon_coretemp]
...
```

v6: Add string.h #include for issue reported by kernel test robot.
v5: Fix asan issue in parse_hwmon_filename caught by a TMA metric.
v4: Drop merged patches 1 to 10. Separate adding the hwmon_pmu from
the update to perf_pmu to use it. Try to make source of literal strings clearer via named #defines. Fix a number of GCC warnings.
v3: Rebase, add Namhyung's acked-by to patches 1 to 10.
v2: Address Namhyung's review feedback. Rebase dropping 4 patches
applied by Arnaldo, fix build breakage reported by Arnaldo.

Quoted 6 lines

Ian Rogers (5):
tools api io: Ensure line_len_out is always initialized perf hwmon_pmu: Add a tool PMU exposing events from hwmon in sysfs perf pmu: Add calls enabling the hwmon_pmu
perf test: Add hwmon "PMU" test
perf docs: Document tool and hwmon events

I think the patch 2 can be easily splitted into core and other parts like dealing with aliases and units. I believe it'd be helpful for others (like me) to understand how it works.

Please take a look at 'perf/hwmon-pmu' branch in:

Quoted 7 lines
Quoted 1 line

https://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git

Thanks Namhyung but I'm not really seeing this making anything simpler and I can see significant new bugs. Your new patch:
https://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git/commit/?h=perf/hwmon-pmu&id=85c78b5bf71fb3e67ae815f7b2d044648fa08391
Has taken about 40% out of patch 2, but done so by splitting function declarations from their definitions, enum declarations from any use,

Yeah, it's just because I was lazy and you can split header files too (and please do so).

Quoted 4 lines

etc. It also adds in code like:

snprintf(buf, sizeof(buf), "%s_input", evsel->name);

Quoted 8 lines
Quoted 2 lines

but this would be a strange thing to do. The evsel->name is rewritten by fallback logic, so cycles may become cycles:u if kernel profiling

I know it doesn't work but just want to highlight how it's supposed to work. Eventually what we need is a correct file name. In fact, I think it'd work if we can pass a correct event name probably like:

perf stat -e hwmon5/name=fan1/ true

But this isn't what the term name and evsel's name are for. They are to allow you to do:

```
$ perf stat -e cycles/name=foobar/ true

Performance counter stats for 'true':

        1,126,942      foobar

      0.001681805 seconds time elapsed

      0.001757000 seconds user
      0.000000000 seconds sys
```

Why would you do this in code, change a fundamental of evsel behavior, then just to delete it in the next patch?

Quoted 9 lines
Quoted 5 lines

is restricted. This is why we have metric-id in the evsel as we cannot rely on the evsel->name not mutating when looking up events for the sake of metrics. Using the name as part of a sysfs filename lookup doesn't make sense to me as now the evsel fallback logic can break a hwmon event. In the original patch the code was:

The fallback logic is used only if the kernel returns an error. Thus it'd be fine as long as it correctly finds the sysfs filename. But it's not used in the final code and the change is a simple one-liner.

But it's not. It's changing what evsel->name means to be an event encoding. How does reverse config to name lookup work in this model? How does the normal use of the name term work?

Quoted 18 lines
Quoted 7 lines

snprintf(buf, sizeof(buf), "%s%d_input", hwmon_type_strs[key.type], key.num);

where those two values are constants and key.type and key.num both values embedded in the config value the evsel fallback logic won't change. But bringing in the code that does that basically brings in all of the rest of patch 2.

Right, that's why I did that way.

Quoted 4 lines

So the patch is adding a PMU that looks broken, so rather than simplifying things it just creates a broken intermediate state and should that be fixed for the benefit of bisects?

Actually it's not broken since it's not enabled yet. :)

Quoted 7 lines
Quoted 5 lines

It also complicates understanding as the declarations of functions and enums have kernel-doc, but now the definitions of enums and functions are split apart. For me, to understand the code I'd want to squash the patches back together again so I could see a declaration with its definition.

Yep, please move the declarations to the patch 3.

So I think moving the enum declarations into one patch is okay. But as the enum values have no bearing on hardware constants, or something outside of the code that uses them it smells strange to me. Ultimately this is going to do little to the lines of code count but damage readability. I'm not sure why we're doing this given the kernel model for adding a driver is to add it as a large chunk. For example, here is adding the intel PT driver:
https://lore.kernel.org/all/1422614392-114498-1-git-send-email-alexander.shishkin@linux.intel.com/T/#u

Thanks,
Ian

maintainer
#13 lore raw
Quoted 95 lines · Ian Rogers
Quoted 71 lines · Namhyung Kim
Quoted 54 lines · Ian Rogers
Quoted 53 lines · Namhyung Kim

Hi Ian,

Quoted 36 lines · Ian Rogers

Following the convention of the tool PMU, create a hwmon PMU that exposes hwmon data for reading. For example, the following shows reading the CPU temperature and 2 fan speeds alongside the uncore frequency:

```
$ perf stat -e temp_cpu,fan1,hwmon_thinkpad/fan2/,tool/num_cpus_online/ -M UNCORE_FREQ -I 1000
     1.001153138              52.00 'C   temp_cpu
     1.001153138              2,588 rpm  fan1
     1.001153138              2,482 rpm  hwmon_thinkpad/fan2/
     1.001153138                  8      tool/num_cpus_online/
     1.001153138      1,077,101,397      UNC_CLOCK.SOCKET                 #     1.08 UNCORE_FREQ
     1.001153138      1,012,773,595      duration_time
...
```

Additional data on the hwmon events is in perf list:

```
$ perf list
...
hwmon:
...
  temp_core_0 OR temp2
       [Temperature in unit coretemp named Core 0. crit=100'C,max=100'C crit_alarm=0'C. Unit:
        hwmon_coretemp]
...
```

v6: Add string.h #include for issue reported by kernel test robot.
v5: Fix asan issue in parse_hwmon_filename caught by a TMA metric.
v4: Drop merged patches 1 to 10. Separate adding the hwmon_pmu from
the update to perf_pmu to use it. Try to make source of literal strings clearer via named #defines. Fix a number of GCC warnings.
v3: Rebase, add Namhyung's acked-by to patches 1 to 10.
v2: Address Namhyung's review feedback. Rebase dropping 4 patches
applied by Arnaldo, fix build breakage reported by Arnaldo.

Quoted 6 lines

Ian Rogers (5):
tools api io: Ensure line_len_out is always initialized perf hwmon_pmu: Add a tool PMU exposing events from hwmon in sysfs perf pmu: Add calls enabling the hwmon_pmu
perf test: Add hwmon "PMU" test
perf docs: Document tool and hwmon events

I think the patch 2 can be easily splitted into core and other parts like dealing with aliases and units. I believe it'd be helpful for others (like me) to understand how it works.

Please take a look at 'perf/hwmon-pmu' branch in:

Quoted 7 lines
Quoted 1 line

https://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git

Thanks Namhyung but I'm not really seeing this making anything simpler and I can see significant new bugs. Your new patch:
https://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git/commit/?h=perf/hwmon-pmu&id=85c78b5bf71fb3e67ae815f7b2d044648fa08391
Has taken about 40% out of patch 2, but done so by splitting function declarations from their definitions, enum declarations from any use,

Yeah, it's just because I was lazy and you can split header files too (and please do so).

Quoted 4 lines

etc. It also adds in code like:

snprintf(buf, sizeof(buf), "%s_input", evsel->name);

Quoted 8 lines
Quoted 2 lines

but this would be a strange thing to do. The evsel->name is rewritten by fallback logic, so cycles may become cycles:u if kernel profiling

I know it doesn't work but just want to highlight how it's supposed to work. Eventually what we need is a correct file name. In fact, I think it'd work if we can pass a correct event name probably like:

perf stat -e hwmon5/name=fan1/ true

But this isn't what the term name and evsel's name are for. They are to allow you to do:

```
$ perf stat -e cycles/name=foobar/ true

Performance counter stats for 'true':

        1,126,942      foobar

      0.001681805 seconds time elapsed

      0.001757000 seconds user
      0.000000000 seconds sys
```
Quoted 2 lines

Why would you do this in code, change a fundamental of evsel behavior, then just to delete it in the next patch?

Well, I didn't change the actual behavior and it doesn't work yet. The deletion is just one line, and I think it reveals the intention of the next patch very well.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

is restricted. This is why we have metric-id in the evsel as we cannot rely on the evsel->name not mutating when looking up events for the sake of metrics. Using the name as part of a sysfs filename lookup doesn't make sense to me as now the evsel fallback logic can break a hwmon event. In the original patch the code was:

Quoted 7 lines
Quoted 3 lines

The fallback logic is used only if the kernel returns an error. Thus it'd be fine as long as it correctly finds the sysfs filename. But it's not used in the final code and the change is a simple one-liner.

But it's not. It's changing what evsel->name means to be an event encoding. How does reverse config to name lookup work in this model? How does the normal use of the name term work?

It's intermediate code that is not activated yet. So I think it's about to say how the code works. If you really don't like to use evsel->name, maybe you can put a dummy name with a comment saying it'll be updated in next patch.

Quoted 27 lines
Quoted 19 lines
Quoted 8 lines

snprintf(buf, sizeof(buf), "%s%d_input", hwmon_type_strs[key.type], key.num);

where those two values are constants and key.type and key.num both values embedded in the config value the evsel fallback logic won't change. But bringing in the code that does that basically brings in all of the rest of patch 2.

Right, that's why I did that way.

Quoted 4 lines

So the patch is adding a PMU that looks broken, so rather than simplifying things it just creates a broken intermediate state and should that be fixed for the benefit of bisects?

Actually it's not broken since it's not enabled yet. :)

Quoted 7 lines
Quoted 5 lines

It also complicates understanding as the declarations of functions and enums have kernel-doc, but now the definitions of enums and functions are split apart. For me, to understand the code I'd want to squash the patches back together again so I could see a declaration with its definition.

Yep, please move the declarations to the patch 3.

Quoted 8 lines

So I think moving the enum declarations into one patch is okay. But as the enum values have no bearing on hardware constants, or something outside of the code that uses them it smells strange to me. Ultimately this is going to do little to the lines of code count but damage readability. I'm not sure why we're doing this given the kernel model for adding a driver is to add it as a large chunk. For example, here is adding the intel PT driver:
https://lore.kernel.org/all/1422614392-114498-1-git-send-email-alexander.shishkin@linux.intel.com/T/#u

Maybe others can understand a big patch easily, but I'm not.

Thanks,
Namhyung

author reviewer
#14 lore raw
Quoted 160 lines · Namhyung Kim
Quoted 95 lines · Ian Rogers
Quoted 71 lines · Namhyung Kim
Quoted 54 lines · Ian Rogers
Quoted 53 lines · Namhyung Kim

Hi Ian,

Quoted 36 lines · Ian Rogers

Following the convention of the tool PMU, create a hwmon PMU that exposes hwmon data for reading. For example, the following shows reading the CPU temperature and 2 fan speeds alongside the uncore frequency:

```
$ perf stat -e temp_cpu,fan1,hwmon_thinkpad/fan2/,tool/num_cpus_online/ -M UNCORE_FREQ -I 1000
     1.001153138              52.00 'C   temp_cpu
     1.001153138              2,588 rpm  fan1
     1.001153138              2,482 rpm  hwmon_thinkpad/fan2/
     1.001153138                  8      tool/num_cpus_online/
     1.001153138      1,077,101,397      UNC_CLOCK.SOCKET                 #     1.08 UNCORE_FREQ
     1.001153138      1,012,773,595      duration_time
...
```

Additional data on the hwmon events is in perf list:

```
$ perf list
...
hwmon:
...
  temp_core_0 OR temp2
       [Temperature in unit coretemp named Core 0. crit=100'C,max=100'C crit_alarm=0'C. Unit:
        hwmon_coretemp]
...
```

v6: Add string.h #include for issue reported by kernel test robot.
v5: Fix asan issue in parse_hwmon_filename caught by a TMA metric.
v4: Drop merged patches 1 to 10. Separate adding the hwmon_pmu from
the update to perf_pmu to use it. Try to make source of literal strings clearer via named #defines. Fix a number of GCC warnings.
v3: Rebase, add Namhyung's acked-by to patches 1 to 10.
v2: Address Namhyung's review feedback. Rebase dropping 4 patches
applied by Arnaldo, fix build breakage reported by Arnaldo.

Quoted 6 lines

Ian Rogers (5):
tools api io: Ensure line_len_out is always initialized perf hwmon_pmu: Add a tool PMU exposing events from hwmon in sysfs perf pmu: Add calls enabling the hwmon_pmu
perf test: Add hwmon "PMU" test
perf docs: Document tool and hwmon events

I think the patch 2 can be easily splitted into core and other parts like dealing with aliases and units. I believe it'd be helpful for others (like me) to understand how it works.

Please take a look at 'perf/hwmon-pmu' branch in:

Quoted 7 lines
Quoted 1 line

https://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git

Thanks Namhyung but I'm not really seeing this making anything simpler and I can see significant new bugs. Your new patch:
https://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git/commit/?h=perf/hwmon-pmu&id=85c78b5bf71fb3e67ae815f7b2d044648fa08391
Has taken about 40% out of patch 2, but done so by splitting function declarations from their definitions, enum declarations from any use,

Yeah, it's just because I was lazy and you can split header files too (and please do so).

Quoted 4 lines

etc. It also adds in code like:

snprintf(buf, sizeof(buf), "%s_input", evsel->name);

Quoted 8 lines
Quoted 2 lines

but this would be a strange thing to do. The evsel->name is rewritten by fallback logic, so cycles may become cycles:u if kernel profiling

I know it doesn't work but just want to highlight how it's supposed to work. Eventually what we need is a correct file name. In fact, I think it'd work if we can pass a correct event name probably like:

perf stat -e hwmon5/name=fan1/ true

But this isn't what the term name and evsel's name are for. They are to allow you to do:

```
$ perf stat -e cycles/name=foobar/ true

Performance counter stats for 'true':

        1,126,942      foobar

      0.001681805 seconds time elapsed

      0.001757000 seconds user
      0.000000000 seconds sys
```
Quoted 2 lines

Why would you do this in code, change a fundamental of evsel behavior, then just to delete it in the next patch?

Well, I didn't change the actual behavior and it doesn't work yet. The deletion is just one line, and I think it reveals the intention of the next patch very well.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

is restricted. This is why we have metric-id in the evsel as we cannot rely on the evsel->name not mutating when looking up events for the sake of metrics. Using the name as part of a sysfs filename lookup doesn't make sense to me as now the evsel fallback logic can break a hwmon event. In the original patch the code was:

Quoted 7 lines
Quoted 3 lines

The fallback logic is used only if the kernel returns an error. Thus it'd be fine as long as it correctly finds the sysfs filename. But it's not used in the final code and the change is a simple one-liner.

But it's not. It's changing what evsel->name means to be an event encoding. How does reverse config to name lookup work in this model? How does the normal use of the name term work?

It's intermediate code that is not activated yet. So I think it's about to say how the code works. If you really don't like to use evsel->name, maybe you can put a dummy name with a comment saying it'll be updated in next patch.

Quoted 27 lines
Quoted 19 lines
Quoted 8 lines

snprintf(buf, sizeof(buf), "%s%d_input", hwmon_type_strs[key.type], key.num);

where those two values are constants and key.type and key.num both values embedded in the config value the evsel fallback logic won't change. But bringing in the code that does that basically brings in all of the rest of patch 2.

Right, that's why I did that way.

Quoted 4 lines

So the patch is adding a PMU that looks broken, so rather than simplifying things it just creates a broken intermediate state and should that be fixed for the benefit of bisects?

Actually it's not broken since it's not enabled yet. :)

Quoted 7 lines
Quoted 5 lines

It also complicates understanding as the declarations of functions and enums have kernel-doc, but now the definitions of enums and functions are split apart. For me, to understand the code I'd want to squash the patches back together again so I could see a declaration with its definition.

Yep, please move the declarations to the patch 3.

Quoted 8 lines

So I think moving the enum declarations into one patch is okay. But as the enum values have no bearing on hardware constants, or something outside of the code that uses them it smells strange to me. Ultimately this is going to do little to the lines of code count but damage readability. I'm not sure why we're doing this given the kernel model for adding a driver is to add it as a large chunk. For example, here is adding the intel PT driver:
https://lore.kernel.org/all/1422614392-114498-1-git-send-email-alexander.shishkin@linux.intel.com/T/#u

Quoted 1 line

Maybe others can understand a big patch easily, but I'm not.

My understanding is that we make small patches so that the codebase is more bisectable. When there is something new, like a driver or here a hwmon PMU, the first patch is large and then we switch to the small patch model. I have seen patches adding constants ahead of them being used, but not normally as enums. I've already reduced the size of the patch by moving everything that isn't hwmon PMU out of the patch and most of that has already landed. Moving enums out of a header file okay, shouldn't break the build (a compiler may complain about unused enums) but then I end up copying comments into commit messages and doing something alien to what is done in the rest of the kernel. Not defining a function when you declare it, that is in many cases a compiler error and for good reason. Adding in changes that are what are or could be compiler errors goes against making things bisectable.

So breaking up this patch is bad as:
1) it doesn't match existing kernel style,
2) it makes the patch harder to understand (declarations split from definitions, etc.),
3) with new compiler errors/warnings the code will be less bisectable as we're deliberately doing things we think wrong for the sake of a lines-of-code size,
4) we increase the number of patches and commit messages, with commit messages duplicating comments for things like functions or enums being added,
5) with your patches we create an intermediate PMU with different conventions than the rest of the code base and with bugs, impacting bisectability and the ability to understand the code base.

So I'm arguing against doing this as it is contrary to both our normal objectives and existing style. I have no real way of knowing when I've cut something up small enough and if we're not building the code then how do I build/test the intermediate states, I'm just out on a wild goose chase.

Thanks,
Ian

#15 lore raw
Quoted 11 lines · Ian Rogers
Quoted 9 lines · Namhyung Kim
Quoted 8 lines · Ian Rogers

So I think moving the enum declarations into one patch is okay. But as the enum values have no bearing on hardware constants, or something outside of the code that uses them it smells strange to me. Ultimately this is going to do little to the lines of code count but damage readability. I'm not sure why we're doing this given the kernel model for adding a driver is to add it as a large chunk. For example, here is adding the intel PT driver:
https://lore.kernel.org/all/1422614392-114498-1-git-send-email-alexander.shishkin@linux.intel.com/T/#u

Quoted 4 lines
Quoted 1 line

Maybe others can understand a big patch easily, but I'm not.

My understanding is that we make small patches so that the codebase is more bisectable. When there is something new, like a driver or here a

That is super important, having patches being super small and doing just one thing helps in bisecting problems.

If two things are done in one patch, and one of them causes a problem, then bisection is a very effective way of finding out what exactly caused a problem.

But bisection is not the only benefit from breaking down larger patches into smaller ones.

We want to have more people joining our ranks, doing low level tooling and kernel work.

Writing new functionality in a series of patches, growing in complexity is a way to reduce the cognitive load on understantind how something works.

As much as trying to emulate how the kernel community works is a good model as that community has been producing a lot of good code in a frantic, athletic pace, and as much as I can agree with you that adding a new piece of code will not affect bisectability as its new code, I think having it broken down in multiple patches benefits revieweing.

Reviewing is something we should do more, but its very taxing.

One would rather try to write as much code as possible, leaving to others the reviewing part.

But its a balancing act.

Whatever we can do to help reviewers, like taking into account what they say they would prefer as a way to submit our work, even if it isn't exactly of our liking, is one such thing.

So if Namhyung says that it would be best for you to try to break down your patches into smaller ones, like I did say to you in the past, even taking the trouble to do it myself, in the process introducing problems, later fixed, I think you should try to do what he says.

He is the maintainer, try to address his comments.

- Arnaldo

author reviewer
#16 lore raw
Quoted 35 lines · Arnaldo Carvalho de Melo
Quoted 11 lines · Ian Rogers
Quoted 9 lines · Namhyung Kim
Quoted 8 lines · Ian Rogers

So I think moving the enum declarations into one patch is okay. But as the enum values have no bearing on hardware constants, or something outside of the code that uses them it smells strange to me. Ultimately this is going to do little to the lines of code count but damage readability. I'm not sure why we're doing this given the kernel model for adding a driver is to add it as a large chunk. For example, here is adding the intel PT driver:
https://lore.kernel.org/all/1422614392-114498-1-git-send-email-alexander.shishkin@linux.intel.com/T/#u

Quoted 4 lines
Quoted 1 line

Maybe others can understand a big patch easily, but I'm not.

My understanding is that we make small patches so that the codebase is more bisectable. When there is something new, like a driver or here a

That is super important, having patches being super small and doing just one thing helps in bisecting problems.

If two things are done in one patch, and one of them causes a problem, then bisection is a very effective way of finding out what exactly caused a problem.

But bisection is not the only benefit from breaking down larger patches into smaller ones.

We want to have more people joining our ranks, doing low level tooling and kernel work.

Writing new functionality in a series of patches, growing in complexity is a way to reduce the cognitive load on understantind how something works.

Quoted 5 lines

As much as trying to emulate how the kernel community works is a good model as that community has been producing a lot of good code in a frantic, athletic pace, and as much as I can agree with you that adding a new piece of code will not affect bisectability as its new code, I think having it broken down in multiple patches benefits revieweing.

Can you explain how, as asked, can separating the declaration of a function from its definition aid in reviewing? As a reviewer, I want to know the scope of a function and its documentation. Placing them in 2 separate patches doesn't benefit my reviewing.

Quoted 11 lines

Reviewing is something we should do more, but its very taxing.

One would rather try to write as much code as possible, leaving to others the reviewing part.

But its a balancing act.

Whatever we can do to help reviewers, like taking into account what they say they would prefer as a way to submit our work, even if it isn't exactly of our liking, is one such thing.

Quoted 6 lines

So if Namhyung says that it would be best for you to try to break down your patches into smaller ones, like I did say to you in the past, even taking the trouble to do it myself, in the process introducing problems, later fixed, I think you should try to do what he says.

He is the maintainer, try to address his comments.

I think I've written long emails addressing the comments. Just saying too big (1) doesn't match how existing drivers are added (although I've split the code many times so the addition is the smallest it can be) (2) as I've pointed out makes the code harder to bisect, work with compilers and understand.

I think there is far too much developer push back going on, it feels capricious, I'm lucky as I'll just go push into Google's tree. I'm only persisting here for upstream's benefit and ultimately my benefit when I pull from upstream. Perfect shouldn't be the enemy of good, but frequently (more often than not for me) reviewer comments aren't improving the code they are significantly stalling it:

1) parallel testing
https://lore.kernel.org/lkml/[email protected]/
1.1) pushed back because it used an #ifdef __linux__ to maintain some posix library code (a now dropped complaint)
1.2) pushed back for improvements in test numbering, addressed in:
https://lore.kernel.org/lkml/[email protected]/
not an unreasonable thing to do but feature creep. Hey we'll only take your work helping us if you also add feature xyz

2) libdw clean up
https://lore.kernel.org/lkml/[email protected]/
Pushed back as more cross architecture output would make the commit messages better. Doesn't sound crazily unreasonable until you realize the function that is being called and needing cross platform testing is 6 lines long and only applies when you do analysis of x86 perf.data files on non-x86 platforms. We heavily test the code on x86 and the chance that cross platform testing will show anything is very small.

On the other hand I can point at unreviewed maintainer code going into the tree and code where I've pointed out it is broken, from a fundamental CS perspective, it is also taken into the tree.

RISC-V has been damaged and now in the driver they are trying to workaround the perf tool. There were already comments to this effect in ARM breakpoint driver's code.

On Intel we now have TPEBS (which took far far too long to land) behind a flag which means we've made accurate top-down analysis require an additional flag on all newer Intel models, something I pushed against.

So the reviewing is inconsistent, damages the code (a maintainer may disagree with the reviewer and developers saying otherwise but the maintainer has to be followed to land) and is constantly stalling development. Fixing reference counting took years to land because of endless stalling, any reasonable developer would have just given up. It is hard to imagine the state the code base would be in without it.

Of the patches I've mentioned how many are code health and how many are a feature I can say working on is part of my day job? I see a deliberate lack of understanding of what a developer needs. To say I've not tried to address comments, I'd say 90% of the noise on linux-perf-users is me resending patches, mine and others, to address comments. Here I've made the patches a size that makes sense. I can move the enums, which feels like a compiler error along the lines of "static function defined but not used" but beside this, changing evsel's name meaning to make it part of the event encoding is imo wrong, having separate patches for a function declaration and then 1 for its definition, can you imagine taking this to its extreme and what the patches would look like if you did this? In making things smaller, as has happened already in this series, it is never clear you will hit a magical maintainer happy threshold. Knowing how to make a "right" patch is even harder when it is inconsistent with the rest of Linux development.

Thanks,
Ian

maintainer
#17 lore raw

Hello Ian,

Thanks for your email explaining the concerns.

Quoted 43 lines · Ian Rogers
Quoted 35 lines · Arnaldo Carvalho de Melo
Quoted 11 lines · Ian Rogers
Quoted 9 lines · Namhyung Kim
Quoted 8 lines · Ian Rogers

So I think moving the enum declarations into one patch is okay. But as the enum values have no bearing on hardware constants, or something outside of the code that uses them it smells strange to me. Ultimately this is going to do little to the lines of code count but damage readability. I'm not sure why we're doing this given the kernel model for adding a driver is to add it as a large chunk. For example, here is adding the intel PT driver:
https://lore.kernel.org/all/1422614392-114498-1-git-send-email-alexander.shishkin@linux.intel.com/T/#u

Quoted 4 lines
Quoted 1 line

Maybe others can understand a big patch easily, but I'm not.

My understanding is that we make small patches so that the codebase is more bisectable. When there is something new, like a driver or here a

That is super important, having patches being super small and doing just one thing helps in bisecting problems.

If two things are done in one patch, and one of them causes a problem, then bisection is a very effective way of finding out what exactly caused a problem.

But bisection is not the only benefit from breaking down larger patches into smaller ones.

We want to have more people joining our ranks, doing low level tooling and kernel work.

Writing new functionality in a series of patches, growing in complexity is a way to reduce the cognitive load on understantind how something works.

Quoted 5 lines

As much as trying to emulate how the kernel community works is a good model as that community has been producing a lot of good code in a frantic, athletic pace, and as much as I can agree with you that adding a new piece of code will not affect bisectability as its new code, I think having it broken down in multiple patches benefits revieweing.

Quoted 4 lines

Can you explain how, as asked, can separating the declaration of a function from its definition aid in reviewing? As a reviewer, I want to know the scope of a function and its documentation. Placing them in 2 separate patches doesn't benefit my reviewing.

No, it's my fault. Please move the declaration into the same patch.

Quoted 17 lines
Quoted 17 lines

Reviewing is something we should do more, but its very taxing.

One would rather try to write as much code as possible, leaving to others the reviewing part.

But its a balancing act.

Whatever we can do to help reviewers, like taking into account what they say they would prefer as a way to submit our work, even if it isn't exactly of our liking, is one such thing.

So if Namhyung says that it would be best for you to try to break down your patches into smaller ones, like I did say to you in the past, even taking the trouble to do it myself, in the process introducing problems, later fixed, I think you should try to do what he says.

Quoted 5 lines
Quoted 1 line

He is the maintainer, try to address his comments.

I think I've written long emails addressing the comments. Just saying too big (1) doesn't match how existing drivers are added (although I've split the code many times so the addition is the smallest it can

I think it's different than drivers which can be separated by a config option easily and highly hardware dependent. Or maybe it's just a maintainers' preference.

Quoted 2 lines

be) (2) as I've pointed out makes the code harder to bisect, work with compilers and understand.

I don't agree. The intention is to help other's understanding of the code. Well I agree it will require more effort for the author, but I believe that having the code more digestible size would benefit in the long run.

I feel like the whole perf code base is getting bigger, harder to know all the details. So I'm asking contributors to do more work to reduce the burden in some way.

Quoted 7 lines

I think there is far too much developer push back going on, it feels capricious, I'm lucky as I'll just go push into Google's tree. I'm only persisting here for upstream's benefit and ultimately my benefit when I pull from upstream. Perfect shouldn't be the enemy of good, but frequently (more often than not for me) reviewer comments aren't improving the code they are significantly stalling it:

I'm sorry that you felt that way. I was trying to improve the code and keep the code simple and concise. But it's sometimes hard to draw the line where it's acceptable. Probably my previous decisions were bad, but I tried to be reasonable as much as possible.

Quoted 5 lines

1) parallel testing
https://lore.kernel.org/lkml/[email protected]/
1.1) pushed back because it used an #ifdef __linux__ to maintain some posix library code (a now dropped complaint)

I don't know we have that in other place. So I was curious if we care about other platforms. Probably we can just delete the unused code, but as I said, I can live with this.

Quoted 4 lines

1.2) pushed back for improvements in test numbering, addressed in:
https://lore.kernel.org/lkml/[email protected]/
not an unreasonable thing to do but feature creep. Hey we'll only take your work helping us if you also add feature xyz

Well I think you changed the numbering in the parallel testing and I asked to keep it continuous as of now.

Quoted 9 lines

2) libdw clean up
https://lore.kernel.org/lkml/[email protected]/
Pushed back as more cross architecture output would make the commit messages better. Doesn't sound crazily unreasonable until you realize the function that is being called and needing cross platform testing is 6 lines long and only applies when you do analysis of x86 perf.data files on non-x86 platforms. We heavily test the code on x86 and the chance that cross platform testing will show anything is very small.

I think we're fine except for the register naming. I haven't reviewed that part yet and I'll do that next week.

Quoted 8 lines

On the other hand I can point at unreviewed maintainer code going into the tree and code where I've pointed out it is broken, from a fundamental CS perspective, it is also taken into the tree.

RISC-V has been damaged and now in the driver they are trying to workaround the perf tool. There were already comments to this effect in ARM breakpoint driver's code.

It's sad we broke some arch. But it should be easy to fix the tool than the kernel driver. Let's find a way to fix the problems in a better way. Sorry if I missed some previous discussion.

Quoted 5 lines

On Intel we now have TPEBS (which took far far too long to land) behind a flag which means we've made accurate top-down analysis require an additional flag on all newer Intel models, something I pushed against.

This is a new code that requires complex and non-intuitive operations like mixing perf record and perf stat together. I remember some people doubt about the approach so it may deserve stricter and longer reviews.

Even then, I tried to review quickly and accepted some minor disasgreements. It's unfortunate it took too long but it happens.

Quoted 7 lines

So the reviewing is inconsistent, damages the code (a maintainer may disagree with the reviewer and developers saying otherwise but the maintainer has to be followed to land) and is constantly stalling development. Fixing reference counting took years to land because of endless stalling, any reasonable developer would have just given up. It is hard to imagine the state the code base would be in without it.

Right it works great, thanks for your effort.

But I think any collaborating work needs some kind of burden (or stalling) for coordination. If said patches touch a lot of area, there is a high chance of rebase, more arguments on the interface, etc.

Quoted 6 lines

Of the patches I've mentioned how many are code health and how many are a feature I can say working on is part of my day job? I see a deliberate lack of understanding of what a developer needs. To say I've not tried to address comments, I'd say 90% of the noise on linux-perf-users is me resending patches, mine and others, to address

Thanks for your hard work. Maybe I'm the bottleneck of your productivity. But I cannot take patches without review, and reviewing patches take time. Having more active reviewers would help.

Quoted 11 lines

comments. Here I've made the patches a size that makes sense. I can move the enums, which feels like a compiler error along the lines of "static function defined but not used" but beside this, changing evsel's name meaning to make it part of the event encoding is imo wrong, having separate patches for a function declaration and then 1 for its definition, can you imagine taking this to its extreme and what the patches would look like if you did this? In making things smaller, as has happened already in this series, it is never clear you will hit a magical maintainer happy threshold. Knowing how to make a "right" patch is even harder when it is inconsistent with the rest of Linux development.

At least for this case, I don't think moving the declaration would cause you a lot of trouble. Please take a look at my updated 'perf/hwmon-pmu' branch again.

For the magical maintainer threshold, I admit it can be different to each maintainer. But I think it's the review process to find a point of agreement. I don't know where it is even by myself but we can argue each other.

Thanks,
Namhyung