From patchwork Mon May 23 11:34:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9131599 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1018660761 for ; Mon, 23 May 2016 11:34:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0DDF32822B for ; Mon, 23 May 2016 11:34:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02C6928231; Mon, 23 May 2016 11:34:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B77BF2822B for ; Mon, 23 May 2016 11:34:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B80926E5B8; Mon, 23 May 2016 11:34:42 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id C29046E066 for ; Mon, 23 May 2016 11:34:34 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id n129so14057794wmn.1 for ; Mon, 23 May 2016 04:34:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=WQHjTXcY+eyl5EY4V3qf++PdfqdCtW/UWA7c1i32+TU=; b=g6WBmNiZnvjOSTGw82NmSUq1QI8J2BheFzK2PkucrsBkeydCXpq7HnJ3gwqwdUAQWi YVlm0HxD8JMekWhIvEaRTg4JqOdgbvidzixulCuwBrYft650ORB4LTujGfqIUC5FUyLi oalcFKxa+a/hoEKCKbq5P2X4+zRlyn/vi0aFaOXnrTKCcNN5DikaUacP4PiO0mW0NnEh 7lVv2Ldq3lRvE6/W/qLYKtrwHgnwiqXLgQC6NU2fc69XJIcU8StOXgdC55r4FvBVUUay PtaLvZqtKbauUwCjeoI8gKlTUoNO6ijucEGbpapUhOfGh6jofMjpySvHDcYy/vcod9aD 0HUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=WQHjTXcY+eyl5EY4V3qf++PdfqdCtW/UWA7c1i32+TU=; b=Zs2JR6jO6DaINJ1tVfkMtst7c7zOZ/ab8ps/t1PxRDJeG+BeGZyjeJZHt3uHI75b1i aOe+IVOVUbUHffdlFao5tJSqKaIz8idCeIAHQ/psRYm/Q/ylJgZwP8qEVr1b11vHFPmf DB19I5hlMMVWoXHi3TBAbF7z/hkKeYqhZDbJgdOQk/Afb90TCzWjL2sky9qceCpdhXai rVxiUA4DueG7/ygZ2/Y7buo0/cuP6BoCuK0MXfKKs1NpPffSc/GJwAn4L5ncdTu5uUnY 646XoZdEoAHZrjhaR2UcXdLjx3CSdeJDjEMVEiQeQg651XyL70bL9cXNyonp2wBMdB5l v7uw== X-Gm-Message-State: AOPr4FVScB6eydH1sUoK95U/V59coho75dZbpKKjEX6aCEtKBTJctoCIHnMTSi3Y5LoZUg== X-Received: by 10.194.82.41 with SMTP id f9mr18446582wjy.169.1464003273117; Mon, 23 May 2016 04:34:33 -0700 (PDT) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id w3sm34924072wjt.0.2016.05.23.04.34.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 May 2016 04:34:32 -0700 (PDT) From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Mon, 23 May 2016 12:34:14 +0100 Message-Id: <1464003258-23669-8-git-send-email-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1464003258-23669-1-git-send-email-chris@chris-wilson.co.uk> References: <1464003258-23669-1-git-send-email-chris@chris-wilson.co.uk> Subject: [Intel-gfx] [PATCH v2 07/11] drm/i915: Show i915_gem_context owner in debugfs X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Print the context's owner (via the pid under file_priv) under debugfs. In doing so, we must be careful that the filp is not accessed after it is freed (notified via i915_gem_context_close). v2: Mark the file_priv as closed. Signed-off-by: Chris Wilson Cc: Tvrtko Ursulin Cc: Joonas Lahtinen Reviewed-by: Tvrtko Ursulin --- drivers/gpu/drm/i915/i915_debugfs.c | 17 +++++++++++++++-- drivers/gpu/drm/i915/i915_gem_context.c | 3 ++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index ae28e6e9d603..945fe4710b37 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c @@ -2014,9 +2014,22 @@ static int i915_context_status(struct seq_file *m, void *unused) continue; seq_printf(m, "HW context %u ", ctx->hw_id); + if (IS_ERR(ctx->file_priv)) { + seq_puts(m, "(deleted) "); + } else if (ctx->file_priv) { + struct pid *pid = ctx->file_priv->file->pid; + struct task_struct *task; + + task = get_pid_task(pid, PIDTYPE_PID); + if (task) { + seq_printf(m, "(%s [%d]) ", + task->comm, task->pid); + put_task_struct(task); + } + } else + seq_puts(m, "(kernel) "); + describe_ctx(m, ctx); - if (ctx == dev_priv->kernel_context) - seq_printf(m, "(kernel context) "); if (i915.enable_execlists) { seq_putc(m, '\n'); diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c index 474174c20be2..e552c936d262 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c @@ -468,6 +468,7 @@ static int context_idr_cleanup(int id, void *p, void *data) { struct i915_gem_context *ctx = p; + ctx->file_priv = ERR_PTR(-EBADF); i915_gem_context_put(ctx); return 0; } @@ -936,7 +937,7 @@ int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data, return PTR_ERR(ctx); } - idr_remove(&ctx->file_priv->context_idr, ctx->user_handle); + idr_remove(&file_priv->context_idr, ctx->user_handle); i915_gem_context_put(ctx); mutex_unlock(&dev->struct_mutex);