Skip to contentSkip to conversation

tools/thermal: thermal library and tools

PATCH Superseded Daniel Lezcano 3 participants 19 messages Mar 30, 2022 – Apr 20, 2022 Thermal

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover tools/thermal: thermal library and tools

These changes are providing the following tools and library:

- A thermal library doing the netlink abstraction from the kernel in order to make the userspace thermal implementation easier. Having the library integrated with the kernel tree is also a guarantee to keep the message format and their encoding/decoding aligned

- A thermal tools library providing a set of functions to deal with usual features like the log, the mainloop and the time. This library is used by the provided tools below

- An data acquisition program to capture the temperature of the different thermal zone during an amount of time or during the execution of an application. The output is formated to be easily parsed by gnuplot, a spreadsheet program or a statistical command line utility. The timestamp is based on the system uptime, thus giving an indication of when a thermal event happened, that can help to spot or reproduce thermal issue in the long run

- A thermal monitoring program based on the thermal library. It gives a skeleton to build any logic on top of it and shows how to use the thermal library. It does nothing except discovering the thermal zones, their trip points and listening for events like cooling devices state changes or trip point crossed

Changelog:

v1: Initial post after a RFC

v2:

- Fixed all trailing whitespaces and some other checkpatch warnings. Some warnings remain but they can be considered as false positive

- Added in the thermometer tool:
- Usage/help option as well as a man page
- The ability to execute a program
- The capture duration
- Create the output directory if it does not exist

- Add in the thermal-engine tool:
- A usage/help option
- A message telling the userspace it is waiting for events
- A daemonize option

- Minor bug fixes here and there, as well as typos

Daniel Lezcano (4):
tools/lib/thermal: Add a thermal library
tools/thermal: Add util library
tools/thermal: A temperature capture tool
tools/thermal: Add thermal daemon skeleton

 MAINTAINERS                                   |   1 +
 tools/Makefile                                |  36 +-
 tools/lib/thermal/.gitignore                  |   2 +
 tools/lib/thermal/Build                       |   5 +
 tools/lib/thermal/Makefile                    | 165 ++++++
 tools/lib/thermal/commands.c                  | 349 +++++++++++
 tools/lib/thermal/events.c                    | 164 +++++
 tools/lib/thermal/include/thermal.h           | 142 +++++
 tools/lib/thermal/libthermal.map              |  25 +
 tools/lib/thermal/libthermal.pc.template      |  12 +
 tools/lib/thermal/sampling.c                  |  75 +++
 tools/lib/thermal/thermal.c                   | 126 ++++
 tools/lib/thermal/thermal_nl.c                | 215 +++++++
 tools/lib/thermal/thermal_nl.h                |  46 ++
 tools/thermal/lib/Build                       |   3 +
 tools/thermal/lib/Makefile                    | 158 +++++
 .../thermal/lib/libthermal_tools.pc.template  |  12 +
 tools/thermal/lib/log.c                       |  77 +++
 tools/thermal/lib/log.h                       |  31 +
 tools/thermal/lib/mainloop.c                  | 120 ++++
 tools/thermal/lib/mainloop.h                  |  15 +
 tools/thermal/lib/thermal-tools.h             |  10 +
 tools/thermal/lib/uptimeofday.c               |  40 ++
 tools/thermal/lib/uptimeofday.h               |  12 +
 tools/thermal/thermal-engine/Build            |   2 +
 tools/thermal/thermal-engine/Makefile         |  28 +
 tools/thermal/thermal-engine/thermal-engine.c | 326 ++++++++++
 tools/thermal/thermometer/Build               |   2 +
 tools/thermal/thermometer/Makefile            |  26 +
 tools/thermal/thermometer/thermometer.8       |  93 +++
 tools/thermal/thermometer/thermometer.c       | 558 ++++++++++++++++++
 tools/thermal/thermometer/thermometer.conf    |   5 +
 32 files changed, 2878 insertions(+), 3 deletions(-)
 create mode 100644 tools/lib/thermal/.gitignore
 create mode 100644 tools/lib/thermal/Build
 create mode 100644 tools/lib/thermal/Makefile
 create mode 100644 tools/lib/thermal/commands.c
 create mode 100644 tools/lib/thermal/events.c
 create mode 100644 tools/lib/thermal/include/thermal.h
 create mode 100644 tools/lib/thermal/libthermal.map
 create mode 100644 tools/lib/thermal/libthermal.pc.template
 create mode 100644 tools/lib/thermal/sampling.c
 create mode 100644 tools/lib/thermal/thermal.c
 create mode 100644 tools/lib/thermal/thermal_nl.c
 create mode 100644 tools/lib/thermal/thermal_nl.h
 create mode 100644 tools/thermal/lib/Build
 create mode 100644 tools/thermal/lib/Makefile
 create mode 100644 tools/thermal/lib/libthermal_tools.pc.template
 create mode 100644 tools/thermal/lib/log.c
 create mode 100644 tools/thermal/lib/log.h
 create mode 100644 tools/thermal/lib/mainloop.c
 create mode 100644 tools/thermal/lib/mainloop.h
 create mode 100644 tools/thermal/lib/thermal-tools.h
 create mode 100644 tools/thermal/lib/uptimeofday.c
 create mode 100644 tools/thermal/lib/uptimeofday.h
 create mode 100644 tools/thermal/thermal-engine/Build
 create mode 100644 tools/thermal/thermal-engine/Makefile
 create mode 100644 tools/thermal/thermal-engine/thermal-engine.c
 create mode 100644 tools/thermal/thermometer/Build
 create mode 100644 tools/thermal/thermometer/Makefile
 create mode 100644 tools/thermal/thermometer/thermometer.8
 create mode 100644 tools/thermal/thermometer/thermometer.c
 create mode 100644 tools/thermal/thermometer/thermometer.conf
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/4 tools/lib/thermal: Add a thermal library

The thermal framework implements a netlink notification mechanism to be used by the userspace to have a thermal configuration discovery, trip point changes or violation, cooling device changes notifications, etc...

This library provides a level of abstraction for the thermal netlink notification allowing the userspace to connect to the notification mechanism more easily. The library is callback oriented.

---
 MAINTAINERS                              |   1 +
 tools/Makefile                           |  14 +-
 tools/lib/thermal/.gitignore             |   2 +
 tools/lib/thermal/Build                  |   5 +
 tools/lib/thermal/Makefile               | 165 +++++++++++
 tools/lib/thermal/commands.c             | 349 +++++++++++++++++++++++
 tools/lib/thermal/events.c               | 164 +++++++++++
 tools/lib/thermal/include/thermal.h      | 142 +++++++++
 tools/lib/thermal/libthermal.map         |  25 ++
 tools/lib/thermal/libthermal.pc.template |  12 +
 tools/lib/thermal/sampling.c             |  75 +++++
 tools/lib/thermal/thermal.c              | 126 ++++++++
 tools/lib/thermal/thermal_nl.c           | 215 ++++++++++++++
 tools/lib/thermal/thermal_nl.h           |  46 +++
 14 files changed, 1339 insertions(+), 2 deletions(-)
 create mode 100644 tools/lib/thermal/.gitignore
 create mode 100644 tools/lib/thermal/Build
 create mode 100644 tools/lib/thermal/Makefile
 create mode 100644 tools/lib/thermal/commands.c
 create mode 100644 tools/lib/thermal/events.c
 create mode 100644 tools/lib/thermal/include/thermal.h
 create mode 100644 tools/lib/thermal/libthermal.map
 create mode 100644 tools/lib/thermal/libthermal.pc.template
 create mode 100644 tools/lib/thermal/sampling.c
 create mode 100644 tools/lib/thermal/thermal.c
 create mode 100644 tools/lib/thermal/thermal_nl.c
 create mode 100644 tools/lib/thermal/thermal_nl.h
MAINTAINERS +1 -0
index 3bcb6f13617f..07fb2d6e2810 100644
@@ -19129,6 +19129,7 @@ F:	drivers/thermal/
 F:	include/linux/cpu_cooling.h
 F:	include/linux/thermal.h
 F:	include/uapi/linux/thermal.h
+F:	tools/lib/thermal/
 F:	tools/thermal/
 
 THERMAL DRIVER FOR AMLOGIC SOCS
tools/Makefile +12 -2
index db2f7b8ebed5..c253cbd27c06 100644
@@ -31,6 +31,7 @@ help:
 	@echo '  bootconfig             - boot config tool'
 	@echo '  spi                    - spi tools'
 	@echo '  tmon                   - thermal monitoring and tuning tool'
+	@echo '  thermal                - thermal library'
 	@echo '  tracing                - misc tracing tools'
 	@echo '  turbostat              - Intel CPU idle stats and freq reporting tool'
 	@echo '  usb                    - USB testing tools'
@@ -85,6 +86,9 @@ perf: FORCE
 selftests: FORCE
 	$(call descend,testing/$@)
 
+thermal: FORCE
+	$(call descend,lib/$@)
+
 turbostat x86_energy_perf_policy intel-speed-select: FORCE
 	$(call descend,power/x86/$@)
 
@@ -101,7 +105,7 @@ all: acpi cgroup counter cpupower gpio hv firewire \
 		perf selftests bootconfig spi turbostat usb \
 		virtio vm bpf x86_energy_perf_policy \
 		tmon freefall iio objtool kvm_stat wmi \
-		pci debugging tracing
+		pci debugging tracing thermal
 
 acpi_install:
 	$(call descend,power/$(@:_install=),install)
@@ -115,6 +119,9 @@ cgroup_install counter_install firewire_install gpio_install hv_install iio_inst
 selftests_install:
 	$(call descend,testing/$(@:_install=),install)
 
+thermal_install:
+	$(call descend,lib/$(@:_install=),install)
+
 turbostat_install x86_energy_perf_policy_install intel-speed-select_install:
 	$(call descend,power/x86/$(@:_install=),install)
 
@@ -160,6 +167,9 @@ perf_clean:
 selftests_clean:
 	$(call descend,testing/$(@:_clean=),clean)
 
+thermal_clean:
+	$(call descend,lib/thermal,clean)
+
 turbostat_clean x86_energy_perf_policy_clean intel-speed-select_clean:
 	$(call descend,power/x86/$(@:_clean=),clean)
 
@@ -177,6 +187,6 @@ clean: acpi_clean cgroup_clean counter_clean cpupower_clean hv_clean firewire_cl
 		vm_clean bpf_clean iio_clean x86_energy_perf_policy_clean tmon_clean \
 		freefall_clean build_clean libbpf_clean libsubcmd_clean \
 		gpio_clean objtool_clean leds_clean wmi_clean pci_clean firmware_clean debugging_clean \
-		intel-speed-select_clean tracing_clean
+		intel-speed-select_clean tracing_clean thermal_clean
 
 .PHONY: FORCE
tools/lib/thermal/.gitignore new file +2 -0
new file mode 100644
index 000000000000..5d2aeda80fea
@@ -0,0 +1,2 @@
+libthermal.so*
+libthermal.pc
tools/lib/thermal/Build new file +5 -0
new file mode 100644
index 000000000000..4a892d9e24f9
@@ -0,0 +1,5 @@
+libthermal-y += commands.o
+libthermal-y += events.o
+libthermal-y += thermal_nl.o
+libthermal-y += sampling.o
+libthermal-y += thermal.o
tools/lib/thermal/Makefile new file +165 -0

165 lines not on this page · raw message

tools/lib/thermal/commands.c new file +349 -0

349 lines not on this page · raw message

tools/lib/thermal/events.c new file +164 -0

164 lines not on this page · raw message

tools/lib/thermal/include/thermal.h new file +142 -0

142 lines not on this page · raw message

tools/lib/thermal/libthermal.map new file +25 -0
new file mode 100644
index 000000000000..d5e77738c7a4
@@ -0,0 +1,25 @@
+LIBTHERMAL_0.0.1 {
+	global:
+		thermal_init;
+		for_each_thermal_zone;
+		for_each_thermal_trip;
+		for_each_thermal_cdev;
+		thermal_zone_find_by_name;
+		thermal_zone_find_by_id;
+		thermal_zone_discover;
+		thermal_init;
+		thermal_events_init;
+		thermal_events_handle;
+		thermal_events_fd;
+		thermal_cmd_init;
+		thermal_cmd_get_tz;
+		thermal_cmd_get_cdev;
+		thermal_cmd_get_trip;
+		thermal_cmd_get_governor;
+		thermal_cmd_get_temp;
+		thermal_sampling_init;
+		thermal_sampling_handle;
+		thermal_sampling_fd;
+local:
+		*;
+};
tools/lib/thermal/libthermal.pc.template new file +12 -0
new file mode 100644
index 000000000000..6f3769731b59
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
+
+prefix=@PREFIX@
+libdir=@LIBDIR@
+includedir=${prefix}/include
+
+Name: libthermal
+Description: thermal library
+Requires: libnl-3.0 libnl-genl-3.0
+Version: @VERSION@
+Libs: -L${libdir} -lnl-genl-3 -lnl-3
+Cflags: -I${includedir} -I{include}/libnl3
tools/lib/thermal/sampling.c new file +75 -0

75 lines not on this page · raw message

tools/lib/thermal/thermal.c new file +126 -0

126 lines not on this page · raw message

tools/lib/thermal/thermal_nl.c new file +215 -0

215 lines not on this page · raw message

tools/lib/thermal/thermal_nl.h new file +46 -0

46 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw

PATCH v2 2/4 tools/thermal: Add util library

In reply to Daniel Lezcano

The next changes will provide a couple of tools using some common functions provided by this library.

It provides basic wrappers for:

- mainloop
- logging
- timestamp

---
 tools/thermal/lib/Build                       |   3 +
 tools/thermal/lib/Makefile                    | 158 ++++++++++++++++++
 .../thermal/lib/libthermal_tools.pc.template  |  12 ++
 tools/thermal/lib/log.c                       |  77 +++++++++
 tools/thermal/lib/log.h                       |  31 ++++
 tools/thermal/lib/mainloop.c                  | 120 +++++++++++++
 tools/thermal/lib/mainloop.h                  |  15 ++
 tools/thermal/lib/thermal-tools.h             |  10 ++
 tools/thermal/lib/uptimeofday.c               |  40 +++++
 tools/thermal/lib/uptimeofday.h               |  12 ++
 10 files changed, 478 insertions(+)
 create mode 100644 tools/thermal/lib/Build
 create mode 100644 tools/thermal/lib/Makefile
 create mode 100644 tools/thermal/lib/libthermal_tools.pc.template
 create mode 100644 tools/thermal/lib/log.c
 create mode 100644 tools/thermal/lib/log.h
 create mode 100644 tools/thermal/lib/mainloop.c
 create mode 100644 tools/thermal/lib/mainloop.h
 create mode 100644 tools/thermal/lib/thermal-tools.h
 create mode 100644 tools/thermal/lib/uptimeofday.c
 create mode 100644 tools/thermal/lib/uptimeofday.h
tools/thermal/lib/Build new file +3 -0
new file mode 100644
index 000000000000..06f22760a272
@@ -0,0 +1,3 @@
+libthermal_tools-y += mainloop.o
+libthermal_tools-y += log.o
+libthermal_tools-y += uptimeofday.o
tools/thermal/lib/Makefile new file +158 -0

158 lines not on this page · raw message

tools/thermal/lib/libthermal_tools.pc.template new file +12 -0
new file mode 100644
index 000000000000..6f3769731b59
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
+
+prefix=@PREFIX@
+libdir=@LIBDIR@
+includedir=${prefix}/include
+
+Name: libthermal
+Description: thermal library
+Requires: libnl-3.0 libnl-genl-3.0
+Version: @VERSION@
+Libs: -L${libdir} -lnl-genl-3 -lnl-3
+Cflags: -I${includedir} -I{include}/libnl3
tools/thermal/lib/log.c new file +77 -0

77 lines not on this page · raw message

tools/thermal/lib/log.h new file +31 -0
new file mode 100644
index 000000000000..be8ab5144938
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+/* Copyright (C) 2022, Linaro Ltd - Daniel Lezcano <[email protected]> */
+#ifndef __THERMAL_TOOLS_LOG_H
+#define __THERMAL_TOOLS_LOG_H
+
+#include <syslog.h>
+
+#ifndef __maybe_unused
+#define __maybe_unused		__attribute__((__unused__))
+#endif
+
+#define TO_SYSLOG 0x1
+#define TO_STDOUT 0x2
+#define TO_STDERR 0x4
+
+extern void logit(int level, const char *format, ...);
+
+#define DEBUG(fmt, ...)		logit(LOG_DEBUG, "%s:%d: " fmt, __func__, __LINE__, ##__VA_ARGS__)
+#define INFO(fmt, ...)		logit(LOG_INFO, fmt, ##__VA_ARGS__)
+#define NOTICE(fmt, ...)	logit(LOG_NOTICE, fmt, ##__VA_ARGS__)
+#define WARN(fmt, ...)		logit(LOG_WARNING, fmt, ##__VA_ARGS__)
+#define ERROR(fmt, ...)		logit(LOG_ERR, fmt, ##__VA_ARGS__)
+#define CRITICAL(fmt, ...)	logit(LOG_CRIT, fmt, ##__VA_ARGS__)
+#define ALERT(fmt, ...)		logit(LOG_ALERT, fmt, ##__VA_ARGS__)
+#define EMERG(fmt, ...)		logit(LOG_EMERG, fmt, ##__VA_ARGS__)
+
+int log_init(int level, const char *ident, int options);
+int log_str2level(const char *lvl);
+void log_exit(void);
+
+#endif
tools/thermal/lib/mainloop.c new file +120 -0

120 lines not on this page · raw message

tools/thermal/lib/mainloop.h new file +15 -0
new file mode 100644
index 000000000000..89b61e89d905
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+/* Copyright (C) 2022, Linaro Ltd - Daniel Lezcano <[email protected]> */
+#ifndef __THERMAL_TOOLS_MAINLOOP_H
+#define __THERMAL_TOOLS_MAINLOOP_H
+
+typedef int (*mainloop_callback_t)(int fd, void *data);
+
+extern int mainloop(unsigned int timeout);
+extern int mainloop_add(int fd, mainloop_callback_t cb, void *data);
+extern int mainloop_del(int fd);
+extern void mainloop_exit(void);
+extern int mainloop_init(void);
+extern void mainloop_fini(void);
+
+#endif
tools/thermal/lib/thermal-tools.h new file +10 -0
new file mode 100644
index 000000000000..f43939a468a3
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+/* Copyright (C) 2022, Linaro Ltd - Daniel Lezcano <[email protected]> */
+#ifndef __THERMAL_TOOLS
+#define __THERMAL_TOOLS
+
+#include "log.h"
+#include "mainloop.h"
+#include "uptimeofday.h"
+
+#endif
tools/thermal/lib/uptimeofday.c new file +40 -0
new file mode 100644
index 000000000000..dacb02956a68
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: LGPL-2.1+
+// Copyright (C) 2022, Linaro Ltd - Daniel Lezcano <[email protected]>
+#include <stdio.h>
+#include <sys/time.h>
+#include <linux/sysinfo.h>
+#include "thermal-tools.h"
+
+static unsigned long __offset;
+static struct timeval __tv;
+
+int uptimeofday_init(void)
+{
+	struct sysinfo info;
+
+	if (sysinfo(&info))
+		return -1;
+
+	gettimeofday(&__tv, NULL);
+
+	__offset = __tv.tv_sec - info.uptime;
+
+	return 0;
+}
+
+unsigned long getuptimeofday_ms(void)
+{
+	gettimeofday(&__tv, NULL);
+
+	return ((__tv.tv_sec - __offset) * 1000) + (__tv.tv_usec / 1000);
+}
+
+struct timespec msec_to_timespec(int msec)
+{
+	struct timespec tv = {
+		.tv_sec = (msec / 1000),
+		.tv_nsec = (msec % 1000) * 1000000,
+	};
+
+	return tv;
+}
tools/thermal/lib/uptimeofday.h new file +12 -0
new file mode 100644
index 000000000000..c0da5de41325
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+/* Copyright (C) 2022, Linaro Ltd - Daniel Lezcano <[email protected]> */
+#ifndef __THERMAL_TOOLS_UPTIMEOFDAY_H
+#define __THERMAL_TOOLS_UPTIMEOFDAY_H
+#include <sys/sysinfo.h>
+#include <sys/time.h>
+
+int uptimeofday_init(void);
+unsigned long getuptimeofday_ms(void);
+struct timespec msec_to_timespec(int msec);
+
+#endif
Signature · 1 line
2.25.1
#3 lore raw

PATCH v2 3/4 tools/thermal: A temperature capture tool

In reply to Daniel Lezcano

The 'thermometer' tool allows to capture the temperature of a set of thermal zones defined in a configuration file at a specified rate.

It is designed to have the lowest possible overhead. It will write the captured temperature per thermal zone per file so making easier to write a gnuplot script.

---
 tools/Makefile                             |  16 +-
 tools/thermal/thermometer/Build            |   2 +
 tools/thermal/thermometer/Makefile         |  26 +
 tools/thermal/thermometer/thermometer.8    |  93 ++++
 tools/thermal/thermometer/thermometer.c    | 558 +++++++++++++++++++++
 tools/thermal/thermometer/thermometer.conf |   5 +
 6 files changed, 697 insertions(+), 3 deletions(-)
 create mode 100644 tools/thermal/thermometer/Build
 create mode 100644 tools/thermal/thermometer/Makefile
 create mode 100644 tools/thermal/thermometer/thermometer.8
 create mode 100644 tools/thermal/thermometer/thermometer.c
 create mode 100644 tools/thermal/thermometer/thermometer.conf
tools/Makefile +13 -3
index c253cbd27c06..78615f8cb463 100644
@@ -31,6 +31,7 @@ help:
 	@echo '  bootconfig             - boot config tool'
 	@echo '  spi                    - spi tools'
 	@echo '  tmon                   - thermal monitoring and tuning tool'
+	@echo '  thermometer            - temperature capture tool'
 	@echo '  thermal                - thermal library'
 	@echo '  tracing                - misc tracing tools'
 	@echo '  turbostat              - Intel CPU idle stats and freq reporting tool'
@@ -95,6 +96,9 @@ turbostat x86_energy_perf_policy intel-speed-select: FORCE
 tmon: FORCE
 	$(call descend,thermal/$@)
 
+thermometer: FORCE
+	$(call descend,thermal/$@)
+
 freefall: FORCE
 	$(call descend,laptop/$@)
 
@@ -105,7 +109,7 @@ all: acpi cgroup counter cpupower gpio hv firewire \
 		perf selftests bootconfig spi turbostat usb \
 		virtio vm bpf x86_energy_perf_policy \
 		tmon freefall iio objtool kvm_stat wmi \
-		pci debugging tracing thermal
+		pci debugging tracing thermal thermometer
 
 acpi_install:
 	$(call descend,power/$(@:_install=),install)
@@ -128,6 +132,9 @@ turbostat_install x86_energy_perf_policy_install intel-speed-select_install:
 tmon_install:
 	$(call descend,thermal/$(@:_install=),install)
 
+thermometer_install:
+	$(call descend,thermal/$(@:_install=),install)
+
 freefall_install:
 	$(call descend,laptop/$(@:_install=),install)
 
@@ -140,7 +147,7 @@ install: acpi_install cgroup_install counter_install cpupower_install gpio_insta
 		virtio_install vm_install bpf_install x86_energy_perf_policy_install \
 		tmon_install freefall_install objtool_install kvm_stat_install \
 		wmi_install pci_install debugging_install intel-speed-select_install \
-		tracing_install
+		tracing_install thermometer_install
 
 acpi_clean:
 	$(call descend,power/acpi,clean)
@@ -173,6 +180,9 @@ thermal_clean:
 turbostat_clean x86_energy_perf_policy_clean intel-speed-select_clean:
 	$(call descend,power/x86/$(@:_clean=),clean)
 
+thermometer_clean:
+	$(call descend,thermal/thermometer,clean)
+
 tmon_clean:
 	$(call descend,thermal/tmon,clean)
 
@@ -187,6 +197,6 @@ clean: acpi_clean cgroup_clean counter_clean cpupower_clean hv_clean firewire_cl
 		vm_clean bpf_clean iio_clean x86_energy_perf_policy_clean tmon_clean \
 		freefall_clean build_clean libbpf_clean libsubcmd_clean \
 		gpio_clean objtool_clean leds_clean wmi_clean pci_clean firmware_clean debugging_clean \
-		intel-speed-select_clean tracing_clean thermal_clean
+		intel-speed-select_clean tracing_clean thermal_clean thermometer_clean
 
 .PHONY: FORCE
tools/thermal/thermometer/Build new file +2 -0
new file mode 100644
index 000000000000..2531dda4acdd
@@ -0,0 +1,2 @@
+thermometer-y += thermometer.o
+
tools/thermal/thermometer/Makefile new file +26 -0
new file mode 100644
index 000000000000..d8f8bc82fe3b
@@ -0,0 +1,26 @@
+# SPDX-License-Identifier: GPL-2.0
+# Makefile for cgroup tools
+
+ifeq ($(srctree),)
+srctree := $(patsubst %/,%,$(dir $(CURDIR)))
+srctree := $(patsubst %/,%,$(dir $(srctree)))
+srctree := $(patsubst %/,%,$(dir $(srctree)))
+# $(info Determined 'srctree' to be $(srctree))
+endif
+
+CFLAGS = -Wall -Wextra
+CFLAGS += -I$(srctree)/tools/thermal/lib
+
+LDFLAGS = -L$(srctree)/tools/thermal/lib
+LDFLAGS += -lthermal_tools
+LDFLAGS += -lconfig
+
+VERSION = 0.0.1
+TARGET=thermometer
+
+all: $(TARGET)
+%: %.c
+	$(CC) $(CFLAGS) -D VERSION=\"$(VERSION)\" -o $@ $^ $(LDFLAGS)
+
+clean:
+	$(RM) $(TARGET)
tools/thermal/thermometer/thermometer.8 new file +93 -0

93 lines not on this page · raw message

tools/thermal/thermometer/thermometer.c new file +558 -0

558 lines not on this page · raw message

tools/thermal/thermometer/thermometer.conf new file +5 -0
new file mode 100644
index 000000000000..456aa269c1b7
@@ -0,0 +1,5 @@
+
+thermal-zones = (
+	      {	name = "cluster1-thermal";
+	      	polling = 100; }
+      )
Signature · 1 line
2.25.1
#4 lore raw

PATCH v2 4/4 tools/thermal: Add thermal daemon skeleton

In reply to Daniel Lezcano

This change provides a simple daemon skeleton. It is an example of how to use the thermal library which wraps all the complex code related to the netlink and transforms it into a callback oriented code.

The goal of this skeleton is to give a base brick for anyone interested in writing its own thermal engine or as an example to rely on to write its own thermal monitoring implementation.

In the future, it will evolve with more features and hopefully more logic.

---
 tools/Makefile                                |  16 +-
 tools/thermal/thermal-engine/Build            |   2 +
 tools/thermal/thermal-engine/Makefile         |  28 ++
 tools/thermal/thermal-engine/thermal-engine.c | 326 ++++++++++++++++++
 4 files changed, 369 insertions(+), 3 deletions(-)
 create mode 100644 tools/thermal/thermal-engine/Build
 create mode 100644 tools/thermal/thermal-engine/Makefile
 create mode 100644 tools/thermal/thermal-engine/thermal-engine.c
tools/Makefile +13 -3
index 78615f8cb463..b71cf39d3c08 100644
@@ -32,6 +32,7 @@ help:
 	@echo '  spi                    - spi tools'
 	@echo '  tmon                   - thermal monitoring and tuning tool'
 	@echo '  thermometer            - temperature capture tool'
+	@echo '  thermal-engine         - thermal monitoring tool'
 	@echo '  thermal                - thermal library'
 	@echo '  tracing                - misc tracing tools'
 	@echo '  turbostat              - Intel CPU idle stats and freq reporting tool'
@@ -99,6 +100,9 @@ tmon: FORCE
 thermometer: FORCE
 	$(call descend,thermal/$@)
 
+thermal-engine: FORCE thermal
+	$(call descend,thermal/$@)
+
 freefall: FORCE
 	$(call descend,laptop/$@)
 
@@ -109,7 +113,7 @@ all: acpi cgroup counter cpupower gpio hv firewire \
 		perf selftests bootconfig spi turbostat usb \
 		virtio vm bpf x86_energy_perf_policy \
 		tmon freefall iio objtool kvm_stat wmi \
-		pci debugging tracing thermal thermometer
+		pci debugging tracing thermal thermometer thermal-engine
 
 acpi_install:
 	$(call descend,power/$(@:_install=),install)
@@ -135,6 +139,9 @@ tmon_install:
 thermometer_install:
 	$(call descend,thermal/$(@:_install=),install)
 
+thermal-engine_install:
+	$(call descend,thermal/$(@:_install=),install)
+
 freefall_install:
 	$(call descend,laptop/$(@:_install=),install)
 
@@ -147,7 +154,7 @@ install: acpi_install cgroup_install counter_install cpupower_install gpio_insta
 		virtio_install vm_install bpf_install x86_energy_perf_policy_install \
 		tmon_install freefall_install objtool_install kvm_stat_install \
 		wmi_install pci_install debugging_install intel-speed-select_install \
-		tracing_install thermometer_install
+		tracing_install thermometer_install thermal-engine_install
 
 acpi_clean:
 	$(call descend,power/acpi,clean)
@@ -183,6 +190,9 @@ turbostat_clean x86_energy_perf_policy_clean intel-speed-select_clean:
 thermometer_clean:
 	$(call descend,thermal/thermometer,clean)
 
+thermal-engine_clean:
+	$(call descend,thermal/thermal-engine,clean)
+
 tmon_clean:
 	$(call descend,thermal/tmon,clean)
 
@@ -197,6 +207,6 @@ clean: acpi_clean cgroup_clean counter_clean cpupower_clean hv_clean firewire_cl
 		vm_clean bpf_clean iio_clean x86_energy_perf_policy_clean tmon_clean \
 		freefall_clean build_clean libbpf_clean libsubcmd_clean \
 		gpio_clean objtool_clean leds_clean wmi_clean pci_clean firmware_clean debugging_clean \
-		intel-speed-select_clean tracing_clean thermal_clean thermometer_clean
+		intel-speed-select_clean tracing_clean thermal_clean thermometer_clean thermal-engine_clean
 
 .PHONY: FORCE
tools/thermal/thermal-engine/Build new file +2 -0
new file mode 100644
index 000000000000..0c8b65248c80
@@ -0,0 +1,2 @@
+thermal-engine-y += thermal-engine.o
+
tools/thermal/thermal-engine/Makefile new file +28 -0
new file mode 100644
index 000000000000..6bd05ff89485
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: GPL-2.0
+# Makefile for thermal tools
+
+ifeq ($(srctree),)
+srctree := $(patsubst %/,%,$(dir $(CURDIR)))
+srctree := $(patsubst %/,%,$(dir $(srctree)))
+srctree := $(patsubst %/,%,$(dir $(srctree)))
+# $(info Determined 'srctree' to be $(srctree))
+endif
+
+CFLAGS = -Wall -Wextra
+CFLAGS += -I$(srctree)/tools/thermal/lib
+CFLAGS += -I$(srctree)/tools/lib/thermal/include
+
+LDFLAGS = -L$(srctree)/tools/thermal/lib
+LDFLAGS += -L$(srctree)/tools/lib/thermal
+LDFLAGS += -lthermal_tools
+LDFLAGS += -lthermal
+LDFLAGS += -lconfig
+LDFLAGS += -lnl-genl-3 -lnl-3
+
+VERSION = 0.0.1
+
+all: thermal-engine
+%: %.c
+	$(CC) $(CFLAGS) -D VERSION=\"$(VERSION)\" -o $@ $^ $(LDFLAGS)
+clean:
+	$(RM) thermal-engine
tools/thermal/thermal-engine/thermal-engine.c new file +326 -0

326 lines not on this page · raw message

Signature · 1 line
2.25.1
#5 lore raw
In reply to Daniel Lezcano

Hi,

if there is no comment for the series, shall I pick it so we can go forward ?

Quoted 118 lines · Daniel Lezcano

These changes are providing the following tools and library:

- A thermal library doing the netlink abstraction from the kernel in order to make the userspace thermal implementation easier. Having the library integrated with the kernel tree is also a guarantee to keep the message format and their encoding/decoding aligned

- A thermal tools library providing a set of functions to deal with usual features like the log, the mainloop and the time. This library is used by the provided tools below

- An data acquisition program to capture the temperature of the different thermal zone during an amount of time or during the execution of an application. The output is formated to be easily parsed by gnuplot, a spreadsheet program or a statistical command line utility. The timestamp is based on the system uptime, thus giving an indication of when a thermal event happened, that can help to spot or reproduce thermal issue in the long run

- A thermal monitoring program based on the thermal library. It gives a skeleton to build any logic on top of it and shows how to use the thermal library. It does nothing except discovering the thermal zones, their trip points and listening for events like cooling devices state changes or trip point crossed

Changelog:

v1: Initial post after a RFC

v2:

- Fixed all trailing whitespaces and some other checkpatch warnings. Some warnings remain but they can be considered as false positive

- Added in the thermometer tool:
- Usage/help option as well as a man page
- The ability to execute a program
- The capture duration
- Create the output directory if it does not exist

- Add in the thermal-engine tool:
- A usage/help option
- A message telling the userspace it is waiting for events
- A daemonize option

- Minor bug fixes here and there, as well as typos

Daniel Lezcano (4):
tools/lib/thermal: Add a thermal library
tools/thermal: Add util library
tools/thermal: A temperature capture tool
tools/thermal: Add thermal daemon skeleton

  MAINTAINERS                                   |   1 +
  tools/Makefile                                |  36 +-
  tools/lib/thermal/.gitignore                  |   2 +
  tools/lib/thermal/Build                       |   5 +
  tools/lib/thermal/Makefile                    | 165 ++++++
  tools/lib/thermal/commands.c                  | 349 +++++++++++
  tools/lib/thermal/events.c                    | 164 +++++
  tools/lib/thermal/include/thermal.h           | 142 +++++
  tools/lib/thermal/libthermal.map              |  25 +
  tools/lib/thermal/libthermal.pc.template      |  12 +
  tools/lib/thermal/sampling.c                  |  75 +++
  tools/lib/thermal/thermal.c                   | 126 ++++
  tools/lib/thermal/thermal_nl.c                | 215 +++++++
  tools/lib/thermal/thermal_nl.h                |  46 ++
  tools/thermal/lib/Build                       |   3 +
  tools/thermal/lib/Makefile                    | 158 +++++
  .../thermal/lib/libthermal_tools.pc.template  |  12 +
  tools/thermal/lib/log.c                       |  77 +++
  tools/thermal/lib/log.h                       |  31 +
  tools/thermal/lib/mainloop.c                  | 120 ++++
  tools/thermal/lib/mainloop.h                  |  15 +
  tools/thermal/lib/thermal-tools.h             |  10 +
  tools/thermal/lib/uptimeofday.c               |  40 ++
  tools/thermal/lib/uptimeofday.h               |  12 +
  tools/thermal/thermal-engine/Build            |   2 +
  tools/thermal/thermal-engine/Makefile         |  28 +
  tools/thermal/thermal-engine/thermal-engine.c | 326 ++++++++++
  tools/thermal/thermometer/Build               |   2 +
  tools/thermal/thermometer/Makefile            |  26 +
  tools/thermal/thermometer/thermometer.8       |  93 +++
  tools/thermal/thermometer/thermometer.c       | 558 ++++++++++++++++++
  tools/thermal/thermometer/thermometer.conf    |   5 +
  32 files changed, 2878 insertions(+), 3 deletions(-)

create mode 100644 tools/lib/thermal/.gitignore
create mode 100644 tools/lib/thermal/Build
create mode 100644 tools/lib/thermal/Makefile
create mode 100644 tools/lib/thermal/commands.c
create mode 100644 tools/lib/thermal/events.c
create mode 100644 tools/lib/thermal/include/thermal.h create mode 100644 tools/lib/thermal/libthermal.map create mode 100644 tools/lib/thermal/libthermal.pc.template create mode 100644 tools/lib/thermal/sampling.c
create mode 100644 tools/lib/thermal/thermal.c
create mode 100644 tools/lib/thermal/thermal_nl.c create mode 100644 tools/lib/thermal/thermal_nl.h create mode 100644 tools/thermal/lib/Build
create mode 100644 tools/thermal/lib/Makefile
create mode 100644 tools/thermal/lib/libthermal_tools.pc.template create mode 100644 tools/thermal/lib/log.c
create mode 100644 tools/thermal/lib/log.h
create mode 100644 tools/thermal/lib/mainloop.c
create mode 100644 tools/thermal/lib/mainloop.h
create mode 100644 tools/thermal/lib/thermal-tools.h create mode 100644 tools/thermal/lib/uptimeofday.c create mode 100644 tools/thermal/lib/uptimeofday.h create mode 100644 tools/thermal/thermal-engine/Build create mode 100644 tools/thermal/thermal-engine/Makefile create mode 100644 tools/thermal/thermal-engine/thermal-engine.c create mode 100644 tools/thermal/thermometer/Build create mode 100644 tools/thermal/thermometer/Makefile create mode 100644 tools/thermal/thermometer/thermometer.8 create mode 100644 tools/thermal/thermometer/thermometer.c create mode 100644 tools/thermal/thermometer/thermometer.conf

Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#6 lore raw

Hi Daniel,

Quoted 5 lines · Daniel Lezcano

Hi,

if there is no comment for the series, shall I pick it so we can go forward ?

Didn't get time to check yet. It will still be for the next merge window, correct?

Thanks,
Srinivas

Quoted 138 lines · Daniel Lezcano
Quoted 132 lines

These changes are providing the following tools and library:

  - A thermal library doing the netlink abstraction from the kernel in
    order to make the userspace thermal implementation easier. Having
    the library integrated with the kernel tree is also a guarantee to
    keep the message format and their encoding/decoding aligned




  - A thermal tools library providing a set of functions to deal with
    usual features like the log, the mainloop and the time. This library is used by the provided tools below

  - An data acquisition program to capture the temperature of the different thermal zone during an amount of time or during the execution of an application. The output is formated to be easily
    parsed by gnuplot, a spreadsheet program or a statistical command
    line utility. The timestamp is based on the system uptime, thus giving an indication of when a thermal event happened, that can help to spot or reproduce thermal issue in the long run

  - A thermal monitoring program based on the thermal library. It gives
    a skeleton to build any logic on top of it and shows how to use the
    thermal library. It does nothing except discovering the thermal zones, their trip points and listening for events like cooling devices state changes or trip point crossed

  Changelog:

  v1: Initial post after a RFC

  v2:

   - Fixed all trailing whitespaces and some other checkpatch warnings. Some warnings remain but they can be considered as false
     positive

   - Added in the thermometer tool:
     - Usage/help option as well as a man page
     - The ability to execute a program
     - The capture duration
     - Create the output directory if it does not exist

   - Add in the thermal-engine tool:
     - A usage/help option
     - A message telling the userspace it is waiting for events
     - A daemonize option

   - Minor bug fixes here and there, as well as typos

Daniel Lezcano (4):
   tools/lib/thermal: Add a thermal library
   tools/thermal: Add util library
   tools/thermal: A temperature capture tool
   tools/thermal: Add thermal daemon skeleton

  MAINTAINERS                                   |   1 + tools/Makefile                                |  36 +- tools/lib/thermal/.gitignore                  |   2 + tools/lib/thermal/Build                       |   5 + tools/lib/thermal/Makefile                    | 165 ++++++ tools/lib/thermal/commands.c                  | 349 +++++++++++ tools/lib/thermal/events.c                    | 164 +++++ tools/lib/thermal/include/thermal.h           | 142 +++++ tools/lib/thermal/libthermal.map              |  25 + tools/lib/thermal/libthermal.pc.template      |  12 + tools/lib/thermal/sampling.c                  |  75 +++ tools/lib/thermal/thermal.c                   | 126 ++++ tools/lib/thermal/thermal_nl.c                | 215 +++++++ tools/lib/thermal/thermal_nl.h                |  46 ++ tools/thermal/lib/Build                       |   3 + tools/thermal/lib/Makefile                    | 158 +++++ .../thermal/lib/libthermal_tools.pc.template  |  12 + tools/thermal/lib/log.c                       |  77 +++ tools/thermal/lib/log.h                       |  31 + tools/thermal/lib/mainloop.c                  | 120 ++++ tools/thermal/lib/mainloop.h                  |  15 + tools/thermal/lib/thermal-tools.h             |  10 + tools/thermal/lib/uptimeofday.c               |  40 ++ tools/thermal/lib/uptimeofday.h               |  12 + tools/thermal/thermal-engine/Build            |   2 + tools/thermal/thermal-engine/Makefile         |  28 + tools/thermal/thermal-engine/thermal-engine.c | 326 ++++++++++ tools/thermal/thermometer/Build               |   2 + tools/thermal/thermometer/Makefile            |  26 + tools/thermal/thermometer/thermometer.8       |  93 +++ tools/thermal/thermometer/thermometer.c       | 558
++++++++++++++++++
  tools/thermal/thermometer/thermometer.conf    |   5 +

  32 files changed, 2878 insertions(+), 3 deletions(-)

  create mode 100644 tools/lib/thermal/.gitignore
  create mode 100644 tools/lib/thermal/Build
  create mode 100644 tools/lib/thermal/Makefile
  create mode 100644 tools/lib/thermal/commands.c
  create mode 100644 tools/lib/thermal/events.c
  create mode 100644 tools/lib/thermal/include/thermal.h create mode 100644 tools/lib/thermal/libthermal.map create mode 100644 tools/lib/thermal/libthermal.pc.template create mode 100644 tools/lib/thermal/sampling.c
  create mode 100644 tools/lib/thermal/thermal.c
  create mode 100644 tools/lib/thermal/thermal_nl.c create mode 100644 tools/lib/thermal/thermal_nl.h create mode 100644 tools/thermal/lib/Build
  create mode 100644 tools/thermal/lib/Makefile
  create mode 100644 tools/thermal/lib/libthermal_tools.pc.template create mode 100644 tools/thermal/lib/log.c
  create mode 100644 tools/thermal/lib/log.h
  create mode 100644 tools/thermal/lib/mainloop.c
  create mode 100644 tools/thermal/lib/mainloop.h
  create mode 100644 tools/thermal/lib/thermal-tools.h create mode 100644 tools/thermal/lib/uptimeofday.c create mode 100644 tools/thermal/lib/uptimeofday.h create mode 100644 tools/thermal/thermal-engine/Build create mode 100644 tools/thermal/thermal-engine/Makefile create mode 100644 tools/thermal/thermal-engine/thermal-engine.c create mode 100644 tools/thermal/thermometer/Build create mode 100644 tools/thermal/thermometer/Makefile create mode 100644 tools/thermal/thermometer/thermometer.8 create mode 100644 tools/thermal/thermometer/thermometer.c create mode 100644 tools/thermal/thermometer/thermometer.conf

#7 lore raw
Quoted 10 lines · srinivas pandruvada

Hi Daniel,

Quoted 5 lines · Daniel Lezcano

Hi,

if there is no comment for the series, shall I pick it so we can go forward ?

Didn't get time to check yet. It will still be for the next merge window, correct?

Right, but I would like to continue adding more features, scripts and tests. Iteratively.

Quoted 138 lines
Quoted 136 lines · Daniel Lezcano
Quoted 132 lines

These changes are providing the following tools and library:

  - A thermal library doing the netlink abstraction from the kernel
in
    order to make the userspace thermal implementation easier.
Having
    the library integrated with the kernel tree is also a guarantee
to
    keep the message format and their encoding/decoding aligned

  - A thermal tools library providing a set of functions to deal
with
    usual features like the log, the mainloop and the time. This library is used by the provided tools below

  - An data acquisition program to capture the temperature of the different thermal zone during an amount of time or during the execution of an application. The output is formated to be
easily
    parsed by gnuplot, a spreadsheet program or a statistical
command
    line utility. The timestamp is based on the system uptime, thus giving an indication of when a thermal event happened, that can help to spot or reproduce thermal issue in the long run

  - A thermal monitoring program based on the thermal library. It
gives
    a skeleton to build any logic on top of it and shows how to use
the
    thermal library. It does nothing except discovering the thermal zones, their trip points and listening for events like cooling devices state changes or trip point crossed

  Changelog:

  v1: Initial post after a RFC

  v2:

   - Fixed all trailing whitespaces and some other checkpatch warnings. Some warnings remain but they can be considered as
false
     positive

   - Added in the thermometer tool:
     - Usage/help option as well as a man page
     - The ability to execute a program
     - The capture duration
     - Create the output directory if it does not exist

   - Add in the thermal-engine tool:
     - A usage/help option
     - A message telling the userspace it is waiting for events
     - A daemonize option

   - Minor bug fixes here and there, as well as typos

Daniel Lezcano (4):
   tools/lib/thermal: Add a thermal library
   tools/thermal: Add util library
   tools/thermal: A temperature capture tool
   tools/thermal: Add thermal daemon skeleton

   MAINTAINERS                                   |   1 +
   tools/Makefile                                |  36 +-
   tools/lib/thermal/.gitignore                  |   2 +
   tools/lib/thermal/Build                       |   5 +
   tools/lib/thermal/Makefile                    | 165 ++++++
   tools/lib/thermal/commands.c                  | 349 +++++++++++
   tools/lib/thermal/events.c                    | 164 +++++
   tools/lib/thermal/include/thermal.h           | 142 +++++
   tools/lib/thermal/libthermal.map              |  25 +
   tools/lib/thermal/libthermal.pc.template      |  12 +
   tools/lib/thermal/sampling.c                  |  75 +++
   tools/lib/thermal/thermal.c                   | 126 ++++
   tools/lib/thermal/thermal_nl.c                | 215 +++++++
   tools/lib/thermal/thermal_nl.h                |  46 ++
   tools/thermal/lib/Build                       |   3 +
   tools/thermal/lib/Makefile                    | 158 +++++
   .../thermal/lib/libthermal_tools.pc.template  |  12 +
   tools/thermal/lib/log.c                       |  77 +++
   tools/thermal/lib/log.h                       |  31 +
   tools/thermal/lib/mainloop.c                  | 120 ++++
   tools/thermal/lib/mainloop.h                  |  15 +
   tools/thermal/lib/thermal-tools.h             |  10 +
   tools/thermal/lib/uptimeofday.c               |  40 ++
   tools/thermal/lib/uptimeofday.h               |  12 +
   tools/thermal/thermal-engine/Build            |   2 +
   tools/thermal/thermal-engine/Makefile         |  28 +
   tools/thermal/thermal-engine/thermal-engine.c | 326 ++++++++++
   tools/thermal/thermometer/Build               |   2 +
   tools/thermal/thermometer/Makefile            |  26 +
   tools/thermal/thermometer/thermometer.8       |  93 +++
   tools/thermal/thermometer/thermometer.c       | 558
++++++++++++++++++
   tools/thermal/thermometer/thermometer.conf    |   5 +
   32 files changed, 2878 insertions(+), 3 deletions(-)

  create mode 100644 tools/lib/thermal/.gitignore
  create mode 100644 tools/lib/thermal/Build
  create mode 100644 tools/lib/thermal/Makefile
  create mode 100644 tools/lib/thermal/commands.c
  create mode 100644 tools/lib/thermal/events.c
  create mode 100644 tools/lib/thermal/include/thermal.h create mode 100644 tools/lib/thermal/libthermal.map create mode 100644 tools/lib/thermal/libthermal.pc.template create mode 100644 tools/lib/thermal/sampling.c
  create mode 100644 tools/lib/thermal/thermal.c
  create mode 100644 tools/lib/thermal/thermal_nl.c create mode 100644 tools/lib/thermal/thermal_nl.h create mode 100644 tools/thermal/lib/Build
  create mode 100644 tools/thermal/lib/Makefile
  create mode 100644 tools/thermal/lib/libthermal_tools.pc.template create mode 100644 tools/thermal/lib/log.c
  create mode 100644 tools/thermal/lib/log.h
  create mode 100644 tools/thermal/lib/mainloop.c
  create mode 100644 tools/thermal/lib/mainloop.h
  create mode 100644 tools/thermal/lib/thermal-tools.h create mode 100644 tools/thermal/lib/uptimeofday.c create mode 100644 tools/thermal/lib/uptimeofday.h create mode 100644 tools/thermal/thermal-engine/Build create mode 100644 tools/thermal/thermal-engine/Makefile create mode 100644 tools/thermal/thermal-engine/thermal-engine.c create mode 100644 tools/thermal/thermometer/Build create mode 100644 tools/thermal/thermometer/Makefile create mode 100644 tools/thermal/thermometer/thermometer.8 create mode 100644 tools/thermal/thermometer/thermometer.c create mode 100644 tools/thermal/thermometer/thermometer.conf

Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#8 lore raw
Quoted 8 lines · Daniel Lezcano
Quoted 6 lines · srinivas pandruvada

Hi Daniel,

Quoted 3 lines · Daniel Lezcano

Hi,

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

if there is no comment for the series, shall I pick it so we can go forward ?

Didn't get time to check yet. It will still be for the next merge window, correct?

Right, but I would like to continue adding more features, scripts and tests. Iteratively.

Srinivas, if you can give this a go, please, it will help.

Otherwise, I think that all of your comments so far have been addressed, or have I missed anything?

Quoted 147 lines
Quoted 129 lines
Quoted 129 lines · Daniel Lezcano
Quoted 126 lines

These changes are providing the following tools and library:

- A thermal library doing the netlink abstraction from the kernel
in
order to make the userspace thermal implementation easier.
Having
the library integrated with the kernel tree is also a guarantee
to
keep the message format and their encoding/decoding aligned

- A thermal tools library providing a set of functions to deal
with
usual features like the log, the mainloop and the time. This library is used by the provided tools below

- An data acquisition program to capture the temperature of the different thermal zone during an amount of time or during the execution of an application. The output is formated to be
easily
parsed by gnuplot, a spreadsheet program or a statistical
command
line utility. The timestamp is based on the system uptime, thus giving an indication of when a thermal event happened, that can help to spot or reproduce thermal issue in the long run

- A thermal monitoring program based on the thermal library. It
gives
a skeleton to build any logic on top of it and shows how to use
the
thermal library. It does nothing except discovering the thermal zones, their trip points and listening for events like cooling devices state changes or trip point crossed

Changelog:

v1: Initial post after a RFC

v2:

- Fixed all trailing whitespaces and some other checkpatch warnings. Some warnings remain but they can be considered as
false
positive

- Added in the thermometer tool:
- Usage/help option as well as a man page
- The ability to execute a program
- The capture duration
- Create the output directory if it does not exist

- Add in the thermal-engine tool:
- A usage/help option
- A message telling the userspace it is waiting for events
- A daemonize option

- Minor bug fixes here and there, as well as typos

Daniel Lezcano (4):
tools/lib/thermal: Add a thermal library
tools/thermal: Add util library
tools/thermal: A temperature capture tool
tools/thermal: Add thermal daemon skeleton

   MAINTAINERS                                   |   1 +
   tools/Makefile                                |  36 +-
   tools/lib/thermal/.gitignore                  |   2 +
   tools/lib/thermal/Build                       |   5 +
   tools/lib/thermal/Makefile                    | 165 ++++++
   tools/lib/thermal/commands.c                  | 349 +++++++++++
   tools/lib/thermal/events.c                    | 164 +++++
   tools/lib/thermal/include/thermal.h           | 142 +++++
   tools/lib/thermal/libthermal.map              |  25 +
   tools/lib/thermal/libthermal.pc.template      |  12 +
   tools/lib/thermal/sampling.c                  |  75 +++
   tools/lib/thermal/thermal.c                   | 126 ++++
   tools/lib/thermal/thermal_nl.c                | 215 +++++++
   tools/lib/thermal/thermal_nl.h                |  46 ++
   tools/thermal/lib/Build                       |   3 +
   tools/thermal/lib/Makefile                    | 158 +++++
   .../thermal/lib/libthermal_tools.pc.template  |  12 +
   tools/thermal/lib/log.c                       |  77 +++
   tools/thermal/lib/log.h                       |  31 +
   tools/thermal/lib/mainloop.c                  | 120 ++++
   tools/thermal/lib/mainloop.h                  |  15 +
   tools/thermal/lib/thermal-tools.h             |  10 +
   tools/thermal/lib/uptimeofday.c               |  40 ++
   tools/thermal/lib/uptimeofday.h               |  12 +
   tools/thermal/thermal-engine/Build            |   2 +
   tools/thermal/thermal-engine/Makefile         |  28 +
   tools/thermal/thermal-engine/thermal-engine.c | 326 ++++++++++
   tools/thermal/thermometer/Build               |   2 +
   tools/thermal/thermometer/Makefile            |  26 +
   tools/thermal/thermometer/thermometer.8       |  93 +++
   tools/thermal/thermometer/thermometer.c       | 558
++++++++++++++++++
   tools/thermal/thermometer/thermometer.conf    |   5 +
   32 files changed, 2878 insertions(+), 3 deletions(-)

create mode 100644 tools/lib/thermal/.gitignore
create mode 100644 tools/lib/thermal/Build
create mode 100644 tools/lib/thermal/Makefile
create mode 100644 tools/lib/thermal/commands.c
create mode 100644 tools/lib/thermal/events.c
create mode 100644 tools/lib/thermal/include/thermal.h create mode 100644 tools/lib/thermal/libthermal.map create mode 100644 tools/lib/thermal/libthermal.pc.template create mode 100644 tools/lib/thermal/sampling.c
create mode 100644 tools/lib/thermal/thermal.c
create mode 100644 tools/lib/thermal/thermal_nl.c create mode 100644 tools/lib/thermal/thermal_nl.h create mode 100644 tools/thermal/lib/Build
create mode 100644 tools/thermal/lib/Makefile
create mode 100644 tools/thermal/lib/libthermal_tools.pc.template create mode 100644 tools/thermal/lib/log.c
create mode 100644 tools/thermal/lib/log.h
create mode 100644 tools/thermal/lib/mainloop.c
create mode 100644 tools/thermal/lib/mainloop.h
create mode 100644 tools/thermal/lib/thermal-tools.h create mode 100644 tools/thermal/lib/uptimeofday.c create mode 100644 tools/thermal/lib/uptimeofday.h create mode 100644 tools/thermal/thermal-engine/Build create mode 100644 tools/thermal/thermal-engine/Makefile create mode 100644 tools/thermal/thermal-engine/thermal-engine.c

Quoted 10 lines
Quoted 8 lines
Quoted 6 lines

create mode 100644 tools/thermal/thermometer/Build create mode 100644 tools/thermal/thermometer/Makefile create mode 100644 tools/thermal/thermometer/thermometer.8 create mode 100644 tools/thermal/thermometer/thermometer.c create mode 100644 tools/thermal/thermometer/thermometer.conf

--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

#9 lore raw
Quoted 16 lines · Rafael J. Wysocki
Quoted 14 lines · Daniel Lezcano
Quoted 11 lines · srinivas pandruvada

Hi Daniel,

Quoted 6 lines · Daniel Lezcano

Hi,

if there is no comment for the series, shall I pick it so we can go
forward ?

Didn't get time to check yet. It will still be for the next merge window, correct?

Quoted 9 lines
Quoted 3 lines

Right, but I would like to continue adding more features, scripts and
tests. Iteratively.

Srinivas, if you can give this a go, please, it will help.

Otherwise, I think that all of your comments so far have been addressed, or have I missed anything?

I will provide by the end of this week.

Thanks,
Srinivas

Quoted 174 lines
Quoted 174 lines
Quoted 155 lines
Quoted 155 lines · Daniel Lezcano
Quoted 152 lines

These changes are providing the following tools and library:

   - A thermal library doing the netlink abstraction from the kernel
in
     order to make the userspace thermal implementation easier.
Having
     the library integrated with the kernel tree is also a guarantee
to
     keep the message format and their encoding/decoding aligned

   - A thermal tools library providing a set of functions to deal
with
     usual features like the log, the mainloop and the time. This
     library is used by the provided tools below

   - An data acquisition program to capture the temperature of the
     different thermal zone during an amount of time or during the
     execution of an application. The output is formated to be
easily
     parsed by gnuplot, a spreadsheet program or a statistical
command
     line utility. The timestamp is based on the system uptime, thus
     giving an indication of when a thermal event happened, that can
     help to spot or reproduce thermal issue in the long run

   - A thermal monitoring program based on the thermal library. It
gives
     a skeleton to build any logic on top of it and shows how to use
the
     thermal library. It does nothing except discovering the thermal
     zones, their trip points and listening for events like cooling
     devices state changes or trip point crossed

   Changelog:

   v1: Initial post after a RFC

   v2:

    - Fixed all trailing whitespaces and some other checkpatch
      warnings. Some warnings remain but they can be considered as
false
      positive

    - Added in the thermometer tool:
      - Usage/help option as well as a man page
      - The ability to execute a program
      - The capture duration
      - Create the output directory if it does not exist

    - Add in the thermal-engine tool:
      - A usage/help option
      - A message telling the userspace it is waiting for events
      - A daemonize option

    - Minor bug fixes here and there, as well as typos

Daniel Lezcano (4):
    tools/lib/thermal: Add a thermal library
    tools/thermal: Add util library
    tools/thermal: A temperature capture tool
    tools/thermal: Add thermal daemon skeleton

   MAINTAINERS                                   |   1 + tools/Makefile                                |  36 +- tools/lib/thermal/.gitignore                  |   2 + tools/lib/thermal/Build                       |   5 + tools/lib/thermal/Makefile                    | 165 ++++++ tools/lib/thermal/commands.c                  | 349
+++++++++++
   tools/lib/thermal/events.c                    | 164 +++++ tools/lib/thermal/include/thermal.h           | 142 +++++ tools/lib/thermal/libthermal.map              |  25 + tools/lib/thermal/libthermal.pc.template      |  12 + tools/lib/thermal/sampling.c                  |  75 +++ tools/lib/thermal/thermal.c                   | 126 ++++ tools/lib/thermal/thermal_nl.c                | 215
+++++++
   tools/lib/thermal/thermal_nl.h                |  46 ++ tools/thermal/lib/Build                       |   3 + tools/thermal/lib/Makefile                    | 158 +++++ .../thermal/lib/libthermal_tools.pc.template  |  12 + tools/thermal/lib/log.c                       |  77 +++ tools/thermal/lib/log.h                       |  31 + tools/thermal/lib/mainloop.c                  | 120 ++++ tools/thermal/lib/mainloop.h                  |  15 + tools/thermal/lib/thermal-tools.h             |  10 + tools/thermal/lib/uptimeofday.c               |  40 ++ tools/thermal/lib/uptimeofday.h               |  12 + tools/thermal/thermal-engine/Build            |   2 + tools/thermal/thermal-engine/Makefile         |  28 + tools/thermal/thermal-engine/thermal-engine.c | 326
++++++++++
   tools/thermal/thermometer/Build               |   2 + tools/thermal/thermometer/Makefile            |  26 + tools/thermal/thermometer/thermometer.8       |  93 +++ tools/thermal/thermometer/thermometer.c       | 558
++++++++++++++++++
   tools/thermal/thermometer/thermometer.conf    |   5 +

   32 files changed, 2878 insertions(+), 3 deletions(-)

   create mode 100644 tools/lib/thermal/.gitignore create mode 100644 tools/lib/thermal/Build create mode 100644 tools/lib/thermal/Makefile create mode 100644 tools/lib/thermal/commands.c create mode 100644 tools/lib/thermal/events.c create mode 100644 tools/lib/thermal/include/thermal.h create mode 100644 tools/lib/thermal/libthermal.map create mode 100644 tools/lib/thermal/libthermal.pc.template
   create mode 100644 tools/lib/thermal/sampling.c create mode 100644 tools/lib/thermal/thermal.c create mode 100644 tools/lib/thermal/thermal_nl.c create mode 100644 tools/lib/thermal/thermal_nl.h create mode 100644 tools/thermal/lib/Build create mode 100644 tools/thermal/lib/Makefile create mode 100644 tools/thermal/lib/libthermal_tools.pc.template create mode 100644 tools/thermal/lib/log.c create mode 100644 tools/thermal/lib/log.h create mode 100644 tools/thermal/lib/mainloop.c create mode 100644 tools/thermal/lib/mainloop.h create mode 100644 tools/thermal/lib/thermal-tools.h create mode 100644 tools/thermal/lib/uptimeofday.c create mode 100644 tools/thermal/lib/uptimeofday.h create mode 100644 tools/thermal/thermal-engine/Build create mode 100644 tools/thermal/thermal-engine/Makefile create mode 100644 tools/thermal/thermal-engine/thermal- engine.c
   create mode 100644 tools/thermal/thermometer/Build

Quoted 10 lines
Quoted 8 lines
Quoted 6 lines

   create mode 100644 tools/thermal/thermometer/Makefile create mode 100644 tools/thermal/thermometer/thermometer.8 create mode 100644 tools/thermal/thermometer/thermometer.c create mode 100644 tools/thermal/thermometer/thermometer.conf

--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

#10 lore raw
Quoted 21 lines · srinivas pandruvada
Quoted 20 lines · Rafael J. Wysocki
Quoted 17 lines · Daniel Lezcano
Quoted 11 lines · srinivas pandruvada

Hi Daniel,

Quoted 6 lines · Daniel Lezcano

Hi,

if there is no comment for the series, shall I pick it so we can go
forward ?

Didn't get time to check yet. It will still be for the next merge window, correct?

Right, but I would like to continue adding more features, scripts and
tests. Iteratively.

Quoted 6 lines
Quoted 5 lines

Srinivas, if you can give this a go, please, it will help.

Otherwise, I think that all of your comments so far have been addressed, or have I missed anything?

I will provide by the end of this week.

1. Some warnings in applying patch

Applying: tools/lib/thermal: Add a thermal library
Applying: tools/thermal: Add util library
Applying: tools/thermal: A temperature capture tool .git/rebase-apply/patch:795: space before tab in indent.

	      	polling = 100; }

.git/rebase-apply/patch:90: new blank line at EOF. +
.git/rebase-apply/patch:221: new blank line at EOF. +
warning: 3 lines add whitespace errors.
Applying: tools/thermal: Add thermal daemon skeleton .git/rebase-apply/patch:86: new blank line at EOF. +
warning: 1 line adds whitespace errors.

2. Thermometer is fine

3. segfault for thermal-engine

LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH ./thermal- engine
Segmentation fault (core dumped) root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/thermal- engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH ./thermal-engine --help
thermal-engine : A thermal monitoring engine based on notifications
Usage: thermal-engine [options]

	-h, --help		this help
	-d, --daemonize	capture duration
	-l <level>, --loglevel <level>	log level: DEBUG, INFO,
NOTICE, WARN, ERROR
	-s, --syslog		output to syslog

root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/thermal- engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH ./thermal-engine -l DEBUG
Segmentation fault (core dumped) root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/thermal- engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH ./thermal-engine --loglevel DEBUG
Segmentation fault (core dumped) root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/thermal- engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH ./thermal-engine -s
Segmentation fault (core dumped)

Thanks,
Srinivas

Quoted 181 lines

Thanks,
Srinivas

Quoted 174 lines
Quoted 174 lines
Quoted 155 lines
Quoted 155 lines · Daniel Lezcano
Quoted 152 lines

These changes are providing the following tools and library:

   - A thermal library doing the netlink abstraction from the kernel
in
     order to make the userspace thermal implementation easier.
Having
     the library integrated with the kernel tree is also a guarantee
to
     keep the message format and their encoding/decoding aligned

   - A thermal tools library providing a set of functions to deal
with
     usual features like the log, the mainloop and the time. This
     library is used by the provided tools below

   - An data acquisition program to capture the temperature of the
     different thermal zone during an amount of time or during the
     execution of an application. The output is formated to be
easily
     parsed by gnuplot, a spreadsheet program or a statistical
command
     line utility. The timestamp is based on the system uptime, thus
     giving an indication of when a thermal event happened, that can
     help to spot or reproduce thermal issue in the long run

   - A thermal monitoring program based on the thermal library. It
gives
     a skeleton to build any logic on top of it and shows how to use
the
     thermal library. It does nothing except discovering the thermal
     zones, their trip points and listening for events like cooling
     devices state changes or trip point crossed

   Changelog:

   v1: Initial post after a RFC

   v2:

    - Fixed all trailing whitespaces and some other checkpatch
      warnings. Some warnings remain but they can be considered as
false
      positive

    - Added in the thermometer tool:
      - Usage/help option as well as a man page
      - The ability to execute a program
      - The capture duration
      - Create the output directory if it does not exist

    - Add in the thermal-engine tool:
      - A usage/help option
      - A message telling the userspace it is waiting for events
      - A daemonize option

    - Minor bug fixes here and there, as well as typos

Daniel Lezcano (4):
    tools/lib/thermal: Add a thermal library
    tools/thermal: Add util library
    tools/thermal: A temperature capture tool
    tools/thermal: Add thermal daemon skeleton

   MAINTAINERS                                   |   1 + tools/Makefile                                |  36 +- tools/lib/thermal/.gitignore                  |   2 + tools/lib/thermal/Build                       |   5 + tools/lib/thermal/Makefile                    | 165 ++++++ tools/lib/thermal/commands.c                  | 349
+++++++++++
   tools/lib/thermal/events.c                    | 164 +++++ tools/lib/thermal/include/thermal.h           | 142 +++++ tools/lib/thermal/libthermal.map              |  25 + tools/lib/thermal/libthermal.pc.template      |  12 + tools/lib/thermal/sampling.c                  |  75 +++ tools/lib/thermal/thermal.c                   | 126 ++++ tools/lib/thermal/thermal_nl.c                | 215
+++++++
   tools/lib/thermal/thermal_nl.h                |  46 ++ tools/thermal/lib/Build                       |   3 + tools/thermal/lib/Makefile                    | 158 +++++ .../thermal/lib/libthermal_tools.pc.template  |  12 + tools/thermal/lib/log.c                       |  77 +++ tools/thermal/lib/log.h                       |  31 + tools/thermal/lib/mainloop.c                  | 120 ++++ tools/thermal/lib/mainloop.h                  |  15 + tools/thermal/lib/thermal-tools.h             |  10 + tools/thermal/lib/uptimeofday.c               |  40 ++ tools/thermal/lib/uptimeofday.h               |  12 + tools/thermal/thermal-engine/Build            |   2 + tools/thermal/thermal-engine/Makefile         |  28 + tools/thermal/thermal-engine/thermal-engine.c | 326
++++++++++
   tools/thermal/thermometer/Build               |   2 + tools/thermal/thermometer/Makefile            |  26 + tools/thermal/thermometer/thermometer.8       |  93 +++ tools/thermal/thermometer/thermometer.c       | 558
++++++++++++++++++
   tools/thermal/thermometer/thermometer.conf    |   5 +

   32 files changed, 2878 insertions(+), 3 deletions(-)

   create mode 100644 tools/lib/thermal/.gitignore create mode 100644 tools/lib/thermal/Build create mode 100644 tools/lib/thermal/Makefile create mode 100644 tools/lib/thermal/commands.c create mode 100644 tools/lib/thermal/events.c create mode 100644 tools/lib/thermal/include/thermal.h create mode 100644 tools/lib/thermal/libthermal.map create mode 100644 tools/lib/thermal/libthermal.pc.template
   create mode 100644 tools/lib/thermal/sampling.c create mode 100644 tools/lib/thermal/thermal.c create mode 100644 tools/lib/thermal/thermal_nl.c create mode 100644 tools/lib/thermal/thermal_nl.h create mode 100644 tools/thermal/lib/Build create mode 100644 tools/thermal/lib/Makefile create mode 100644 tools/thermal/lib/libthermal_tools.pc.template create mode 100644 tools/thermal/lib/log.c create mode 100644 tools/thermal/lib/log.h create mode 100644 tools/thermal/lib/mainloop.c create mode 100644 tools/thermal/lib/mainloop.h create mode 100644 tools/thermal/lib/thermal-tools.h create mode 100644 tools/thermal/lib/uptimeofday.c create mode 100644 tools/thermal/lib/uptimeofday.h create mode 100644 tools/thermal/thermal-engine/Build create mode 100644 tools/thermal/thermal-engine/Makefile create mode 100644 tools/thermal/thermal-engine/thermal- engine.c
   create mode 100644 tools/thermal/thermometer/Build

Quoted 10 lines
Quoted 8 lines
Quoted 6 lines

   create mode 100644 tools/thermal/thermometer/Makefile create mode 100644 tools/thermal/thermometer/thermometer.8 create mode 100644 tools/thermal/thermometer/thermometer.c create mode 100644 tools/thermal/thermometer/thermometer.conf

--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

#11 lore raw

Hi Srinivas,

Quoted 36 lines · srinivas pandruvada
Quoted 21 lines · srinivas pandruvada
Quoted 20 lines · Rafael J. Wysocki
Quoted 17 lines · Daniel Lezcano
Quoted 11 lines · srinivas pandruvada

Hi Daniel,

Quoted 6 lines · Daniel Lezcano

Hi,

if there is no comment for the series, shall I pick it so we can go
forward ?

Didn't get time to check yet. It will still be for the next merge window, correct?

Right, but I would like to continue adding more features, scripts and
tests. Iteratively.

Quoted 6 lines
Quoted 5 lines

Srinivas, if you can give this a go, please, it will help.

Otherwise, I think that all of your comments so far have been addressed, or have I missed anything?

I will provide by the end of this week.

1. Some warnings in applying patch

Applying: tools/lib/thermal: Add a thermal library
Applying: tools/thermal: Add util library
Applying: tools/thermal: A temperature capture tool .git/rebase-apply/patch:795: space before tab in indent.

	      	polling = 100; }
Quoted 9 lines

.git/rebase-apply/patch:90: new blank line at EOF. +
.git/rebase-apply/patch:221: new blank line at EOF. +
warning: 3 lines add whitespace errors.
Applying: tools/thermal: Add thermal daemon skeleton .git/rebase-apply/patch:86: new blank line at EOF. +
warning: 1 line adds whitespace errors.

Strange, I did not have those but I'll try to reproduce

Quoted 18 lines

2. Thermometer is fine

3. segfault for thermal-engine

LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH ./thermal- engine
Segmentation fault (core dumped) root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/thermal- engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH ./thermal-engine --help
thermal-engine : A thermal monitoring engine based on notifications
Usage: thermal-engine [options]

	-h, --help		this help
	-d, --daemonize	capture duration
	-l <level>, --loglevel <level>	log level: DEBUG, INFO,
NOTICE, WARN, ERROR
	-s, --syslog		output to syslog
Quoted 12 lines

root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/thermal- engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH ./thermal-engine -l DEBUG
Segmentation fault (core dumped) root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/thermal- engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH ./thermal-engine --loglevel DEBUG
Segmentation fault (core dumped) root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/thermal- engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH ./thermal-engine -s
Segmentation fault (core dumped)

Is CONFIG_THERMAL_NETLINK set ?

Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#12 lore raw

Hi Daniel,

Quoted 11 lines · Daniel Lezcano

Hi Srinivas,

Quoted 6 lines · srinivas pandruvada
Quoted 4 lines · srinivas pandruvada
Quoted 3 lines · Rafael J. Wysocki
Quoted 1 line · Daniel Lezcano

[...]

Quoted 13 lines
Quoted 4 lines

root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/thermal- engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH ./thermal-engine -l DEBUG
Segmentation fault (core dumped)

Quoted 8 lines

root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/thermal- engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH ./thermal-engine --loglevel DEBUG
Segmentation fault (core dumped) root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/thermal- engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH ./thermal-engine -s
Segmentation fault (core dumped)

Quoted 1 line

Is CONFIG_THERMAL_NETLINK set ?

Yes, Thermometer program works fine. Just thermal-engine fails. CONFIG_THERMAL=y
CONFIG_THERMAL_NETLINK=y
CONFIG_THERMAL_STATISTICS=y CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS=0 CONFIG_THERMAL_HWMON=y CONFIG_THERMAL_WRITABLE_TRIPS=y CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y
# CONFIG_THERMAL_DEFAULT_GOV_FAIR_SHARE is not set
# CONFIG_THERMAL_DEFAULT_GOV_USER_SPACE is not set CONFIG_THERMAL_GOV_FAIR_SHARE=y CONFIG_THERMAL_GOV_STEP_WISE=y CONFIG_THERMAL_GOV_BANG_BANG=y CONFIG_THERMAL_GOV_USER_SPACE=y CONFIG_DEVFREQ_THERMAL=y
CONFIG_THERMAL_EMULATION=y

This may help

#gdb ./thermal-engine
GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"... Reading symbols from ./thermal-engine...(no debugging symbols found)...done.
(gdb) run
Starting program:
/home/labuser/development/linux/tools/thermal/thermal-engine/thermal- engine
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux- gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7402036 in parse_tz_get_trip (info=0x7fffffffdf60, tz=0x555555607898) at commands.c:143
143 __tt[size].id = -1;
(gdb) backtrace
#0 0x00007ffff7402036 in parse_tz_get_trip (info=0x7fffffffdf60, tz=0x555555607898) at commands.c:143
#1 0x00007ffff7402233 in handle_netlink (unused=0x0, cmd=0x7ffff76052f8 <thermal_cmds+120>, info=0x7fffffffdf60, arg=0x555555607898) at commands.c:206
#2 0x00007ffff7003435 in ?? () from /lib/x86_64-linux-gnu/libnl-genl- 3.so.200
#3 0x00007ffff6810c1c in nl_recvmsgs_report () from /lib/x86_64-linux- gnu/libnl-3.so.200
#4 0x00007ffff6811049 in nl_recvmsgs () from /lib/x86_64-linux- gnu/libnl-3.so.200
#5 0x00007ffff7402eaf in nl_send_msg (sock=0x555555606040, cb=0x5555556065d0, msg=0x555555606110, rx_handler=0x7ffff70036f0 <genl_handle_msg>, data=0x555555607898) at thermal_nl.c:70 #6 0x00007ffff7402327 in thermal_genl_auto (th=0x5555556048a0, id=1, cmd=2, flags=0, arg=0x555555607898) at commands.c:282
#7 0x00007ffff74023e0 in thermal_cmd_get_trip (th=0x5555556048a0, tz=0x555555607898) at commands.c:304
#8 0x00007ffff74039db in __thermal_zone_discover (tz=0x555555607898, th=0x5555556048a0) at thermal.c:71
#9 0x00007ffff7403842 in for_each_thermal_zone (tz=0x555555607860, cb=0x7ffff74039b8 <__thermal_zone_discover>, arg=0x5555556048a0) at thermal.c:33
#10 0x00007ffff7403a5b in thermal_zone_discover (th=0x5555556048a0) at thermal.c:87
#11 0x00005555554019bd in main ()

Thanks,
Srinivas

Quoted 1 line
#13 lore raw

Hi Srinivas,

thanks for the information. I've indeed not tested on x86_64 but on ARM64.

I'll give a try to reproduce and fix the issue.

Thanks again for taking the time to run it

-- Daniel

Quoted 116 lines · srinivas pandruvada

Hi Daniel,

Quoted 11 lines · Daniel Lezcano

Hi Srinivas,

Quoted 6 lines · srinivas pandruvada
Quoted 4 lines · srinivas pandruvada
Quoted 3 lines · Rafael J. Wysocki
Quoted 1 line · Daniel Lezcano

[...]

Quoted 13 lines
Quoted 4 lines

root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/thermal- engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH ./thermal-engine -l DEBUG
Segmentation fault (core dumped)

Quoted 8 lines

root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/thermal- engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH ./thermal-engine --loglevel DEBUG
Segmentation fault (core dumped) root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/thermal- engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH ./thermal-engine -s
Segmentation fault (core dumped)

Quoted 1 line

Is CONFIG_THERMAL_NETLINK set ?

Yes, Thermometer program works fine. Just thermal-engine fails. CONFIG_THERMAL=y
CONFIG_THERMAL_NETLINK=y
CONFIG_THERMAL_STATISTICS=y CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS=0 CONFIG_THERMAL_HWMON=y CONFIG_THERMAL_WRITABLE_TRIPS=y CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y
# CONFIG_THERMAL_DEFAULT_GOV_FAIR_SHARE is not set
# CONFIG_THERMAL_DEFAULT_GOV_USER_SPACE is not set CONFIG_THERMAL_GOV_FAIR_SHARE=y CONFIG_THERMAL_GOV_STEP_WISE=y CONFIG_THERMAL_GOV_BANG_BANG=y CONFIG_THERMAL_GOV_USER_SPACE=y CONFIG_DEVFREQ_THERMAL=y
CONFIG_THERMAL_EMULATION=y

This may help

#gdb ./thermal-engine
GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"... Reading symbols from ./thermal-engine...(no debugging symbols found)...done.
(gdb) run
Starting program:
/home/labuser/development/linux/tools/thermal/thermal-engine/thermal- engine
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux- gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7402036 in parse_tz_get_trip (info=0x7fffffffdf60, tz=0x555555607898) at commands.c:143
143 __tt[size].id = -1;
(gdb) backtrace
#0 0x00007ffff7402036 in parse_tz_get_trip (info=0x7fffffffdf60, tz=0x555555607898) at commands.c:143
#1 0x00007ffff7402233 in handle_netlink (unused=0x0, cmd=0x7ffff76052f8 <thermal_cmds+120>, info=0x7fffffffdf60, arg=0x555555607898) at commands.c:206
#2 0x00007ffff7003435 in ?? () from /lib/x86_64-linux-gnu/libnl-genl- 3.so.200
#3 0x00007ffff6810c1c in nl_recvmsgs_report () from /lib/x86_64-linux- gnu/libnl-3.so.200
#4 0x00007ffff6811049 in nl_recvmsgs () from /lib/x86_64-linux- gnu/libnl-3.so.200
#5 0x00007ffff7402eaf in nl_send_msg (sock=0x555555606040, cb=0x5555556065d0, msg=0x555555606110, rx_handler=0x7ffff70036f0 <genl_handle_msg>, data=0x555555607898) at thermal_nl.c:70 #6 0x00007ffff7402327 in thermal_genl_auto (th=0x5555556048a0, id=1, cmd=2, flags=0, arg=0x555555607898) at commands.c:282
#7 0x00007ffff74023e0 in thermal_cmd_get_trip (th=0x5555556048a0, tz=0x555555607898) at commands.c:304
#8 0x00007ffff74039db in __thermal_zone_discover (tz=0x555555607898, th=0x5555556048a0) at thermal.c:71
#9 0x00007ffff7403842 in for_each_thermal_zone (tz=0x555555607860, cb=0x7ffff74039b8 <__thermal_zone_discover>, arg=0x5555556048a0) at thermal.c:33
#10 0x00007ffff7403a5b in thermal_zone_discover (th=0x5555556048a0) at thermal.c:87
#11 0x00005555554019bd in main ()

Thanks,
Srinivas

Quoted 1 line
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#14 lore raw

Hi Daniel,

The attached diff fixes the crash,

Also when you run in daemon mode, you need to use some pid lock file. Otherwise it launches multiple daemons.

Thanks,
Srinivas

Quoted 6 lines · Daniel Lezcano

Hi Srinivas,

thanks for the information. I've indeed not tested on x86_64 but on ARM64.

Quoted 137 lines

I'll give a try to reproduce and fix the issue.

Thanks again for taking the time to run it

   -- Daniel

Quoted 128 lines · srinivas pandruvada

Hi Daniel,

Quoted 11 lines · Daniel Lezcano

Hi Srinivas,

Quoted 6 lines · srinivas pandruvada
Quoted 4 lines · srinivas pandruvada
Quoted 3 lines · Rafael J. Wysocki
Quoted 1 line · Daniel Lezcano

[...]

Quoted 19 lines
Quoted 10 lines

root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/the rmal-
engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH ./thermal-engine -l DEBUG
Segmentation fault (core dumped) root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/the rmal-
engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH

Quoted 8 lines

./thermal-engine --loglevel DEBUG
Segmentation fault (core dumped) root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/the rmal-
engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH ./thermal-engine -s
Segmentation fault (core dumped)

Quoted 1 line

Is CONFIG_THERMAL_NETLINK set ?

Yes, Thermometer program works fine. Just thermal-engine fails. CONFIG_THERMAL=y
CONFIG_THERMAL_NETLINK=y
CONFIG_THERMAL_STATISTICS=y CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS=0 CONFIG_THERMAL_HWMON=y CONFIG_THERMAL_WRITABLE_TRIPS=y CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y
# CONFIG_THERMAL_DEFAULT_GOV_FAIR_SHARE is not set
# CONFIG_THERMAL_DEFAULT_GOV_USER_SPACE is not set CONFIG_THERMAL_GOV_FAIR_SHARE=y CONFIG_THERMAL_GOV_STEP_WISE=y CONFIG_THERMAL_GOV_BANG_BANG=y CONFIG_THERMAL_GOV_USER_SPACE=y CONFIG_DEVFREQ_THERMAL=y
CONFIG_THERMAL_EMULATION=y

This may help

#gdb ./thermal-engine
GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
Copyright (C) 2018 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details. For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"... Reading symbols from ./thermal-engine...(no debugging symbols found)...done.
(gdb) run
Starting program:
/home/labuser/development/linux/tools/thermal/thermal- engine/thermal-
engine
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux- gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7402036 in parse_tz_get_trip (info=0x7fffffffdf60, tz=0x555555607898) at commands.c:143
143             __tt[size].id = -1;
(gdb) backtrace
#0  0x00007ffff7402036 in parse_tz_get_trip (info=0x7fffffffdf60, tz=0x555555607898) at commands.c:143
#1  0x00007ffff7402233 in handle_netlink (unused=0x0, cmd=0x7ffff76052f8 <thermal_cmds+120>, info=0x7fffffffdf60, arg=0x555555607898) at commands.c:206
#2  0x00007ffff7003435 in ?? () from /lib/x86_64-linux-gnu/libnl- genl-
3.so.200
#3  0x00007ffff6810c1c in nl_recvmsgs_report () from /lib/x86_64- linux-
gnu/libnl-3.so.200
#4  0x00007ffff6811049 in nl_recvmsgs () from /lib/x86_64-linux- gnu/libnl-3.so.200
#5  0x00007ffff7402eaf in nl_send_msg (sock=0x555555606040, cb=0x5555556065d0, msg=0x555555606110, rx_handler=0x7ffff70036f0 <genl_handle_msg>, data=0x555555607898) at thermal_nl.c:70 #6  0x00007ffff7402327 in thermal_genl_auto (th=0x5555556048a0, id=1,
cmd=2, flags=0, arg=0x555555607898) at commands.c:282
#7  0x00007ffff74023e0 in thermal_cmd_get_trip (th=0x5555556048a0, tz=0x555555607898) at commands.c:304
#8  0x00007ffff74039db in __thermal_zone_discover (tz=0x555555607898,
th=0x5555556048a0) at thermal.c:71
#9  0x00007ffff7403842 in for_each_thermal_zone (tz=0x555555607860, cb=0x7ffff74039b8 <__thermal_zone_discover>, arg=0x5555556048a0) at thermal.c:33
#10 0x00007ffff7403a5b in thermal_zone_discover (th=0x5555556048a0) at
thermal.c:87
#11 0x00005555554019bd in main ()

Thanks,
Srinivas

Quoted 1 line

git diff

tools/lib/thermal/commands.c +7 -0
index 539083780107..b8d933f19909 100644
@@ -117,6 +117,8 @@ static int parse_tz_get_trip(struct genl_info *info, struct thermal_zone *tz)
        size_t size = 0;
        int rem;
 
+       tz->trip_count = 0;
+
        nla_for_each_nested(attr, info->attrs[THERMAL_GENL_ATTR_TZ_TRIP], rem) {
 
                if (nla_type(attr) == THERMAL_GENL_ATTR_TZ_TRIP_ID) {
@@ -140,10 +142,15 @@ static int parse_tz_get_trip(struct genl_info *info, struct thermal_zone *tz)
                        __tt[size - 1].hyst = nla_get_u32(attr);
        }
 
+       if (!size)
+               return THERMAL_ERROR;
+
        __tt[size].id = -1;
 
        tz->trip = __tt;
 
+       tz->trip_count = size;
+
        return THERMAL_SUCCESS;
 }
 
tools/lib/thermal/include/thermal.h +1 -0
index 1abc560602cf..5cb9ba8c6c0e 100644
@@ -51,6 +51,7 @@ struct thermal_zone {
        char name[THERMAL_NAME_LENGTH];
        char governor[THERMAL_NAME_LENGTH];
        struct thermal_trip *trip;
+       int trip_count;
 };
 
 struct thermal_cdev {
tools/lib/thermal/thermal.c +7 -1
index a80b967ce334..dd4ebfbbf1d0 100644
@@ -19,7 +19,10 @@ int for_each_thermal_trip(struct thermal_trip *tt, cb_tt_t cb, void *arg)
 {
        int i, ret = 0;
 
-       for (i = 0; tt[i].id != -1; i++)
+       if (!tt)
+               return -1;
+
+       for (i = 0; &tt[i] && tt[i].id != -1; i++)
                ret |= cb(&tt[i], arg);
 
        return ret;
@@ -29,6 +32,9 @@ int for_each_thermal_zone(struct thermal_zone *tz, cb_tz_t cb, void *arg)
 {
        int i, ret = 0;
 
+       if (!tz)
+               return 0;
+
        for (i = 0; tz[i].id != -1; i++)
                ret |= cb(&tz[i], arg);
 
tools/thermal/thermal-engine/thermal-engine.c +2 -1
index 525520049aa2..4e446aec22b5 100644
@@ -68,7 +68,8 @@ static int show_tz(struct thermal_zone *tz, __maybe_unused void *arg)
 {
        INFO("thermal zone '%s', id=%d\n", tz->name, tz->id);
 
-       for_each_thermal_trip(tz->trip, show_trip, NULL);
+       if (tz->trip_count)
+               for_each_thermal_trip(tz->trip, show_trip, NULL);
 
        show_temp(tz, arg);
 
#15 lore raw
Quoted 7 lines · srinivas pandruvada

Hi Daniel,

The attached diff fixes the crash,

Also when you run in daemon mode, you need to use some pid lock file. Otherwise it launches multiple daemons.

With the diff
./thermal-engine
thermal zone 'acpitz', id=0
trip id=0, type=3, temp=119000, hyst=0 trip id=1, type=0, temp=71000, hyst=0 trip id=2, type=0, temp=55000, hyst=0 trip id=3, type=0, temp=50000, hyst=0 trip id=4, type=0, temp=45000, hyst=0 trip id=5, type=0, temp=40000, hyst=0
temperature: 25000
governor: 'step_wise'
thermal zone 'INT3400 Thermal', id=1
temperature: 20000
governor: 'user_space'
thermal zone 'B0D4', id=2
trip id=0, type=3, temp=110050, hyst=0 trip id=1, type=2, temp=110050, hyst=0 trip id=2, type=1, temp=110050, hyst=0 trip id=3, type=0, temp=90050, hyst=0 trip id=4, type=0, temp=85050, hyst=0 trip id=5, type=0, temp=80050, hyst=0 trip id=6, type=0, temp=75050, hyst=0 trip id=7, type=0, temp=70050, hyst=0
temperature: 26050
governor: 'user_space'
thermal zone 'x86_pkg_temp', id=3 trip id=0, type=1, temp=-274000, hyst=0 trip id=1, type=1, temp=-274000, hyst=0
temperature: 26000
governor: 'step_wise'
Waiting for thermal events ...

Quoted 150 lines

Thanks,
Srinivas

Quoted 143 lines · Daniel Lezcano

Hi Srinivas,

thanks for the information. I've indeed not tested on x86_64 but on ARM64.

I'll give a try to reproduce and fix the issue.

Thanks again for taking the time to run it

   -- Daniel

Quoted 128 lines · srinivas pandruvada

Hi Daniel,

Quoted 11 lines · Daniel Lezcano

Hi Srinivas,

Quoted 6 lines · srinivas pandruvada
Quoted 4 lines · srinivas pandruvada
Quoted 3 lines · Rafael J. Wysocki
Quoted 1 line · Daniel Lezcano

[...]

Quoted 19 lines
Quoted 10 lines

root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/the rmal-
engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH ./thermal-engine -l DEBUG
Segmentation fault (core dumped) root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/the rmal-
engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH

Quoted 8 lines

./thermal-engine --loglevel DEBUG
Segmentation fault (core dumped) root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/the rmal-
engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH ./thermal-engine -s
Segmentation fault (core dumped)

Quoted 1 line

Is CONFIG_THERMAL_NETLINK set ?

Yes, Thermometer program works fine. Just thermal-engine fails. CONFIG_THERMAL=y
CONFIG_THERMAL_NETLINK=y
CONFIG_THERMAL_STATISTICS=y CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS=0 CONFIG_THERMAL_HWMON=y CONFIG_THERMAL_WRITABLE_TRIPS=y CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y
# CONFIG_THERMAL_DEFAULT_GOV_FAIR_SHARE is not set
# CONFIG_THERMAL_DEFAULT_GOV_USER_SPACE is not set CONFIG_THERMAL_GOV_FAIR_SHARE=y CONFIG_THERMAL_GOV_STEP_WISE=y CONFIG_THERMAL_GOV_BANG_BANG=y CONFIG_THERMAL_GOV_USER_SPACE=y CONFIG_DEVFREQ_THERMAL=y
CONFIG_THERMAL_EMULATION=y

This may help

#gdb ./thermal-engine
GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
Copyright (C) 2018 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details. For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"... Reading symbols from ./thermal-engine...(no debugging symbols found)...done.
(gdb) run
Starting program:
/home/labuser/development/linux/tools/thermal/thermal- engine/thermal-
engine
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux- gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7402036 in parse_tz_get_trip (info=0x7fffffffdf60, tz=0x555555607898) at commands.c:143
143             __tt[size].id = -1;
(gdb) backtrace
#0  0x00007ffff7402036 in parse_tz_get_trip (info=0x7fffffffdf60, tz=0x555555607898) at commands.c:143
#1  0x00007ffff7402233 in handle_netlink (unused=0x0, cmd=0x7ffff76052f8 <thermal_cmds+120>, info=0x7fffffffdf60, arg=0x555555607898) at commands.c:206
#2  0x00007ffff7003435 in ?? () from /lib/x86_64-linux-gnu/libnl- genl-
3.so.200
#3  0x00007ffff6810c1c in nl_recvmsgs_report () from /lib/x86_64- linux-
gnu/libnl-3.so.200
#4  0x00007ffff6811049 in nl_recvmsgs () from /lib/x86_64-linux- gnu/libnl-3.so.200
#5  0x00007ffff7402eaf in nl_send_msg (sock=0x555555606040, cb=0x5555556065d0, msg=0x555555606110, rx_handler=0x7ffff70036f0 <genl_handle_msg>, data=0x555555607898) at thermal_nl.c:70 #6  0x00007ffff7402327 in thermal_genl_auto (th=0x5555556048a0, id=1,
cmd=2, flags=0, arg=0x555555607898) at commands.c:282
#7  0x00007ffff74023e0 in thermal_cmd_get_trip (th=0x5555556048a0, tz=0x555555607898) at commands.c:304
#8  0x00007ffff74039db in __thermal_zone_discover (tz=0x555555607898,
th=0x5555556048a0) at thermal.c:71
#9  0x00007ffff7403842 in for_each_thermal_zone (tz=0x555555607860, cb=0x7ffff74039b8 <__thermal_zone_discover>, arg=0x5555556048a0) at thermal.c:33
#10 0x00007ffff7403a5b in thermal_zone_discover (th=0x5555556048a0) at
thermal.c:87
#11 0x00005555554019bd in main ()

Thanks,
Srinivas

Quoted 1 line
#16 lore raw
In reply to srinivas pandruvada

Hi Srinivas,

thanks for the fix !

Quoted 6 lines · srinivas pandruvada

Hi Daniel,

The attached diff fixes the crash,

Also when you run in daemon mode, you need to use some pid lock file. Otherwise it launches multiple daemons.

Thanks for the feedback, I'll add it

-- Daniel

Quoted 146 lines · Daniel Lezcano
Quoted 143 lines

Hi Srinivas,

thanks for the information. I've indeed not tested on x86_64 but on ARM64.

I'll give a try to reproduce and fix the issue.

Thanks again for taking the time to run it

   -- Daniel

Quoted 128 lines · srinivas pandruvada

Hi Daniel,

Quoted 11 lines · Daniel Lezcano

Hi Srinivas,

Quoted 6 lines · srinivas pandruvada
Quoted 4 lines · srinivas pandruvada
Quoted 3 lines · Rafael J. Wysocki
Quoted 1 line · Daniel Lezcano

[...]

Quoted 19 lines
Quoted 10 lines

root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/the rmal-
engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH ./thermal-engine -l DEBUG
Segmentation fault (core dumped) root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/the rmal-
engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH

Quoted 8 lines

./thermal-engine --loglevel DEBUG
Segmentation fault (core dumped) root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/the rmal-
engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH ./thermal-engine -s
Segmentation fault (core dumped)

Quoted 1 line

Is CONFIG_THERMAL_NETLINK set ?

Yes, Thermometer program works fine. Just thermal-engine fails. CONFIG_THERMAL=y
CONFIG_THERMAL_NETLINK=y
CONFIG_THERMAL_STATISTICS=y CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS=0 CONFIG_THERMAL_HWMON=y CONFIG_THERMAL_WRITABLE_TRIPS=y CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y
# CONFIG_THERMAL_DEFAULT_GOV_FAIR_SHARE is not set
# CONFIG_THERMAL_DEFAULT_GOV_USER_SPACE is not set CONFIG_THERMAL_GOV_FAIR_SHARE=y CONFIG_THERMAL_GOV_STEP_WISE=y CONFIG_THERMAL_GOV_BANG_BANG=y CONFIG_THERMAL_GOV_USER_SPACE=y CONFIG_DEVFREQ_THERMAL=y
CONFIG_THERMAL_EMULATION=y

This may help

#gdb ./thermal-engine
GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
Copyright (C) 2018 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details. For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"... Reading symbols from ./thermal-engine...(no debugging symbols found)...done.
(gdb) run
Starting program:
/home/labuser/development/linux/tools/thermal/thermal- engine/thermal-
engine
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux- gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7402036 in parse_tz_get_trip (info=0x7fffffffdf60, tz=0x555555607898) at commands.c:143
143             __tt[size].id = -1;
(gdb) backtrace
#0  0x00007ffff7402036 in parse_tz_get_trip (info=0x7fffffffdf60, tz=0x555555607898) at commands.c:143
#1  0x00007ffff7402233 in handle_netlink (unused=0x0, cmd=0x7ffff76052f8 <thermal_cmds+120>, info=0x7fffffffdf60, arg=0x555555607898) at commands.c:206
#2  0x00007ffff7003435 in ?? () from /lib/x86_64-linux-gnu/libnl- genl-
3.so.200
#3  0x00007ffff6810c1c in nl_recvmsgs_report () from /lib/x86_64- linux-
gnu/libnl-3.so.200
#4  0x00007ffff6811049 in nl_recvmsgs () from /lib/x86_64-linux- gnu/libnl-3.so.200
#5  0x00007ffff7402eaf in nl_send_msg (sock=0x555555606040, cb=0x5555556065d0, msg=0x555555606110, rx_handler=0x7ffff70036f0 <genl_handle_msg>, data=0x555555607898) at thermal_nl.c:70 #6  0x00007ffff7402327 in thermal_genl_auto (th=0x5555556048a0, id=1,
cmd=2, flags=0, arg=0x555555607898) at commands.c:282
#7  0x00007ffff74023e0 in thermal_cmd_get_trip (th=0x5555556048a0, tz=0x555555607898) at commands.c:304
#8  0x00007ffff74039db in __thermal_zone_discover (tz=0x555555607898,
th=0x5555556048a0) at thermal.c:71
#9  0x00007ffff7403842 in for_each_thermal_zone (tz=0x555555607860, cb=0x7ffff74039b8 <__thermal_zone_discover>, arg=0x5555556048a0) at thermal.c:33
#10 0x00007ffff7403a5b in thermal_zone_discover (th=0x5555556048a0) at
thermal.c:87
#11 0x00005555554019bd in main ()

Thanks,
Srinivas

Quoted 1 line
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#17 lore raw
In reply to srinivas pandruvada

Hi Srinivas,

Quoted 6 lines · srinivas pandruvada

Hi Daniel,

The attached diff fixes the crash,

Also when you run in daemon mode, you need to use some pid lock file. Otherwise it launches multiple daemons.

I've been thinking about it and I don't think it is a problem to have multiple instances of the daemon. The netlink allows multicast and can be run as non-root user.

If the finality of the thermal engine is to manage the system and has some code making actions on the system with the root privilege, the init scripts can take care of the pid lock

Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#18 lore raw

Hi Daniel,

Quoted 18 lines · Daniel Lezcano

Hi Srinivas,

Quoted 7 lines · srinivas pandruvada

Hi Daniel,

The attached diff fixes the crash,

Also when you run in daemon mode, you need to use some pid lock file.
Otherwise it launches multiple daemons.

I've been thinking about it and I don't think it is a problem to have multiple instances of the daemon. The netlink allows multicast and can
be run as non-root user.

Quoted 5 lines

If the finality of the thermal engine is to manage the system and has some code making actions on the system with the root privilege, the init
scripts can take care of the pid lock

If there is use case, then this is fine otherwise wasting system resources.

Thanks,
Srinivas

Quoted 2 lines