Skip to content

Commit 27ac597

Browse files
notValordacmel
authored andcommitted
perf test record.sh: Raise limit of open file descriptors
Subtest for system-wide record with '--threads=cpu' option fails due to a limit of open file descriptors on systems with 128 or more CPUs as the default limit is set to 1024. The number of open file descriptors should be slightly above nmb_events*nmb_cpus + nmb_cpus(for perf.data.n) + 4*nmb_cpus(for pipes), which equals 8*nmb_cpus. Therefore, temporarily raise the limit to 16*nmb_cpus for the test. Committer notes: Instead of disabling ShellCheck warnings all the uses of 'uname -n', i.e. those: In tests/shell/record.sh line 35: default_fd_limit=$(ulimit -Sn) ^-^ SC3045 (warning): In POSIX sh, ulimit -S is undefined. We can just switch from using '/bin/sh' to '/bin/bash' for this test, as bash _has_ 'ulimit -n', so ShellCheck will not emit that warning. There are dozens of 'perf test' shell tests that do just that, '/bin/bash' is a reasonable expectation for those tests. Signed-off-by: Veronika Molnarova <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Athira Rajeev <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kajol Jain <[email protected]> Cc: Michael Petlan <[email protected]> Cc: Radostin Stoyanov <[email protected]> Link: https://lore.kernel.org/linux-perf-users/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 4c55560 commit 27ac597

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

tools/perf/tests/shell/record.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
# perf record tests
33
# SPDX-License-Identifier: GPL-2.0
44

@@ -23,6 +23,15 @@ br_cntr_file="/caps/branch_counter_nr"
2323
br_cntr_output="branch stack counters"
2424
br_cntr_script_output="br_cntr: A"
2525

26+
default_fd_limit=$(ulimit -Sn)
27+
# With option --threads=cpu the number of open file descriptors should be
28+
# equal to sum of: nmb_cpus * nmb_events (2+dummy),
29+
# nmb_threads for perf.data.n (equal to nmb_cpus) and
30+
# 2*nmb_cpus of pipes = 4*nmb_cpus (each pipe has 2 ends)
31+
# All together it needs 8*nmb_cpus file descriptors plus some are also used
32+
# outside of testing, thus raising the limit to 16*nmb_cpus
33+
min_fd_limit=$(($(getconf _NPROCESSORS_ONLN) * 16))
34+
2635
cleanup() {
2736
rm -rf "${perfdata}"
2837
rm -rf "${perfdata}".old
@@ -197,11 +206,19 @@ test_branch_counter() {
197206
echo "Branch counter test [Success]"
198207
}
199208

209+
# raise the limit of file descriptors to minimum
210+
if [[ $default_fd_limit -lt $min_fd_limit ]]; then
211+
ulimit -Sn $min_fd_limit
212+
fi
213+
200214
test_per_thread
201215
test_register_capture
202216
test_system_wide
203217
test_workload
204218
test_branch_counter
205219

220+
# restore the default value
221+
ulimit -Sn $default_fd_limit
222+
206223
cleanup
207224
exit $err

0 commit comments

Comments
 (0)