From 6e988609cf760e132a5346f14affee25fcb2f0f4 Mon Sep 17 00:00:00 2001 From: "George V. Neville-Neil" Date: Sat, 3 Sep 2016 00:22:42 +0000 Subject: [PATCH] Add cpuset support to separate forked processes. Reviewed by: cem Sponsored by: Rubicon Communications, LLC (Netgate) Differential Revision: https://reviews.freebsd.org/D7766 --- tools/tools/crypto/cryptotest.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/tools/crypto/cryptotest.c b/tools/tools/crypto/cryptotest.c index 640ec9bb836..bf0f8eef3e4 100644 --- a/tools/tools/crypto/cryptotest.c +++ b/tools/tools/crypto/cryptotest.c @@ -97,6 +97,7 @@ #include #include #include +#include #include #include @@ -468,6 +469,11 @@ runtests(struct alg *alg, int count, int size, u_long cmd, int threads, int prof if (threads > 1) { for (i = 0; i < threads; i++) if (fork() == 0) { + cpuset_t mask; + CPU_ZERO(&mask); + CPU_SET(i, &mask); + cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, + -1, sizeof(mask), &mask); runtest(alg, count, size, cmd, &tvp[i]); exit(0); } @@ -573,6 +579,9 @@ main(int argc, char **argv) } argc--, argv++; } + if (maxthreads > CPU_SETSIZE) + errx(EX_USAGE, "Too many threads, %d, choose fewer.", maxthreads); + if (nsizes == 0) { if (alg) sizes[nsizes++] = alg->blocksize;