aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFengguang Wu <fengguang.wu@intel.com>2013-09-30 11:17:46 +0800
committerFengguang Wu <fengguang.wu@intel.com>2013-09-30 11:37:13 +0800
commitec44094f517f45965e0c413bb27e596d433100f1 (patch)
treee9b98e307695c3b6425638cf19a14690265eb58b
parent3bac73108f348e303d4c898bcf6e04ad54f6b3c6 (diff)
downloadvm-scalability-ec44094f517f45965e0c413bb27e596d433100f1.tar.gz
case-migrate: improve kill wait
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
-rwxr-xr-xcase-migrate14
-rwxr-xr-xrun3
-rw-r--r--usemem.c21
3 files changed, 12 insertions, 26 deletions
diff --git a/case-migrate b/case-migrate
index 386253f..4d0f366 100755
--- a/case-migrate
+++ b/case-migrate
@@ -4,12 +4,14 @@ source ./hw_vars
create_sparse_file $SPARSE_FILE $mem
+[[ $runtime ]] || runtime=60
+
migrate_unit=$((mem/nr_node/2))
-numactl --interleave=all $USEMEM -f $SPARSE_FILE --readonly $migrate_unit --detach --sleep 100000 --pid-file $PIDFILE
+numactl --interleave=all $USEMEM -f $SPARSE_FILE --readonly $migrate_unit --detach --sleep $((runtime * 2)) --pid-file $PIDFILE
pid=$(<$PIDFILE)
-
-[[ $runtime ]] || runtime=60
+rm $PIDFILE
+rm $SPARSE_FILE
start_time=$(date +%s%N)
start_time=${start_time%???}
@@ -31,13 +33,11 @@ done
throughput=$((count * migrate_unit / usecs))
echo "$count * $migrate_unit bytes migrated, $usecs usecs, $throughput MB/s"
-kill $pid
-rm $SPARSE_FILE
-rm $PIDFILE
+kill -INT $pid
# the sleep is necessary for umount to succeed
# it takes some time to kill the usemem process
while [[ -d /proc/$pid && $(</proc/$pid/comm) = usemem ]]
do
- sleep 1
+ sleep 0.1
done
diff --git a/run b/run
index 351663b..e1aeab5 100755
--- a/run
+++ b/run
@@ -133,7 +133,8 @@ remove_sparse_root
kill_detached() {
for pidfile in $SPARSE_ROOT/*.pid
do
- [[ -s $pidfile ]] && kill $(<$pidfile)
+ [[ -s $pidfile ]] && kill -INT $(<$pidfile)
+ rm $pidfile
done
}
diff --git a/usemem.c b/usemem.c
index 99575b4..7c23417 100644
--- a/usemem.c
+++ b/usemem.c
@@ -242,15 +242,6 @@ int up(int sem_id)
return semop(sem_id, &buf, 1);
}
-void delete_pid_file(void)
-{
- if (!pid_filename)
- return;
-
- if (unlink(pid_filename) < 0)
- perror(pid_filename);
-}
-
void update_pid_file(pid_t pid)
{
FILE *file;
@@ -272,10 +263,9 @@ void update_pid_file(pid_t pid)
void sighandler(int sig, siginfo_t *si, void *arg)
{
up(sem_id);
- delete_pid_file();
- fprintf(stderr, "Fatal signal %d\n", sig);
- exit(1);
+ fprintf(stderr, "usemem: exit on signal %d\n", sig);
+ exit(0);
}
void detach(void)
@@ -318,12 +308,7 @@ void detach(void)
* XXX: SIGKILL cannot be caught.
* The parent will wait for ever if child is OOM killed.
*/
- sigaction(SIGBUS, &sa, NULL);
-
- if (atexit(delete_pid_file) != 0) {
- fprintf(stderr, "cannot set exit function\n");
- exit(1);
- }
+ sigaction(SIGINT, &sa, NULL);
}
}