Although we currently don't compile in CPU-pinning support by default,
add a -P to enable it if it were. MFC after: 1 week Sponsored by: Juniper Networks
This commit is contained in:
parent
5c15d3c87e
commit
73dd1f4339
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=208859
@ -39,6 +39,7 @@ The client has more to configure, with the following flags:
|
||||
|
||||
-c <remoteIP> Select client mode, and specific dest IP
|
||||
-C Print connections/second instead of GBps
|
||||
-P Pin each worker to a CPU
|
||||
-M <localIPcount> Number of sequential local IPs to use; req. -l
|
||||
-T Include CPU use summary in stats at end of run
|
||||
-b <bytespertcp> Data bytes per connection
|
||||
|
@ -51,7 +51,7 @@
|
||||
|
||||
struct sockaddr_in remoteip; /* Base target address. */
|
||||
struct sockaddr_in localipbase; /* Base local address, if -l. */
|
||||
int cflag, lflag, mflag, pflag, sflag, tflag, Cflag, Mflag, Tflag;
|
||||
int cflag, lflag, mflag, pflag, sflag, tflag, Cflag, Mflag, Pflag, Tflag;
|
||||
uint64_t bflag;
|
||||
u_short rflag;
|
||||
|
||||
@ -61,24 +61,27 @@ usage(void)
|
||||
|
||||
fprintf(stderr, "client: tcpp"
|
||||
" -c remoteIP"
|
||||
" [-CT]"
|
||||
" [-CPT]"
|
||||
" [-M localIPcount]"
|
||||
" [-l localIPbase]"
|
||||
"\n\t"
|
||||
" [-b bytespertcp]"
|
||||
" [-m maxtcpsatonce]"
|
||||
"\n"
|
||||
"\t"
|
||||
" [-p procs]"
|
||||
" [-t tcpsperproc]"
|
||||
"\n"
|
||||
"\t"
|
||||
" [-r baseport]"
|
||||
"\n");
|
||||
|
||||
fprintf(stderr, "server: tcpp"
|
||||
" -s"
|
||||
" [-T]"
|
||||
" [-PT]"
|
||||
" [-l localIPbase]"
|
||||
" [-m maxtcpsatonce]"
|
||||
" [-p procs]"
|
||||
"\n"
|
||||
"\t"
|
||||
" [-r baseport]"
|
||||
"\n");
|
||||
exit(EX_USAGE);
|
||||
@ -109,7 +112,7 @@ main(int argc, char *argv[])
|
||||
rflag = BASEPORT_DEFAULT;
|
||||
tflag = TCPS_DEFAULT;
|
||||
Mflag = 1;
|
||||
while ((ch = getopt(argc, argv, "b:c:l:m:p:r:st:CM:T")) != -1) {
|
||||
while ((ch = getopt(argc, argv, "b:c:l:m:p:r:st:CM:PT")) != -1) {
|
||||
switch (ch) {
|
||||
case 'b':
|
||||
ll = strtoll(optarg, &dummy, 10);
|
||||
@ -173,6 +176,14 @@ main(int argc, char *argv[])
|
||||
Mflag = ll;
|
||||
break;
|
||||
|
||||
case 'P':
|
||||
#if defined(CPU_SETSIZE) && 0
|
||||
Pflag++;
|
||||
break;
|
||||
#else
|
||||
errx(EX_USAGE, "-P current unsupported");
|
||||
#endif
|
||||
|
||||
case 'T':
|
||||
Tflag++;
|
||||
break;
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
extern struct sockaddr_in localipbase, remoteip;
|
||||
extern int cflag, lflag, mflag, pflag, sflag, tflag;
|
||||
extern int Cflag, Iflag, Mflag, Tflag;
|
||||
extern int Cflag, Iflag, Mflag, Pflag, Tflag;
|
||||
extern uint64_t bflag;
|
||||
extern u_short rflag;
|
||||
|
||||
|
@ -224,17 +224,19 @@ tcpp_client_worker(int workernum)
|
||||
int ncpus;
|
||||
size_t len;
|
||||
|
||||
len = sizeof(ncpus);
|
||||
if (sysctlbyname(SYSCTLNAME_CPUS, &ncpus, &len, NULL, 0) < 0)
|
||||
err(-1, "sysctlbyname: %s", SYSCTLNAME_CPUS);
|
||||
if (len != sizeof(ncpus))
|
||||
errx(-1, "sysctlbyname: %s: len %jd", SYSCTLNAME_CPUS,
|
||||
(intmax_t)len);
|
||||
if (Pflag) {
|
||||
len = sizeof(ncpus);
|
||||
if (sysctlbyname(SYSCTLNAME_CPUS, &ncpus, &len, NULL, 0) < 0)
|
||||
err(-1, "sysctlbyname: %s", SYSCTLNAME_CPUS);
|
||||
if (len != sizeof(ncpus))
|
||||
errx(-1, "sysctlbyname: %s: len %jd", SYSCTLNAME_CPUS,
|
||||
(intmax_t)len);
|
||||
|
||||
CPU_ZERO(&mask);
|
||||
CPU_SET(workernum % ncpus, &mask);
|
||||
if (sched_setaffinity(0, CPU_SETSIZE, &mask) < 0)
|
||||
err(-1, "sched_setaffinity");
|
||||
CPU_ZERO(&mask);
|
||||
CPU_SET(workernum % ncpus, &mask);
|
||||
if (sched_setaffinity(0, CPU_SETSIZE, &mask) < 0)
|
||||
err(-1, "sched_setaffinity");
|
||||
}
|
||||
#endif
|
||||
setproctitle("tcpp_client %d", workernum);
|
||||
|
||||
|
@ -201,17 +201,19 @@ tcpp_server_worker(int workernum)
|
||||
int ncpus;
|
||||
ssize_t len;
|
||||
|
||||
len = sizeof(ncpus);
|
||||
if (sysctlbyname(SYSCTLNAME_CPUS, &ncpus, &len, NULL, 0) < 0)
|
||||
err(-1, "sysctlbyname: %s", SYSCTLNAME_CPUS);
|
||||
if (len != sizeof(ncpus))
|
||||
errx(-1, "sysctlbyname: %s: len %jd", SYSCTLNAME_CPUS,
|
||||
(intmax_t)len);
|
||||
if (Pflag) {
|
||||
len = sizeof(ncpus);
|
||||
if (sysctlbyname(SYSCTLNAME_CPUS, &ncpus, &len, NULL, 0) < 0)
|
||||
err(-1, "sysctlbyname: %s", SYSCTLNAME_CPUS);
|
||||
if (len != sizeof(ncpus))
|
||||
errx(-1, "sysctlbyname: %s: len %jd", SYSCTLNAME_CPUS,
|
||||
(intmax_t)len);
|
||||
|
||||
CPU_ZERO(&mask);
|
||||
CPU_SET(workernum % ncpus, &mask);
|
||||
if (sched_setaffinity(0, CPU_SETSIZE, &mask) < 0)
|
||||
err(-1, "sched_setaffinity");
|
||||
CPU_ZERO(&mask);
|
||||
CPU_SET(workernum % ncpus, &mask);
|
||||
if (sched_setaffinity(0, CPU_SETSIZE, &mask) < 0)
|
||||
err(-1, "sched_setaffinity");
|
||||
}
|
||||
#endif
|
||||
setproctitle("tcpp_server %d", workernum);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user