diff options
author | Fengguang Wu <fengguang.wu@intel.com> | 2013-09-30 11:17:46 +0800 |
---|---|---|
committer | Fengguang Wu <fengguang.wu@intel.com> | 2013-09-30 11:37:13 +0800 |
commit | ec44094f517f45965e0c413bb27e596d433100f1 (patch) | |
tree | e9b98e307695c3b6425638cf19a14690265eb58b | |
parent | 3bac73108f348e303d4c898bcf6e04ad54f6b3c6 (diff) | |
download | vm-scalability-ec44094f517f45965e0c413bb27e596d433100f1.tar.gz |
case-migrate: improve kill wait
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
-rwxr-xr-x | case-migrate | 14 | ||||
-rwxr-xr-x | run | 3 | ||||
-rw-r--r-- | usemem.c | 21 |
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 @@ -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 } @@ -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); } } |