1 // SPDX-License-Identifier: GPL-2.0
3 * Author: SeongJae Park <sj@kernel.org>
13 #include <sys/types.h>
18 #define DBGFS_TARGET_IDS "/sys/kernel/debug/damon/target_ids"
20 static void write_targetid_exit(void)
22 int target_ids_fd
= open(DBGFS_TARGET_IDS
, O_RDWR
);
25 snprintf(pid_str
, sizeof(pid_str
), "%d", getpid());
26 write(target_ids_fd
, pid_str
, sizeof(pid_str
));
31 unsigned long msec_timestamp(void)
35 gettimeofday(&tv
, NULL
);
36 return tv
.tv_sec
* 1000UL + tv
.tv_usec
/ 1000;
39 int main(int argc
, char *argv
[])
41 unsigned long start_ms
;
42 int time_to_run
, nr_forks
= 0;
45 fprintf(stderr
, "Usage: %s <msecs to run>\n", argv
[0]);
48 time_to_run
= atoi(argv
[1]);
50 start_ms
= msec_timestamp();
55 fprintf(stderr
, "fork() failed\n");
59 write_targetid_exit();
63 if (msec_timestamp() - start_ms
> time_to_run
)
66 printf("%d\n", nr_forks
);