* [PATCH] perf/bench: Fix perf bench syscall XXXX loop count
@ 2025-03-04 9:23 Thomas Richter
2025-03-04 14:14 ` Athira Rajeev
2025-03-06 17:14 ` Namhyung Kim
0 siblings, 2 replies; 3+ messages in thread
From: Thomas Richter @ 2025-03-04 9:23 UTC (permalink / raw)
To: linux-kernel, linux-s390, linux-perf-users, acme, namhyung,
yangtiezhu
Cc: agordeev, gor, sumanthk, hca, Thomas Richter
Command 'perf bench syscall fork -l 100000' offers option
-l to run for a specified number of iterations. However this
option is not always observed. The number is silently limited to
10000 iterations as can be seen:
Output before:
# perf bench syscall fork -l 100000
# Running 'syscall/fork' benchmark:
# Executed 10,000 fork() calls
Total time: 23.388 [sec]
2338.809800 usecs/op
427 ops/sec
#
When explicitly specified with option -l or --loops, also observe
higher number of iterations:
Output after:
# perf bench syscall fork -l 100000
# Running 'syscall/fork' benchmark:
# Executed 100,000 fork() calls
Total time: 716.982 [sec]
7169.829510 usecs/op
139 ops/sec
#
This patch fixes the issue for basic execve fork and getpgid.
Fixes: ece7f7c0507c ("perf bench syscall: Add fork syscall benchmark")
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Acked-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
---
tools/perf/bench/syscall.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/tools/perf/bench/syscall.c b/tools/perf/bench/syscall.c
index ea4dfc07cbd6..e7dc216f717f 100644
--- a/tools/perf/bench/syscall.c
+++ b/tools/perf/bench/syscall.c
@@ -22,8 +22,7 @@
#define __NR_fork -1
#endif
-#define LOOPS_DEFAULT 10000000
-static int loops = LOOPS_DEFAULT;
+static int loops;
static const struct option options[] = {
OPT_INTEGER('l', "loop", &loops, "Specify number of loops"),
@@ -80,6 +79,18 @@ static int bench_syscall_common(int argc, const char **argv, int syscall)
const char *name = NULL;
int i;
+ switch (syscall) {
+ case __NR_fork:
+ case __NR_execve:
+ /* Limit default loop to 10000 times to save time */
+ loops = 10000;
+ break;
+ default:
+ loops = 10000000;
+ break;
+ }
+
+ /* Options -l and --loops override default above */
argc = parse_options(argc, argv, options, bench_syscall_usage, 0);
gettimeofday(&start, NULL);
@@ -94,16 +105,9 @@ static int bench_syscall_common(int argc, const char **argv, int syscall)
break;
case __NR_fork:
test_fork();
- /* Only loop 10000 times to save time */
- if (i == 10000)
- loops = 10000;
break;
case __NR_execve:
test_execve();
- /* Only loop 10000 times to save time */
- if (i == 10000)
- loops = 10000;
- break;
default:
break;
}
--
2.47.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] perf/bench: Fix perf bench syscall XXXX loop count
2025-03-04 9:23 [PATCH] perf/bench: Fix perf bench syscall XXXX loop count Thomas Richter
@ 2025-03-04 14:14 ` Athira Rajeev
2025-03-06 17:14 ` Namhyung Kim
1 sibling, 0 replies; 3+ messages in thread
From: Athira Rajeev @ 2025-03-04 14:14 UTC (permalink / raw)
To: Thomas Richter
Cc: LKML, linux-s390, open list:PERFORMANCE EVENTS SUBSYSTEM,
Arnaldo Carvalho de Melo, Namhyung Kim, yangtiezhu, agordeev, gor,
sumanthk, hca
> On 4 Mar 2025, at 2:53 PM, Thomas Richter <tmricht@linux.ibm.com> wrote:
>
> Command 'perf bench syscall fork -l 100000' offers option
> -l to run for a specified number of iterations. However this
> option is not always observed. The number is silently limited to
> 10000 iterations as can be seen:
>
> Output before:
> # perf bench syscall fork -l 100000
> # Running 'syscall/fork' benchmark:
> # Executed 10,000 fork() calls
> Total time: 23.388 [sec]
>
> 2338.809800 usecs/op
> 427 ops/sec
> #
>
> When explicitly specified with option -l or --loops, also observe
> higher number of iterations:
>
> Output after:
> # perf bench syscall fork -l 100000
> # Running 'syscall/fork' benchmark:
> # Executed 100,000 fork() calls
> Total time: 716.982 [sec]
>
> 7169.829510 usecs/op
> 139 ops/sec
> #
>
Tested-by: Athira Rajeev <atrajeev@linux.ibm.com>
Thanks
Athira
> This patch fixes the issue for basic execve fork and getpgid.
>
> Fixes: ece7f7c0507c ("perf bench syscall: Add fork syscall benchmark")
> Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
> Acked-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
> Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
> tools/perf/bench/syscall.c | 22 +++++++++++++---------
> 1 file changed, 13 insertions(+), 9 deletions(-)
>
> diff --git a/tools/perf/bench/syscall.c b/tools/perf/bench/syscall.c
> index ea4dfc07cbd6..e7dc216f717f 100644
> --- a/tools/perf/bench/syscall.c
> +++ b/tools/perf/bench/syscall.c
> @@ -22,8 +22,7 @@
> #define __NR_fork -1
> #endif
>
> -#define LOOPS_DEFAULT 10000000
> -static int loops = LOOPS_DEFAULT;
> +static int loops;
>
> static const struct option options[] = {
> OPT_INTEGER('l', "loop", &loops, "Specify number of loops"),
> @@ -80,6 +79,18 @@ static int bench_syscall_common(int argc, const char **argv, int syscall)
> const char *name = NULL;
> int i;
>
> + switch (syscall) {
> + case __NR_fork:
> + case __NR_execve:
> + /* Limit default loop to 10000 times to save time */
> + loops = 10000;
> + break;
> + default:
> + loops = 10000000;
> + break;
> + }
> +
> + /* Options -l and --loops override default above */
> argc = parse_options(argc, argv, options, bench_syscall_usage, 0);
>
> gettimeofday(&start, NULL);
> @@ -94,16 +105,9 @@ static int bench_syscall_common(int argc, const char **argv, int syscall)
> break;
> case __NR_fork:
> test_fork();
> - /* Only loop 10000 times to save time */
> - if (i == 10000)
> - loops = 10000;
> break;
> case __NR_execve:
> test_execve();
> - /* Only loop 10000 times to save time */
> - if (i == 10000)
> - loops = 10000;
> - break;
> default:
> break;
> }
> --
> 2.47.0
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] perf/bench: Fix perf bench syscall XXXX loop count
2025-03-04 9:23 [PATCH] perf/bench: Fix perf bench syscall XXXX loop count Thomas Richter
2025-03-04 14:14 ` Athira Rajeev
@ 2025-03-06 17:14 ` Namhyung Kim
1 sibling, 0 replies; 3+ messages in thread
From: Namhyung Kim @ 2025-03-06 17:14 UTC (permalink / raw)
To: linux-kernel, linux-s390, linux-perf-users, acme, yangtiezhu,
Thomas Richter
Cc: agordeev, gor, sumanthk, hca
On Tue, 04 Mar 2025 10:23:49 +0100, Thomas Richter wrote:
> Command 'perf bench syscall fork -l 100000' offers option
> -l to run for a specified number of iterations. However this
> option is not always observed. The number is silently limited to
> 10000 iterations as can be seen:
>
> Output before:
> # perf bench syscall fork -l 100000
> # Running 'syscall/fork' benchmark:
> # Executed 10,000 fork() calls
> Total time: 23.388 [sec]
>
> [...]
Applied to perf-tools-next, thanks!
Best regards,
Namhyung
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-06 17:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-04 9:23 [PATCH] perf/bench: Fix perf bench syscall XXXX loop count Thomas Richter
2025-03-04 14:14 ` Athira Rajeev
2025-03-06 17:14 ` Namhyung Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox