Skip to content

Commit 110acbc

Browse files
committed
tools/thermal: Add a temperature capture tool
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. Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Tested-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Link: https://lore.kernel.org/r/20220420160933.347088-4-daniel.lezcano@linaro.org
1 parent 3b7c5e8 commit 110acbc

6 files changed

Lines changed: 709 additions & 3 deletions

File tree

tools/Makefile

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ help:
3131
@echo ' bootconfig - boot config tool'
3232
@echo ' spi - spi tools'
3333
@echo ' tmon - thermal monitoring and tuning tool'
34+
@echo ' thermometer - temperature capture tool'
3435
@echo ' thermal - thermal library'
3536
@echo ' tracing - misc tracing tools'
3637
@echo ' turbostat - Intel CPU idle stats and freq reporting tool'
@@ -95,6 +96,9 @@ turbostat x86_energy_perf_policy intel-speed-select: FORCE
9596
tmon: FORCE
9697
$(call descend,thermal/$@)
9798

99+
thermometer: FORCE
100+
$(call descend,thermal/$@)
101+
98102
freefall: FORCE
99103
$(call descend,laptop/$@)
100104

@@ -105,7 +109,7 @@ all: acpi cgroup counter cpupower gpio hv firewire \
105109
perf selftests bootconfig spi turbostat usb \
106110
virtio vm bpf x86_energy_perf_policy \
107111
tmon freefall iio objtool kvm_stat wmi \
108-
pci debugging tracing thermal
112+
pci debugging tracing thermal thermometer
109113

110114
acpi_install:
111115
$(call descend,power/$(@:_install=),install)
@@ -128,6 +132,9 @@ turbostat_install x86_energy_perf_policy_install intel-speed-select_install:
128132
tmon_install:
129133
$(call descend,thermal/$(@:_install=),install)
130134

135+
thermometer_install:
136+
$(call descend,thermal/$(@:_install=),install)
137+
131138
freefall_install:
132139
$(call descend,laptop/$(@:_install=),install)
133140

@@ -140,7 +147,7 @@ install: acpi_install cgroup_install counter_install cpupower_install gpio_insta
140147
virtio_install vm_install bpf_install x86_energy_perf_policy_install \
141148
tmon_install freefall_install objtool_install kvm_stat_install \
142149
wmi_install pci_install debugging_install intel-speed-select_install \
143-
tracing_install
150+
tracing_install thermometer_install
144151

145152
acpi_clean:
146153
$(call descend,power/acpi,clean)
@@ -173,6 +180,9 @@ thermal_clean:
173180
turbostat_clean x86_energy_perf_policy_clean intel-speed-select_clean:
174181
$(call descend,power/x86/$(@:_clean=),clean)
175182

183+
thermometer_clean:
184+
$(call descend,thermal/thermometer,clean)
185+
176186
tmon_clean:
177187
$(call descend,thermal/tmon,clean)
178188

@@ -187,6 +197,6 @@ clean: acpi_clean cgroup_clean counter_clean cpupower_clean hv_clean firewire_cl
187197
vm_clean bpf_clean iio_clean x86_energy_perf_policy_clean tmon_clean \
188198
freefall_clean build_clean libbpf_clean libsubcmd_clean \
189199
gpio_clean objtool_clean leds_clean wmi_clean pci_clean firmware_clean debugging_clean \
190-
intel-speed-select_clean tracing_clean thermal_clean
200+
intel-speed-select_clean tracing_clean thermal_clean thermometer_clean
191201

192202
.PHONY: FORCE

tools/thermal/thermometer/Build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
thermometer-y += thermometer.o

tools/thermal/thermometer/Makefile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
# Makefile for cgroup tools
3+
4+
ifeq ($(srctree),)
5+
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
6+
srctree := $(patsubst %/,%,$(dir $(srctree)))
7+
srctree := $(patsubst %/,%,$(dir $(srctree)))
8+
# $(info Determined 'srctree' to be $(srctree))
9+
endif
10+
11+
CFLAGS = -Wall -Wextra
12+
CFLAGS += -I$(srctree)/tools/thermal/lib
13+
14+
LDFLAGS = -L$(srctree)/tools/thermal/lib
15+
LDFLAGS += -lthermal_tools
16+
LDFLAGS += -lconfig
17+
18+
VERSION = 0.0.1
19+
TARGET=thermometer
20+
21+
all: $(TARGET)
22+
%: %.c
23+
$(CC) $(CFLAGS) -D VERSION=\"$(VERSION)\" -o $@ $^ $(LDFLAGS)
24+
25+
clean:
26+
$(RM) $(TARGET)
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
.TH THERMOMETER 8
2+
# SPDX-License-Identifier: GPL-2.0
3+
.SH NAME
4+
\fBthermometer\fP - A thermal profiling tool
5+
6+
.SH SYNOPSIS
7+
.ft B
8+
.B thermometer
9+
.RB [ options ]
10+
.RB [ command ]
11+
.br
12+
.SH DESCRIPTION
13+
\fBthermometer \fP captures the thermal zones temperature at a
14+
specified sampling period. It is optimized to reduce as much as
15+
possible the overhead while doing the temperature acquisition in order
16+
to prevent disrupting the running application we may want to profile.
17+
18+
This low overhead also allows a high rate sampling for the temperature
19+
which could be necessary to spot overshots and undershots.
20+
21+
If no configuration file is specified, then all the thermal zones will
22+
be monitored at 4Hz, so every 250ms. A configuration file specifies
23+
the thermal zone names and the desired sampling period. A thermal zone
24+
name can be a regular expression to specify a group of thermal zone.
25+
26+
The sampling of the different thermal zones will be written into
27+
separate files with the thermal zone name. It is possible to specify a
28+
postfix to identify them for example for a specific scenario. The
29+
output directory can be specified in addition.
30+
31+
Without any parameters, \fBthermometer \fP captures all the thermal
32+
zone temperatures every 250ms and write to the current directory the
33+
captured files postfixed with the current date.
34+
35+
If a running \fBduration\fP is specified or a \fBcommand\fP, the
36+
capture ends at the end of the duration if the command did not
37+
finished before. The \fBduration\fP can be specified alone as well as
38+
the \fBcommand\fP. If none is specified, the capture will continue
39+
indefinitively until interrupted by \fBSIGINT\fP or \fBSIGQUIT\fP.
40+
.PP
41+
42+
.SS Options
43+
.PP
44+
The \fB-h, --help\fP option shows a short usage help
45+
.PP
46+
The \fB-o <dir>, --output <dir>\fP option defines the output directory to put the
47+
sampling files
48+
.PP
49+
The \fB-c <config>, --config <config>\fP option specifies the configuration file to use
50+
.PP
51+
The \fB-d <seconds>, --duration <seconds>\fP option specifies the duration of the capture
52+
.PP
53+
The \fB-l <loglevel>, --loglevel <loglevel>\fP option sets the loglevel [DEBUG,INFO,NOTICE,WARN,ERROR]
54+
.PP
55+
The \fB-p <string>, --postfix <string>\fP option appends \fBstring\fP at the end of the capture filenames
56+
.PP
57+
The \fB-s, --syslog\fP option sets the output to syslog, default is \fBstdout\fP
58+
.PP
59+
The \fB-w, --overwrite\fP overwrites the output files if they exist
60+
.PP
61+
62+
.PP
63+
64+
.SS "Exit status:"
65+
.TP
66+
0
67+
if OK,
68+
.TP
69+
1
70+
Error with the options specified as parameters
71+
.TP
72+
2
73+
Error when configuring the logging facility
74+
.TP
75+
3
76+
Error when configuring the time
77+
.TP
78+
4
79+
Error in the initialization routine
80+
.TP
81+
5
82+
Error during the runtime
83+
84+
.SH Capture file format
85+
86+
Every file contains two columns. The first one is the uptime timestamp
87+
in order to find a point in time since the system started up if there
88+
is any thermal event. The second one is the temperature in milli
89+
degree. The first line contains the label of each column.
90+
91+
.SH AUTHOR
92+
Daniel Lezcano <daniel.lezcano@kernel.org>

0 commit comments

Comments
 (0)