tools/perf/bench/sched-seccomp-notify.c

Source file repositories/reference/linux-study-clean/tools/perf/bench/sched-seccomp-notify.c

File Facts

System
Linux kernel
Corpus path
tools/perf/bench/sched-seccomp-notify.c
Extension
.c
Size
4561 bytes
Lines
179
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

while (1) {
			ret = syscall(__NR_gettid);
			if (ret == USER_NOTIF_MAGIC)
				continue;
			break;
		}
		_exit(1);
	}

	if (sync_mode) {
		if (ioctl(listener, SECCOMP_IOCTL_NOTIF_SET_FLAGS,
			     SECCOMP_USER_NOTIF_FD_SYNC_WAKE_UP, 0))
			err(EXIT_FAILURE,
			    "can't set SECCOMP_USER_NOTIF_FD_SYNC_WAKE_UP");
	}
	user_notification_sync_loop(listener);

	kill(pid, SIGKILL);
	if (waitpid(pid, &status, 0) != pid)
		err(EXIT_FAILURE, "waitpid(%d) failed", pid);
	if (!WIFSIGNALED(status) || WTERMSIG(status) != SIGKILL)
		errx(EXIT_FAILURE, "unexpected exit code: %d", status);

	gettimeofday(&stop, NULL);
	timersub(&stop, &start, &diff);

	switch (bench_format) {
	case BENCH_FORMAT_DEFAULT:
		printf("# Executed %" PRIu64 " system calls\n\n",
			loops);

		result_usec = diff.tv_sec * USEC_PER_SEC;
		result_usec += diff.tv_usec;

		printf(" %14s: %lu.%03lu [sec]\n\n", "Total time",
		       (unsigned long) diff.tv_sec,
		       (unsigned long) (diff.tv_usec / USEC_PER_MSEC));

		printf(" %14lf usecs/op\n",
		       (double)result_usec / (double)loops);
		printf(" %14d ops/sec\n",
		       (int)((double)loops /
			     ((double)result_usec / (double)USEC_PER_SEC)));
		break;

	case BENCH_FORMAT_SIMPLE:
		printf("%lu.%03lu\n",
		       (unsigned long) diff.tv_sec,
		       (unsigned long) (diff.tv_usec / USEC_PER_MSEC));
		break;

	default:
		/* reaching here is something disaster */
		fprintf(stderr, "Unknown format:%d\n", bench_format);
		exit(1);
		break;
	}

	return 0;
}

Annotation

Implementation Notes