Skip to content

Commit 472c5f7

Browse files
committed
Merge tag 'trace-tools-v6.16' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull tracing tools updates from Steven Rostedt: - Set distinctive value for failed tests When running "make check" that performs tests on rtla the failure is checked by examining the output. Instead have the tool return an error status if it exceeds the threadhold. - Define __NR_sched_setattr for LoongArch Define __NR_sched_setattr to allow this to build for LoongArch. - Define _GNU_SOURCE for timerlat_bpf.c Due to modifications of struct sched_attr in utils.h when _GNU_SOURCE is not defined, this can cause errors for timerlat_bpf_init() and breakage in BPF sample collection mode. * tag 'trace-tools-v6.16' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: rtla: Define _GNU_SOURCE in timerlat_bpf.c rtla: Define __NR_sched_setattr for LoongArch rtla: Set distinctive exit value for failed tests
2 parents e0797d3 + 8020361 commit 472c5f7

File tree

11 files changed

+37
-21
lines changed

11 files changed

+37
-21
lines changed

tools/tracing/rtla/src/osnoise_hist.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -766,8 +766,8 @@ int osnoise_hist_main(int argc, char *argv[])
766766
struct osnoise_params *params;
767767
struct osnoise_tool *record = NULL;
768768
struct osnoise_tool *tool = NULL;
769+
enum result return_value = ERROR;
769770
struct trace_instance *trace;
770-
int return_value = 1;
771771
int retval;
772772

773773
params = osnoise_hist_parse_args(argc, argv);
@@ -889,12 +889,13 @@ int osnoise_hist_main(int argc, char *argv[])
889889

890890
osnoise_print_stats(params, tool);
891891

892-
return_value = 0;
892+
return_value = PASSED;
893893

894894
if (osnoise_trace_is_off(tool, record)) {
895895
printf("rtla osnoise hit stop tracing\n");
896896
save_trace_to_file(record ? record->trace.inst : NULL,
897897
params->trace_output);
898+
return_value = FAILED;
898899
}
899900

900901
out_hist:

tools/tracing/rtla/src/osnoise_top.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,8 +594,8 @@ int osnoise_top_main(int argc, char **argv)
594594
struct osnoise_params *params;
595595
struct osnoise_tool *record = NULL;
596596
struct osnoise_tool *tool = NULL;
597+
enum result return_value = ERROR;
597598
struct trace_instance *trace;
598-
int return_value = 1;
599599
int retval;
600600

601601
params = osnoise_top_parse_args(argc, argv);
@@ -715,12 +715,13 @@ int osnoise_top_main(int argc, char **argv)
715715

716716
osnoise_print_stats(params, tool);
717717

718-
return_value = 0;
718+
return_value = PASSED;
719719

720720
if (osnoise_trace_is_off(tool, record)) {
721721
printf("osnoise hit stop tracing\n");
722722
save_trace_to_file(record ? record->trace.inst : NULL,
723723
params->trace_output);
724+
return_value = FAILED;
724725
}
725726

726727
out_top:

tools/tracing/rtla/src/timerlat_bpf.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0
22
#ifdef HAVE_BPF_SKEL
3+
#define _GNU_SOURCE
34
#include "timerlat.h"
45
#include "timerlat_bpf.h"
56
#include "timerlat.skel.h"

tools/tracing/rtla/src/timerlat_hist.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,11 +1141,11 @@ int timerlat_hist_main(int argc, char *argv[])
11411141
struct timerlat_params *params;
11421142
struct osnoise_tool *record = NULL;
11431143
struct timerlat_u_params params_u;
1144+
enum result return_value = ERROR;
11441145
struct osnoise_tool *tool = NULL;
11451146
struct osnoise_tool *aa = NULL;
11461147
struct trace_instance *trace;
11471148
int dma_latency_fd = -1;
1148-
int return_value = 1;
11491149
pthread_t timerlat_u;
11501150
int retval;
11511151
int nr_cpus, i;
@@ -1378,7 +1378,7 @@ int timerlat_hist_main(int argc, char *argv[])
13781378

13791379
timerlat_print_stats(params, tool);
13801380

1381-
return_value = 0;
1381+
return_value = PASSED;
13821382

13831383
if (osnoise_trace_is_off(tool, record) && !stop_tracing) {
13841384
printf("rtla timerlat hit stop tracing\n");
@@ -1388,6 +1388,7 @@ int timerlat_hist_main(int argc, char *argv[])
13881388

13891389
save_trace_to_file(record ? record->trace.inst : NULL,
13901390
params->trace_output);
1391+
return_value = FAILED;
13911392
}
13921393

13931394
out_hist:

tools/tracing/rtla/src/timerlat_top.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -985,12 +985,12 @@ int timerlat_top_main(int argc, char *argv[])
985985
struct timerlat_params *params;
986986
struct osnoise_tool *record = NULL;
987987
struct timerlat_u_params params_u;
988+
enum result return_value = ERROR;
988989
struct osnoise_tool *top = NULL;
989990
struct osnoise_tool *aa = NULL;
990991
struct trace_instance *trace;
991992
int dma_latency_fd = -1;
992993
pthread_t timerlat_u;
993-
int return_value = 1;
994994
char *max_lat;
995995
int retval;
996996
int nr_cpus, i;
@@ -1197,7 +1197,7 @@ int timerlat_top_main(int argc, char *argv[])
11971197

11981198
timerlat_print_stats(params, top);
11991199

1200-
return_value = 0;
1200+
return_value = PASSED;
12011201

12021202
if (osnoise_trace_is_off(top, record) && !stop_tracing) {
12031203
printf("rtla timerlat hit stop tracing\n");
@@ -1207,6 +1207,7 @@ int timerlat_top_main(int argc, char *argv[])
12071207

12081208
save_trace_to_file(record ? record->trace.inst : NULL,
12091209
params->trace_output);
1210+
return_value = FAILED;
12101211
} else if (params->aa_only) {
12111212
/*
12121213
* If the trace did not stop with --aa-only, at least print the

tools/tracing/rtla/src/utils.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ long parse_ns_duration(char *val)
227227
# define __NR_sched_setattr 355
228228
# elif __s390x__
229229
# define __NR_sched_setattr 345
230+
# elif __loongarch__
231+
# define __NR_sched_setattr 274
230232
# endif
231233
#endif
232234

tools/tracing/rtla/src/utils.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,9 @@ int auto_house_keeping(cpu_set_t *monitored_cpus);
8383

8484
#define ns_to_usf(x) (((double)x/1000))
8585
#define ns_to_per(total, part) ((part * 100) / (double)total)
86+
87+
enum result {
88+
PASSED = 0, /* same as EXIT_SUCCESS */
89+
ERROR = 1, /* same as EXIT_FAILURE, an error in arguments */
90+
FAILED = 2, /* test hit the stop tracing condition */
91+
};

tools/tracing/rtla/tests/engine.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ reset_osnoise() {
3939
}
4040

4141
check() {
42+
expected_exitcode=${3:-0}
4243
# Simple check: run rtla with given arguments and test exit code.
4344
# If TEST_COUNT is set, run the test. Otherwise, just count.
4445
ctr=$(($ctr + 1))
@@ -49,7 +50,7 @@ check() {
4950
# Run rtla; in case of failure, include its output as comment
5051
# in the test results.
5152
result=$(stdbuf -oL $TIMEOUT "$RTLA" $2 2>&1); exitcode=$?
52-
if [ $exitcode -eq 0 ]
53+
if [ $exitcode -eq $expected_exitcode ]
5354
then
5455
echo "ok $ctr - $1"
5556
else
@@ -68,12 +69,14 @@ check_with_osnoise_options() {
6869
# Save original arguments
6970
arg1=$1
7071
arg2=$2
72+
arg3=$3
7173

7274
# Apply osnoise options (if not dry run)
7375
if [ -n "$TEST_COUNT" ]
7476
then
7577
[ "$NO_RESET_OSNOISE" == 1 ] || reset_osnoise
7678
shift
79+
shift
7780
while shift
7881
do
7982
[ "$1" == "" ] && continue
@@ -84,7 +87,7 @@ check_with_osnoise_options() {
8487
done
8588
fi
8689

87-
NO_RESET_OSNOISE=1 check "$arg1" "$arg2"
90+
NO_RESET_OSNOISE=1 check "$arg1" "$arg2" "$arg3"
8891
}
8992

9093
set_timeout() {

tools/tracing/rtla/tests/hwnoise.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ check "verify help page" \
1010
check "detect noise higher than one microsecond" \
1111
"hwnoise -c 0 -T 1 -d 5s -q"
1212
check "set the automatic trace mode" \
13-
"hwnoise -a 5 -d 30s"
13+
"hwnoise -a 5 -d 30s" 2
1414
check "set scheduling param to the osnoise tracer threads" \
1515
"hwnoise -P F:1 -c 0 -r 900000 -d 1M -q"
1616
check "stop the trace if a single sample is higher than 1 us" \
17-
"hwnoise -s 1 -T 1 -t -d 30s"
17+
"hwnoise -s 1 -T 1 -t -d 30s" 2
1818
check "enable a trace event trigger" \
1919
"hwnoise -t -e osnoise:irq_noise trigger=\"hist:key=desc,duration:sort=desc,duration:vals=hitcount\" -d 1m"
2020

tools/tracing/rtla/tests/osnoise.t

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ check "verify help page" \
1010
check "verify the --priority/-P param" \
1111
"osnoise top -P F:1 -c 0 -r 900000 -d 1M -q"
1212
check "verify the --stop/-s param" \
13-
"osnoise top -s 30 -T 1 -t"
13+
"osnoise top -s 30 -T 1 -t" 2
1414
check "verify the --trace param" \
15-
"osnoise hist -s 30 -T 1 -t"
15+
"osnoise hist -s 30 -T 1 -t" 2
1616
check "verify the --entries/-E param" \
1717
"osnoise hist -P F:1 -c 0 -r 900000 -d 1M -b 10 -E 25"
1818

1919
# Test setting default period by putting an absurdly high period
2020
# and stopping on threshold.
2121
# If default period is not set, this will time out.
2222
check_with_osnoise_options "apply default period" \
23-
"osnoise hist -s 1" period_us=600000000
23+
"osnoise hist -s 1" 2 period_us=600000000
2424

2525
test_end

0 commit comments

Comments
 (0)