From 91b5a3ef5516b29584ea4567b0f5ffa18219b29f Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 3 May 2018 21:53:41 +0100 Subject: lib: Show the kernel stack when reporting a GPU hang In a few tests (like gem_exec_await, gem_exec_schedule) we use the GPU hang to break a deadlock hit during test setup. In these case we would like to see where in kernel the process is stuck (if at all). References: https://bugs.freedesktop.org/show_bug.cgi?id=105900 Signed-off-by: Chris Wilson Acked-by: Antonio Argenziano --- lib/igt_aux.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'lib/igt_aux.c') diff --git a/lib/igt_aux.c b/lib/igt_aux.c index aabf6e50..acafb713 100644 --- a/lib/igt_aux.c +++ b/lib/igt_aux.c @@ -426,6 +426,24 @@ void igt_stop_shrink_helper(void) igt_stop_helper(&shrink_helper); } +static void show_kernel_stack(pid_t pid) +{ + char buf[80], *str; + int dir; + + snprintf(buf, sizeof(buf), "/proc/%d", pid); + dir = open(buf, O_RDONLY); + if (dir < 0) + return; + + str = igt_sysfs_get(dir, "stack"); + if (str) { + igt_debug("Kernel stack for pid %d:\n%s\n", pid, str); + free(str); + } + + close(dir); +} static struct igt_helper_process hang_detector; static void __attribute__((noreturn)) @@ -465,6 +483,7 @@ hang_detector_process(int fd, pid_t pid, dev_t rdev) str = udev_device_get_property_value(dev, "ERROR"); if (str && atoi(str) == 1) { igt_debugfs_dump(fd, "i915_error_state"); + show_kernel_stack(pid); kill(pid, SIGIO); } } -- cgit v1.2.3