From patchwork Thu Aug 29 01:31:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 2851077 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8CE799F2F4 for ; Thu, 29 Aug 2013 01:31:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A18122035C for ; Thu, 29 Aug 2013 01:31:25 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7252120345 for ; Thu, 29 Aug 2013 01:31:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6CE1EE60D0 for ; Wed, 28 Aug 2013 18:31:24 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail.bwidawsk.net (bwidawsk.net [166.78.191.112]) by gabe.freedesktop.org (Postfix) with ESMTP id 3650CE5C20 for ; Wed, 28 Aug 2013 18:31:08 -0700 (PDT) Received: by mail.bwidawsk.net (Postfix, from userid 5001) id 6EEDF59AB3; Wed, 28 Aug 2013 18:31:07 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from lundgren.intel.com (c-24-21-100-90.hsd1.or.comcast.net [24.21.100.90]) by mail.bwidawsk.net (Postfix) with ESMTPSA id 15E7A581EA; Wed, 28 Aug 2013 18:31:05 -0700 (PDT) From: Ben Widawsky To: "\"Intel GFX" Date: Wed, 28 Aug 2013 18:31:00 -0700 Message-Id: <1377739860-32047-1-git-send-email-benjamin.widawsky@intel.com> X-Mailer: git-send-email 1.8.4 Cc: Ben Widawsky , Ben Widawsky Subject: [Intel-gfx] [PATCH] drm/i915: Track the proc which created the context X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org X-Virus-Scanned: ClamAV using ClamSMTP We've tried more than once in the past to print the guilty process. Prior to Mika's recent work however, we never had a good way to actually assign guilt. With that, this trivial patch should get print the guilty process and pid in dmesg. Until we merge the full PPGTT support (which have per fd contexts), we don't have a good way to name the default context used by X, and other clients not opting in to contexts. As such, they will get "swapper" as their guilty process. Once the full PPGTT support is merged, we should be able to properly track the names. NOTE: The string is limited to 16 characters as defined by the ASCII string kept in the task struct. One could theoretically pull out the full from the command args as done for cmdline in proc, but this is terribly ugly, and a homework assignment for another day. Example courtesy of Eric: [drm:i915_set_reset_status] *ERROR* render ring hung inside bo (0x1b5a000 ctx 1 [ext_framebuffer pid=5762]) at 0x1b5a034 Cc: Mika Kuoppala Tested-by: Eric Anholt Signed-off-by: Ben Widawsky --- drivers/gpu/drm/i915/i915_drv.h | 4 ++++ drivers/gpu/drm/i915/i915_gem.c | 4 +++- drivers/gpu/drm/i915/i915_gem_context.c | 7 +++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 05de1ca..742e248 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -594,6 +594,10 @@ struct i915_hw_context { struct intel_ring_buffer *ring; struct drm_i915_gem_object *obj; struct i915_ctx_hang_stats hang_stats; + + /* Process which created this context */ + char comm[TASK_COMM_LEN]; + pid_t pid; }; struct i915_fbc { diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index c65650c..4845c7a 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -2205,11 +2205,13 @@ static void i915_set_reset_status(struct intel_ring_buffer *ring, if (ring->hangcheck.action != HANGCHECK_WAIT && i915_request_guilty(request, acthd, &inside)) { - DRM_ERROR("%s hung %s bo (0x%lx ctx %d) at 0x%x\n", + DRM_ERROR("%s hung %s bo (0x%lx ctx %d [%s pid=%d]) at 0x%x\n", ring->name, inside ? "inside" : "flushing", offset, request->ctx ? request->ctx->id : 0, + request->ctx ? request->ctx->comm : "???", + request->ctx ? request->ctx->pid : -1, acthd); guilty = true; diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c index 403309c..eeee324 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c @@ -85,6 +85,7 @@ * */ +#include #include #include #include "i915_drv.h" @@ -226,6 +227,9 @@ static int create_default_context(struct drm_i915_private *dev_priv) goto err_unpin; } + memcpy(ctx->comm, INIT_TASK_COMM, TASK_COMM_LEN); + ctx->pid = 0; + DRM_DEBUG_DRIVER("Default HW context loaded\n"); return 0; @@ -539,6 +543,9 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data, if (IS_ERR(ctx)) return PTR_ERR(ctx); + memcpy(ctx->comm, current->comm, TASK_COMM_LEN); + ctx->pid = task_pid_nr(current); + args->ctx_id = ctx->id; DRM_DEBUG_DRIVER("HW context %d created\n", args->ctx_id);