From b0d0a09235093cf11fbe83ce502d7079bc255f7e Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Thu, 22 Sep 2011 04:22:34 +0200 Subject: [PATCH] Speedup cpu-load experiments by stopping hackbench during maintenance --- gw-tests/lib.sh | 5 +++-- latester/Makefile.omk | 3 +++ latester/latester.c | 15 +++++++++++++++ latester/setpgid.c | 29 +++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 latester/setpgid.c diff --git a/gw-tests/lib.sh b/gw-tests/lib.sh index c5492e8..8cfcf26 100644 --- a/gw-tests/lib.sh +++ b/gw-tests/lib.sh @@ -91,9 +91,10 @@ traffic_and_length() { } start_load() { + unset LATESTER_CONTROL_HACKBENCH case $load in none) ;; - cpu) sshgw 'hackbench -g 3 -l 100000' & loadpid=$!;; + cpu) export LATESTER_CONTROL_HACKBENCH=$(sshgw 'nohup setpgid hackbench -g 3 -l 100000 >/dev/null & echo $!');; eth) ping -f -s 60000 -q 192.168.2.3 & loadpid=$!;; # TODO: Generate eth load from another computer can) latester -q -d can1 -i 0x7ff & loadpid=$!;; *) error "Unknown load specification: $load" @@ -103,7 +104,7 @@ start_load() { kill_load() { case $load in none) ;; - cpu) kill $loadpid; sshgw "killall -q hackbench || :";; + cpu) sshgw "kill -9 -$LATESTER_CONTROL_HACKBENCH; killall -q -9 hackbench || :";; eth) kill $loadpid;; can) kill $loadpid;; *) error "Unknown load specification: $load" diff --git a/latester/Makefile.omk b/latester/Makefile.omk index 0b9029d..0d1e2be 100644 --- a/latester/Makefile.omk +++ b/latester/Makefile.omk @@ -8,3 +8,6 @@ INCLUDES = -DSO_RXQ_OVFL=40 \ -DPF_CAN=29 \ -DAF_CAN=PF_CAN + +bin_PROGRAMS += setpgid +setpgid_SOURCES = setpgid.c diff --git a/latester/latester.c b/latester/latester.c index d09b1ab..30e62f1 100644 --- a/latester/latester.c +++ b/latester/latester.c @@ -884,6 +884,13 @@ int main(int argc, const char *argv[]) error(1, errno, "pipe fcntl"); init_ftrace(); + if (getenv("LATESTER_CONTROL_HACKBENCH")) { + char cmd[1000]; + sprintf(cmd, "ssh -x -a -S $HOME/.ssh/cangw-connection root@192.168.2.3 'kill -CONT -%s'", + getenv("LATESTER_CONTROL_HACKBENCH")); + printf("Running: %s\n", cmd); + system(cmd); + } pthread_create(&thread, 0, measure_thread, NULL); @@ -933,6 +940,14 @@ int main(int argc, const char *argv[]) pthread_join(thread, NULL); + if (getenv("LATESTER_CONTROL_HACKBENCH")) { + char cmd[1000]; + sprintf(cmd, "ssh -x -a -S $HOME/.ssh/cangw-connection root@192.168.2.3 'kill -STOP -%s'", + getenv("LATESTER_CONTROL_HACKBENCH")); + printf("Running: %s\n", cmd); + system(cmd); + } + close(completion_pipe[0]); close(completion_pipe[1]); diff --git a/latester/setpgid.c b/latester/setpgid.c new file mode 100644 index 0000000..0562302 --- /dev/null +++ b/latester/setpgid.c @@ -0,0 +1,29 @@ +#define _XOPEN_SOURCE 500 +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + if (argc < 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); + return 1; + } + pid_t pid; + pid = atol(argv[1]); + if (setpgid(0, 0) != 0) { + perror("setpgid"); + return 1; + } + + char **newargv = malloc(sizeof(void*)*argc); + unsigned i; + for (i=1; i