All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf test record.sh: Raise limit of open file descriptors
@ 2023-11-15 14:05 vmolnaro
  2023-11-21 12:32 ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 4+ messages in thread
From: vmolnaro @ 2023-11-15 14:05 UTC (permalink / raw)
  To: linux-perf-users, acme, acme; +Cc: mpetlan

From: Veronika Molnarova <vmolnaro@redhat.com>

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.

Signed-off-by: Veronika Molnarova <vmolnaro@redhat.com>
---
 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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] perf test record.sh: Raise limit of open file descriptors
  2023-11-15 14:05 [PATCH] perf test record.sh: Raise limit of open file descriptors vmolnaro
@ 2023-11-21 12:32 ` Arnaldo Carvalho de Melo
  2023-11-30 21:29   ` vmolnaro
  0 siblings, 1 reply; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-11-21 12:32 UTC (permalink / raw)
  To: vmolnaro; +Cc: linux-perf-users, acme, mpetlan, Linux Kernel Mailing List

Em Wed, Nov 15, 2023 at 03:05:22PM +0100, vmolnaro@redhat.com escreveu:
> From: Veronika Molnarova <vmolnaro@redhat.com>
 
> 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@redhat.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] perf test record.sh: Raise limit of open file descriptors
  2023-11-21 12:32 ` Arnaldo Carvalho de Melo
@ 2023-11-30 21:29   ` vmolnaro
  0 siblings, 0 replies; 4+ messages in thread
From: vmolnaro @ 2023-11-30 21:29 UTC (permalink / raw)
  To: linux-perf-users, acme, acme, vmolnaro; +Cc: mpetlan

From: Veronika Molnarova <vmolnaro@redhat.com>

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.

Signed-off-by: Veronika Molnarova <vmolnaro@redhat.com>
---
 tools/perf/tests/shell/record.sh | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
index 4fbc74805d52..8acd55d09a1c 100755
--- a/tools/perf/tests/shell/record.sh
+++ b/tools/perf/tests/shell/record.sh
@@ -11,6 +11,14 @@ err=0
 perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
 testprog="perf test -w thloop"
 testsym="test_loop"
+default_fd_limit=$(ulimit -n)
+# 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}"
@@ -154,10 +162,18 @@ test_workload() {
   echo "Basic target workload test [Success]"
 }
 
+# raise the limit of file descriptors to minimum
+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
 
+# restore the default value
+ulimit -n $default_fd_limit
+
 cleanup
 exit $err
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] perf test record.sh: Raise limit of open file descriptors
  2024-03-20 14:19 [PATCH v2] " Arnaldo Carvalho de Melo
@ 2024-03-28 15:46 ` vmolnaro
  0 siblings, 0 replies; 4+ messages in thread
From: vmolnaro @ 2024-03-28 15:46 UTC (permalink / raw)
  To: linux-perf-users, acme, acme; +Cc: mpetlan

From: Veronika Molnarova <vmolnaro@redhat.com>

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.

Signed-off-by: Veronika Molnarova <vmolnaro@redhat.com>
---
Reworked the patch as the testfile has already changed since the patch
was sent causing the applying to fail. Should be good now.
 tools/perf/tests/shell/record.sh | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
index 4fbc74805d52..8dc90fa08682 100755
--- a/tools/perf/tests/shell/record.sh
+++ b/tools/perf/tests/shell/record.sh
@@ -11,6 +11,14 @@ err=0
 perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
 testprog="perf test -w thloop"
 testsym="test_loop"
+default_fd_limit=$(ulimit -n)
+# 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}"
@@ -154,10 +162,18 @@ test_workload() {
   echo "Basic target workload test [Success]"
 }
 
+# raise the limit of file descriptors to minimum
+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
 
+# restore the default value
+ulimit -n $default_fd_limit
+
 cleanup
 exit $err
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-03-28 15:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-15 14:05 [PATCH] perf test record.sh: Raise limit of open file descriptors vmolnaro
2023-11-21 12:32 ` Arnaldo Carvalho de Melo
2023-11-30 21:29   ` vmolnaro
2024-03-20 14:19 [PATCH v2] " Arnaldo Carvalho de Melo
2024-03-28 15:46 ` [PATCH] " vmolnaro

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.