diff options
author | Jiachen Yang | 2016-04-24 13:08:04 +0900 |
---|---|---|
committer | Jiachen Yang | 2016-04-24 13:08:04 +0900 |
commit | 54f54b4234a6f61a1468b2a6bd6b5814a871cdfe (patch) | |
tree | e7ae8c6206ce1fe33b4f365330e164fc44dc1c8e | |
download | aur-54f54b4234a6f61a1468b2a6bd6b5814a871cdfe.tar.gz |
push to aur
-rw-r--r-- | .SRCINFO | 18 | ||||
-rw-r--r-- | PKGBUILD | 25 | ||||
-rwxr-xr-x | analyze-shutdown | 115 | ||||
-rwxr-xr-x | diagnose.shutdown | 5 | ||||
-rw-r--r-- | shutdown-diagnose.service | 11 | ||||
-rwxr-xr-x | start-diagnose-shutdown | 20 |
6 files changed, 194 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..325b3ac4c3b3 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,18 @@ +pkgbase = systemd-shutdown-diagnose + pkgdesc = help to diagnose shutdown sequence for systemd + pkgver = 4 + pkgrel = 1 + url = http://github.com/farseerfc/systemd-shutdown-diagnose + arch = any + license = GPL2 + source = analyze-shutdown + source = diagnose.shutdown + source = shutdown-diagnose.service + source = start-diagnose-shutdown + sha512sums = 883b12b23cad21f620fb10e6f682390d155da65f41517701296793e7ad4ca16e55547b78d3fb06dd697a261e5f236e5d96e6d6c539d16ed3a7b52f890066ac59 + sha512sums = ab00ff35e6e74f90589587c44d3efc4584f0d5d40e7767ee2fc982f2b20f0656dfbb58b3c3a8103a32538a28bb08dd15087114aae0b1f6f73a12b6073d32c99f + sha512sums = 26faec19537be2d4dad83e16a3557d1ab20f71a3f66abbfb8725e7fd9233fef6df2c21c81f5c48c48963746d8b319483615a25ae1fb49f8b3667f30e6b1418ec + sha512sums = 2ee770dce7cbf95d07b49e24522c6be2d7dd8f3cbe88097d6b27a9ea05052525ef58ef6c2f95bf09bcbc38db46918098faf13655c0f6853b3057dac9ec10e6bb + +pkgname = systemd-shutdown-diagnose + diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..020552ecafad --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,25 @@ +# Maintainer: Jiachen Yang <farseerfc@gmail.com> +pkgname=systemd-shutdown-diagnose +pkgver=4 +pkgrel=1 +pkgdesc="help to diagnose shutdown sequence for systemd" +arch=(any) +url="http://github.com/farseerfc/systemd-shutdown-diagnose" +license=('GPL2') +depends=() +source=('analyze-shutdown' + 'diagnose.shutdown' + 'shutdown-diagnose.service' + 'start-diagnose-shutdown' +) +sha512sums=('883b12b23cad21f620fb10e6f682390d155da65f41517701296793e7ad4ca16e55547b78d3fb06dd697a261e5f236e5d96e6d6c539d16ed3a7b52f890066ac59' + 'ab00ff35e6e74f90589587c44d3efc4584f0d5d40e7767ee2fc982f2b20f0656dfbb58b3c3a8103a32538a28bb08dd15087114aae0b1f6f73a12b6073d32c99f' + '26faec19537be2d4dad83e16a3557d1ab20f71a3f66abbfb8725e7fd9233fef6df2c21c81f5c48c48963746d8b319483615a25ae1fb49f8b3667f30e6b1418ec' + '2ee770dce7cbf95d07b49e24522c6be2d7dd8f3cbe88097d6b27a9ea05052525ef58ef6c2f95bf09bcbc38db46918098faf13655c0f6853b3057dac9ec10e6bb') + +package() { + install -Dm755 diagnose.shutdown "$pkgdir/usr/lib/systemd/system-shutdown/diagnose.shutdown" + install -Dm755 start-diagnose-shutdown "$pkgdir/usr/bin/start-diagnose-shutdown" + install -Dm755 analyze-shutdown "$pkgdir/usr/bin/analyze-shutdown" + install -Dm644 shutdown-diagnose.service "$pkgdir/usr/lib/systemd/system/shutdown-diagnose.service" +} diff --git a/analyze-shutdown b/analyze-shutdown new file mode 100755 index 000000000000..40e0919d13e5 --- /dev/null +++ b/analyze-shutdown @@ -0,0 +1,115 @@ +#!/bin/bash +declare -A kill_time +declare -A exit_time +declare -a exit_seq +declare -A pid_comm +declare -A wait_time +declare -A killer +declare -A recv_sig + +# ts, pid, signo +set_kill_time() +{ + if [[ "${kill_time[$2]}" ]]; then + return + fi + + case "$3" in + 0 | 1 | 2 | 3 | 6 | 9 | 15) + kill_time[$2]=$1 + ;; + esac +} + +# ts, pid +set_exit_time() +{ + if [[ "${exit_time[$2]}" ]]; then + return + fi + + exit_time[$2]=$1 + exit_seq+=($pid) +} + +# pid, target_pid, signo +add_killer() +{ + killer[$1]+=" $3>$target_pid" +} + +#ts, pid, signo +add_signal() +{ + recv_sig[$2]+=" $3($1)" +} + +declare -i lineno=0 +while read line; do + let lineno++ + if [[ 0 == ${#line} ]] || [[ '#' == ${line:0:1} ]]; then + continue + fi + + cols=($line) + comm=${cols[0]%-*} + pid=${cols[0]#$comm-} + ts=${cols[3]%:} + ts=${ts//./} + func=${cols[4]%(*} + func=${func%:} + + if [[ -z "$shut_time" ]]; then + shut_time=$ts + ts=0 + else + zeros=000000 + ts=$(($ts-$shut_time)) + if (( 6 >= ${#ts} )); then + ts=${zeros:0:7-${#ts}}$ts + fi + ts=${ts:0:${#ts}-6}.${ts:${#ts}-6} + fi + + case "$func" in + sched_process_exit) + set_exit_time $ts $pid + comm="${cols[5]#comm=}" + ;; + sys_kill | sys_tgkill) + if [[ '->' == "${cols[5]}" ]]; then + if [[ '0x0' != "${cols[6]}" ]]; then + target_pid=${killer[$pid]##*>} + if [[ "$target_pid" ]]; then + add_killer $pid $target_pid $signo + set_exit_time $ts $target_pid + fi + fi + else + let target_pid=0x${cols[5]%,} + if [[ 'sys_kill' == "$func" ]]; then + let signo=0x${cols[7]%)} + else + let signo=0x${cols[9]%)} + fi + set_kill_time $ts $target_pid $signo + add_killer $pid $target_pid $signo + fi + ;; + signal_deliver) + let signo=${cols[5]#sig=} + add_signal $ts $pid $signo + ;; + sys_exit) + set_kill_time $ts $pid - + ;; + esac + + if [[ -z "${pid_comm[$pid]}" ]] || [[ '<...>' == "${pid_comm[$pid]}" ]]; then + pid_comm[$pid]=$comm + fi +done + +for pid in "${exit_seq[@]}"; do + printf "%15s(%4s) exited at %10ss, got signals: %s\n" ${pid_comm[$pid]} $pid ${exit_time[$pid]} "${recv_sig[$pid]}" +done diff --git a/diagnose.shutdown b/diagnose.shutdown new file mode 100755 index 000000000000..0ff72cdc9655 --- /dev/null +++ b/diagnose.shutdown @@ -0,0 +1,5 @@ +#!/bin/sh +mount -o remount,rw / +cat /sys/kernel/debug/tracing/trace >/shutdown.log +mount -o remount,ro / + diff --git a/shutdown-diagnose.service b/shutdown-diagnose.service new file mode 100644 index 000000000000..fef096532ea4 --- /dev/null +++ b/shutdown-diagnose.service @@ -0,0 +1,11 @@ +[Unit] +Description= A service to execute start diagnose-shutdown at begining of shutdown + +[Service] +Type=idle +RemainAfterExit=yes +ExecStart=/usr/bin/true +ExecStop=/usr/bin/start-diagnose-shutdown + +[Install] +WantedBy=default.target diff --git a/start-diagnose-shutdown b/start-diagnose-shutdown new file mode 100755 index 000000000000..395b8bf81303 --- /dev/null +++ b/start-diagnose-shutdown @@ -0,0 +1,20 @@ +#!/bin/bash +set -e +PS4="> ${0##*/}: " +set -x + +cd /sys/kernel/debug/tracing +echo 0 >tracing_on +echo >trace + +echo syscalls:sys_enter_exit >set_event +echo syscalls:sys_enter_kill >>set_event +echo syscalls:sys_enter_tkill >>set_event +echo syscalls:sys_enter_tgkill >>set_event +echo signal:signal_deliver >>set_event +echo sched:sched_process_exit >>set_event + +echo global >trace_clock +echo 40960 >buffer_size_kb +echo nop >current_tracer +echo 1 >tracing_on |