Skip to content

Commit 5df1d87

Browse files
committed
trigger kernel blocked stack trace on system server watchdog
Bug b/7638530 may be caused by a kernel deadlock when killing processes under low memory conditions. Write to /proc/sysrq-trigger to get a kernel log of blocked tasks before killing the system server. Bug: 7638530 Change-Id: I60df324ad4affdadbf13650099dc4dfb38722420
1 parent 154e2d7 commit 5df1d87

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

services/java/com/android/server/Watchdog.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
import android.util.Slog;
4040

4141
import java.io.File;
42+
import java.io.FileWriter;
43+
import java.io.IOException;
4244
import java.util.ArrayList;
4345
import java.util.Calendar;
4446

@@ -439,6 +441,16 @@ public void run() {
439441
dumpKernelStackTraces();
440442
}
441443

444+
// Trigger the kernel to dump all blocked threads to the kernel log
445+
try {
446+
FileWriter sysrq_trigger = new FileWriter("/proc/sysrq-trigger");
447+
sysrq_trigger.write("w");
448+
sysrq_trigger.close();
449+
} catch (IOException e) {
450+
Slog.e(TAG, "Failed to write to /proc/sysrq-trigger");
451+
Slog.e(TAG, e.getMessage());
452+
}
453+
442454
// Try to add the error to the dropbox, but assuming that the ActivityManager
443455
// itself may be deadlocked. (which has happened, causing this statement to
444456
// deadlock and the watchdog as a whole to be ineffective)

0 commit comments

Comments
 (0)