Skip to content

Commit fc8f0d7

Browse files
committed
perf bench: Fix perf bench syscall loop count
JIRA: https://issues.redhat.com/browse/RHEL-78197 upstream ======== commit 957d194 Author: Thomas Richter <tmricht@linux.ibm.com> Date: Tue Mar 4 10:23:49 2025 +0100 description =========== 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: ece7f7c ("perf bench syscall: Add fork syscall benchmark") Signed-off-by: Thomas Richter <tmricht@linux.ibm.com> Acked-by: Sumanth Korikkar <sumanthk@linux.ibm.com> Tested-by: Athira Rajeev <atrajeev@linux.ibm.com> Cc: Tiezhu Yang <yangtiezhu@loongson.cn> Link: https://lore.kernel.org/r/20250304092349.2618082-1-tmricht@linux.ibm.com Signed-off-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Michael Petlan <mpetlan@redhat.com>
1 parent 118999d commit fc8f0d7

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

tools/perf/bench/syscall.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
#define __NR_fork -1
2323
#endif
2424

25-
#define LOOPS_DEFAULT 10000000
26-
static int loops = LOOPS_DEFAULT;
25+
static int loops;
2726

2827
static const struct option options[] = {
2928
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)
8079
const char *name = NULL;
8180
int i;
8281

82+
switch (syscall) {
83+
case __NR_fork:
84+
case __NR_execve:
85+
/* Limit default loop to 10000 times to save time */
86+
loops = 10000;
87+
break;
88+
default:
89+
loops = 10000000;
90+
break;
91+
}
92+
93+
/* Options -l and --loops override default above */
8394
argc = parse_options(argc, argv, options, bench_syscall_usage, 0);
8495

8596
gettimeofday(&start, NULL);
@@ -94,16 +105,9 @@ static int bench_syscall_common(int argc, const char **argv, int syscall)
94105
break;
95106
case __NR_fork:
96107
test_fork();
97-
/* Only loop 10000 times to save time */
98-
if (i == 10000)
99-
loops = 10000;
100108
break;
101109
case __NR_execve:
102110
test_execve();
103-
/* Only loop 10000 times to save time */
104-
if (i == 10000)
105-
loops = 10000;
106-
break;
107111
default:
108112
break;
109113
}

0 commit comments

Comments
 (0)