diff --git a/src/task_bulk.c b/src/task_bulk.c
index 3a854ec06979ff0ff8ff7c092169d49c135d561c..3d69110143aa2e1cd9a4e622ce7063f20ccba276 100644
--- a/src/task_bulk.c
+++ b/src/task_bulk.c
@@ -41,12 +41,12 @@ static void bump_memlock_rlimit(void)
}
static void print_usage(char **argv) {
- fprintf(stderr, "Usage: %s user|bpf", argv[0]);
+ fprintf(stderr, "Usage: %s user|bpf <iter>", argv[0]);
}
int main(int argc, char **argv)
{
- if (argc != 2) {
+ if (argc != 3) {
print_usage(argv);
return 1;
}
@@ -59,29 +59,36 @@ int main(int argc, char **argv)
print_usage(argv);
return 1;
}
+ int iter = atoi(argv[2]);
+ if (iter < 0) {
+ print_usage(argv);
+ return 1;
+ }
int err;
+
if (user) {
int *fds = malloc(sizeof(int) * SIZE);
if (fds == NULL) {
return 1;
}
- for (int i = 0; i < SIZE; i++) {
- int fd = open("/tmp", O_TMPFILE | O_RDWR, S_IRUSR | S_IWUSR);
- if (fd == -1) {
- perror("open");
- return 1;
+ for (int j = 0; j < iter; j++) {
+ for (int i = 0; i < SIZE; i++) {
+ int fd = open("/tmp", O_TMPFILE | O_RDWR, S_IRUSR | S_IWUSR);
+ if (fd == -1) {
+ perror("open");
+ return 1;
+ }
+ fds[i] = fd;
}
- fds[i] = fd;
- }
-
- for (int i = 0; i < SIZE; i++) {
- err = close(fds[i]);
- if (err) {
- perror("close");
- return 1;
+ for (int i = 0; i < SIZE; i++) {
+ err = close(fds[i]);
+ if (err) {
+ perror("close");
+ return 1;
+ }
}
}
@@ -113,8 +120,9 @@ int main(int argc, char **argv)
int prog_fd = bpf_program__fd(skel->progs.entry);
- long *output;
- err = syscall(SYS_bpftask, prog_fd, &output);
+ for (int j = 0; j < iter; j++) {
+ err = syscall(SYS_bpftask, prog_fd, NULL);
+ }
cleanup:
task_bulk_bpf__destroy(skel);