Re: [PATCH] perf test record.sh: Raise limit of open file descriptors

From: Arnaldo Carvalho de Melo
Date: Tue Nov 21 2023 - 07:32:46 EST


Em Wed, Nov 15, 2023 at 03:05:22PM +0100, vmolnaro@xxxxxxxxxx escreveu:
> From: Veronika Molnarova <vmolnaro@xxxxxxxxxx>

> Subtest for system-wide record with '--threads' option fails due to a
> limit of open file descriptors(usually set to 1024) on systems with
> 128 and more CPUs.
>
> If the default limit is set lower than 2048 file descriptors,
> temporarily raise it to this value for the test.

Can we instead raise it to a multiple of the number of CPUs? Using:

[acme@five ~]$ getconf _NPROCESSORS_ONLN
32
[acme@five ~]$

If you tested 2048 is ok for a 128 CPU system, then maybe this is more
future proof:

[acme@five ~]$ echo $(($(getconf _NPROCESSORS_ONLN) * 16))
512
[acme@five ~]$ echo $((128 * 16))
2048
[acme@five ~]$

- Arnaldo

> Signed-off-by: Veronika Molnarova <vmolnaro@xxxxxxxxxx>
> ---
> tools/perf/tests/shell/record.sh | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> index 4fbc74805d52..c6c43263809a 100755
> --- a/tools/perf/tests/shell/record.sh
> +++ b/tools/perf/tests/shell/record.sh
> @@ -11,6 +11,8 @@ err=0
> perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
> testprog="perf test -w thloop"
> testsym="test_loop"
> +min_fd_limit=2048
> +default_fd_limit=$(ulimit -n)
>
> cleanup() {
> rm -rf "${perfdata}"
> @@ -154,10 +156,16 @@ test_workload() {
> echo "Basic target workload test [Success]"
> }
>
> +if [[ $default_fd_limit -lt $min_fd_limit ]]; then
> + ulimit -n $min_fd_limit
> +fi
> +
> test_per_thread
> test_register_capture
> test_system_wide
> test_workload
>
> +ulimit -n $default_fd_limit
> +
> cleanup
> exit $err
> --
> 2.41.0