Skip to content

Commit 4b01712

Browse files
committed
Merge tag 'trace-tools-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull tracing tools updates from Steven Rostedt: - Add ':' to getopt option 'trace-buffer-size' in timerlat_hist for consistency - Remove unused sched_getattr define - Rename sched_setattr() helper to syscall_sched_setattr() to avoid conflicts - Update counters to long from int to avoid overflow - Add libcpupower dependency detection - Add --deepest-idle-state to timerlat to limit deep idle sleeps - Other minor clean ups and documentation changes * tag 'trace-tools-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: verification/dot2: Improve dot parser robustness tools/rtla: Improve exception handling in timerlat_load.py tools/rtla: Enhance argument parsing in timerlat_load.py tools/rtla: Improve code readability in timerlat_load.py rtla/timerlat: Do not set params->user_workload with -U rtla: Documentation: Mention --deepest-idle-state rtla/timerlat: Add --deepest-idle-state for hist rtla/timerlat: Add --deepest-idle-state for top rtla/utils: Add idle state disabling via libcpupower rtla: Add optional dependency on libcpupower tools/build: Add libcpupower dependency detection rtla/timerlat: Make timerlat_hist_cpu->*_count unsigned long long rtla/timerlat: Make timerlat_top_cpu->*_count unsigned long long tools/rtla: fix collision with glibc sched_attr/sched_set_attr tools/rtla: drop __NR_sched_getattr rtla: Fix consistency in getopt_long for timerlat_hist rv: Fix a typo tools/rv: Correct the grammatical errors in the comments tools/rv: Correct the grammatical errors in the comments rtla: use the definition for stdout fd when calling isatty()
2 parents f1db825 + 571f8b3 commit 4b01712

File tree

17 files changed

+361
-79
lines changed

17 files changed

+361
-79
lines changed

Documentation/tools/rtla/common_timerlat_options.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@
3131
*cyclictest* sets this value to *0* by default, use **--dma-latency** *0* to have
3232
similar results.
3333

34+
**--deepest-idle-state** *n*
35+
Disable idle states higher than *n* for cpus that are running timerlat threads to
36+
reduce exit from idle latencies. If *n* is -1, all idle states are disabled.
37+
On exit from timerlat, the idle state setting is restored to its original state
38+
before running timerlat.
39+
40+
Requires rtla to be built with libcpupower.
41+
3442
**-k**, **--kernel-threads**
3543

3644
Use timerlat kernel-space threads, in contrast of **-u**.

kernel/trace/rv/rv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* per-task monitor, and so on), and the helper functions that glue the
4242
* monitor to the system via trace. Generally, a monitor includes some form
4343
* of trace output as a reaction for event parsing and exceptions,
44-
* as depicted bellow:
44+
* as depicted below:
4545
*
4646
* Linux +----- RV Monitor ----------------------------------+ Formal
4747
* Realm | | Realm

tools/build/Makefile.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ FEATURE_TESTS_BASIC := \
5353
libslang-include-subdir \
5454
libtraceevent \
5555
libtracefs \
56+
libcpupower \
5657
libcrypto \
5758
libunwind \
5859
pthread-attr-setaffinity-np \

tools/build/feature/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ FILES= \
3838
test-libslang.bin \
3939
test-libslang-include-subdir.bin \
4040
test-libtraceevent.bin \
41+
test-libcpupower.bin \
4142
test-libtracefs.bin \
4243
test-libcrypto.bin \
4344
test-libunwind.bin \
@@ -248,6 +249,9 @@ $(OUTPUT)test-libslang-include-subdir.bin:
248249
$(OUTPUT)test-libtraceevent.bin:
249250
$(BUILD) -ltraceevent
250251

252+
$(OUTPUT)test-libcpupower.bin:
253+
$(BUILD) -lcpupower
254+
251255
$(OUTPUT)test-libtracefs.bin:
252256
$(BUILD) $(shell $(PKG_CONFIG) --cflags libtracefs 2>/dev/null) -ltracefs
253257

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
#include <cpuidle.h>
3+
4+
int main(void)
5+
{
6+
int rv = cpuidle_state_count(0);
7+
return rv;
8+
}

tools/tracing/rtla/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ DOCSRC := ../../../Documentation/tools/rtla/
3232

3333
FEATURE_TESTS := libtraceevent
3434
FEATURE_TESTS += libtracefs
35+
FEATURE_TESTS += libcpupower
3536
FEATURE_DISPLAY := libtraceevent
3637
FEATURE_DISPLAY += libtracefs
38+
FEATURE_DISPLAY += libcpupower
3739

3840
ifeq ($(V),1)
3941
Q =

tools/tracing/rtla/Makefile.config

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ else
4343
$(info libtracefs is missing. Please install libtracefs-dev/libtracefs-devel)
4444
endif
4545

46+
$(call feature_check,libcpupower)
47+
ifeq ($(feature-libcpupower), 1)
48+
$(call detected,CONFIG_LIBCPUPOWER)
49+
CFLAGS += -DHAVE_LIBCPUPOWER_SUPPORT
50+
EXTLIBS += -lcpupower
51+
else
52+
$(info libcpupower is missing, building without --deepest-idle-state support.)
53+
$(info Please install libcpupower-dev/kernel-tools-libs-devel)
54+
endif
55+
4656
ifeq ($(STOP_ERROR),1)
4757
$(error Please, check the errors above.)
4858
endif

tools/tracing/rtla/README.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ RTLA depends on the following libraries and tools:
1111

1212
- libtracefs
1313
- libtraceevent
14+
- libcpupower (optional, for --deepest-idle-state)
1415

1516
It also depends on python3-docutils to compile man pages.
1617

@@ -26,6 +27,9 @@ For development, we suggest the following steps for compiling rtla:
2627
$ make
2728
$ sudo make install
2829
$ cd ..
30+
$ cd $libcpupower_src
31+
$ make
32+
$ sudo make install
2933
$ cd $rtla_src
3034
$ make
3135
$ sudo make install

tools/tracing/rtla/sample/timerlat_load.py

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,50 +25,54 @@
2525
import os
2626

2727
parser = argparse.ArgumentParser(description='user-space timerlat thread in Python')
28-
parser.add_argument("cpu", help='CPU to run timerlat thread')
29-
parser.add_argument("-p", "--prio", help='FIFO priority')
30-
28+
parser.add_argument("cpu", type=int, help='CPU to run timerlat thread')
29+
parser.add_argument("-p", "--prio", type=int, help='FIFO priority')
3130
args = parser.parse_args()
3231

3332
try:
34-
affinity_mask = { int(args.cpu) }
35-
except:
36-
print("Invalid cpu: " + args.cpu)
37-
exit(1)
38-
39-
try:
40-
os.sched_setaffinity(0, affinity_mask);
41-
except:
42-
print("Error setting affinity")
43-
exit(1)
33+
affinity_mask = {args.cpu}
34+
os.sched_setaffinity(0, affinity_mask)
35+
except Exception as e:
36+
print(f"Error setting affinity: {e}")
37+
sys.exit(1)
4438

45-
if (args.prio):
39+
if args.prio:
4640
try:
47-
param = os.sched_param(int(args.prio))
41+
param = os.sched_param(args.prio)
4842
os.sched_setscheduler(0, os.SCHED_FIFO, param)
49-
except:
50-
print("Error setting priority")
51-
exit(1)
43+
except Exception as e:
44+
print(f"Error setting priority: {e}")
45+
sys.exit(1)
5246

5347
try:
54-
timerlat_path = "/sys/kernel/tracing/osnoise/per_cpu/cpu" + args.cpu + "/timerlat_fd"
48+
timerlat_path = f"/sys/kernel/tracing/osnoise/per_cpu/cpu{args.cpu}/timerlat_fd"
5549
timerlat_fd = open(timerlat_path, 'r')
56-
except:
50+
except PermissionError:
51+
print("Permission denied. Please check your access rights.")
52+
sys.exit(1)
53+
except OSError:
5754
print("Error opening timerlat fd, did you run timerlat -U?")
58-
exit(1)
55+
sys.exit(1)
5956

6057
try:
61-
data_fd = open("/dev/full", 'r');
62-
except:
63-
print("Error opening data fd")
58+
data_fd = open("/dev/full", 'r')
59+
except Exception as e:
60+
print(f"Error opening data fd: {e}")
61+
sys.exit(1)
6462

6563
while True:
6664
try:
6765
timerlat_fd.read(1)
68-
data_fd.read(20*1024*1024)
69-
except:
66+
data_fd.read(20 * 1024 * 1024)
67+
except KeyboardInterrupt:
7068
print("Leaving")
7169
break
70+
except IOError as e:
71+
print(f"I/O error occurred: {e}")
72+
break
73+
except Exception as e:
74+
print(f"Unexpected error: {e}")
75+
break
7276

7377
timerlat_fd.close()
7478
data_fd.close()

tools/tracing/rtla/src/osnoise_top.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ osnoise_top_apply_config(struct osnoise_tool *tool, struct osnoise_top_params *p
627627
auto_house_keeping(&params->monitored_cpus);
628628
}
629629

630-
if (isatty(1) && !params->quiet)
630+
if (isatty(STDOUT_FILENO) && !params->quiet)
631631
params->pretty_output = 1;
632632

633633
return 0;

0 commit comments

Comments
 (0)