summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtools/perf/tests/shell/record.sh19
1 files changed, 18 insertions, 1 deletions
diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
index 7964ebd9007d..36883b03169f 100755
--- a/tools/perf/tests/shell/record.sh
+++ b/tools/perf/tests/shell/record.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
# perf record tests
# SPDX-License-Identifier: GPL-2.0
@@ -23,6 +23,15 @@ br_cntr_file="/caps/branch_counter_nr"
br_cntr_output="branch stack counters"
br_cntr_script_output="br_cntr: A"
+default_fd_limit=$(ulimit -Sn)
+# With option --threads=cpu the number of open file descriptors should be
+# equal to sum of: nmb_cpus * nmb_events (2+dummy),
+# nmb_threads for perf.data.n (equal to nmb_cpus) and
+# 2*nmb_cpus of pipes = 4*nmb_cpus (each pipe has 2 ends)
+# All together it needs 8*nmb_cpus file descriptors plus some are also used
+# outside of testing, thus raising the limit to 16*nmb_cpus
+min_fd_limit=$(($(getconf _NPROCESSORS_ONLN) * 16))
+
cleanup() {
rm -rf "${perfdata}"
rm -rf "${perfdata}".old
@@ -197,11 +206,19 @@ test_branch_counter() {
echo "Branch counter test [Success]"
}
+# raise the limit of file descriptors to minimum
+if [[ $default_fd_limit -lt $min_fd_limit ]]; then
+ ulimit -Sn $min_fd_limit
+fi
+
test_per_thread
test_register_capture
test_system_wide
test_workload
test_branch_counter
+# restore the default value
+ulimit -Sn $default_fd_limit
+
cleanup
exit $err