Speedup cpu-load experiments by stopping hackbench during maintenance
authorMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 22 Sep 2011 02:22:34 +0000 (04:22 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 22 Sep 2011 02:23:39 +0000 (04:23 +0200)
gw-tests/lib.sh
latester/Makefile.omk
latester/latester.c
latester/setpgid.c [new file with mode: 0644]

index c5492e8..8cfcf26 100644 (file)
@@ -91,9 +91,10 @@ traffic_and_length() {
 }
 
 start_load() {
 }
 
 start_load() {
+    unset LATESTER_CONTROL_HACKBENCH
     case $load in
        none) ;;
     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"
        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) ;;
 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"
        eth) kill $loadpid;;
        can) kill $loadpid;;
        *) error "Unknown load specification: $load"
index 0b9029d..0d1e2be 100644 (file)
@@ -8,3 +8,6 @@ INCLUDES = -DSO_RXQ_OVFL=40 \
           -DPF_CAN=29 \
           -DAF_CAN=PF_CAN
 
           -DPF_CAN=29 \
           -DAF_CAN=PF_CAN
 
+
+bin_PROGRAMS += setpgid
+setpgid_SOURCES = setpgid.c
index d09b1ab..30e62f1 100644 (file)
@@ -884,6 +884,13 @@ int main(int argc, const char *argv[])
                error(1, errno, "pipe fcntl");
 
        init_ftrace();
                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);
 
 
        pthread_create(&thread, 0, measure_thread, NULL);
 
@@ -933,6 +940,14 @@ int main(int argc, const char *argv[])
 
        pthread_join(thread, NULL);
 
 
        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]);
 
        close(completion_pipe[0]);
        close(completion_pipe[1]);
 
diff --git a/latester/setpgid.c b/latester/setpgid.c
new file mode 100644 (file)
index 0000000..0562302
--- /dev/null
@@ -0,0 +1,29 @@
+#define _XOPEN_SOURCE 500
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+
+int main(int argc, char *argv[])
+{
+       if (argc < 2) {
+               fprintf(stderr, "Usage: %s <command>\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<argc; i++)
+               newargv[i-1] = argv[i];
+       newargv[argc-1] = NULL;
+       kill(0, SIGSTOP);
+       execvp(argv[1], newargv);
+       perror("execvp");   /* execve() only returns on error */
+       exit(EXIT_FAILURE);
+}