From patchwork Wed Mar 31 22:16:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 412925 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63395C433B4 for ; Wed, 31 Mar 2021 22:14:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2956D6108F for ; Wed, 31 Mar 2021 22:14:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232716AbhCaWNj (ORCPT ); Wed, 31 Mar 2021 18:13:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229787AbhCaWNK (ORCPT ); Wed, 31 Mar 2021 18:13:10 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3CCCC061574; Wed, 31 Mar 2021 15:13:09 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id y2so8629836plg.5; Wed, 31 Mar 2021 15:13:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OhRKnjnp04/KR/sSNoa+tu/vhEXwdj63Uk5C6mZJOQk=; b=R61jEIdU7UJlduyCmpi1FgYLKVeDrBBnWycok2VFemsAh8ONoU6Ct/jfQFcIDuxI1B cL0Ahh1wL0jtMlDTsygl9ed4T3bDYtTbLXcwB9uT7W3dYPCQlCxQgdJ9tpyPcaYtguhG TnevF4xcxxWQVmYJu32jkfE29aQP4m/IyI9g+cqdxuHAvayoZKNOWYjXVjpdzbXixmOd NV30uRz65bYHZ4b/0KZRbeA0GRMKAwk8J10MR25VmWvBPEt7wO0vlQrrNjXBA1wPfX7s kE98yJByo8AWC7cEIO9QliGVpm+GFX2FyNKLmgTPMGg8Ha7W27Q0QLTZZZrSq/1EX4Fn DSLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OhRKnjnp04/KR/sSNoa+tu/vhEXwdj63Uk5C6mZJOQk=; b=hvt4wPim+B9Aaf2ET++N4PjX7YY7LLrW5kvs6NEAD/Jm6IiR2OYkx1/HEsJLFSE47q TMx8lLWsWy7xrIoxLkEq3U2D02S2qM1+wb4TbfJtFq4BAt3Fzvq4bO9W6GfF1iEpkKxw /nVV+fTlZQkGQOeUlbCz0vMpIeopMYoBAa1AhyVn3Jqp/e2r0j+sq7k+s0Jdm+1SCMDa bsm/9u0cPVmWy17WmivM4m04DKX45lF6j1m55sw93LmBRJfayEsrheQA9U1f1kEj0ZS5 nlos1+5SOmi3CsX5cJAjIFgqwq1XHsePQNJiAMlC8onRV1Xk/8424HzZ2n7wCXoXmF+z 8Zow== X-Gm-Message-State: AOAM532JBCI6i18n5yeAYZbnGHp3j2Knd7Z+wpUTHkLlMoUC0QEIwp6D Zs3OZEncgYeedUHF+wJcNBQ= X-Google-Smtp-Source: ABdhPJzx4z92OqXjJmA2aDQUjVGO3fWl15Kt1bf1LZ1Za5EpQuUlXCbs5blxseMptA2QArFmtiPUWQ== X-Received: by 2002:a17:90b:fce:: with SMTP id gd14mr5702746pjb.8.1617228789609; Wed, 31 Mar 2021 15:13:09 -0700 (PDT) Received: from localhost (c-73-25-156-94.hsd1.or.comcast.net. [73.25.156.94]) by smtp.gmail.com with ESMTPSA id gm9sm3035227pjb.13.2021.03.31.15.13.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Mar 2021 15:13:08 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: Rob Clark , Rob Clark , Sean Paul , David Airlie , Daniel Vetter , linux-arm-msm@vger.kernel.org (open list:DRM DRIVER FOR MSM ADRENO GPU), freedreno@lists.freedesktop.org (open list:DRM DRIVER FOR MSM ADRENO GPU), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 1/4] drm/msm: Remove unused freed llist node Date: Wed, 31 Mar 2021 15:16:26 -0700 Message-Id: <20210331221630.488498-2-robdclark@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210331221630.488498-1-robdclark@gmail.com> References: <20210331221630.488498-1-robdclark@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Rob Clark Unused since c951a9b284b907604759628d273901064c60d09f Signed-off-by: Rob Clark --- drivers/gpu/drm/msm/msm_gem.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_gem.h b/drivers/gpu/drm/msm/msm_gem.h index b3a0a880cbab..7a9107cf1818 100644 --- a/drivers/gpu/drm/msm/msm_gem.h +++ b/drivers/gpu/drm/msm/msm_gem.h @@ -78,8 +78,6 @@ struct msm_gem_object { struct list_head vmas; /* list of msm_gem_vma */ - struct llist_node freed; - /* For physically contiguous buffers. Used when we don't have * an IOMMU. Also used for stolen/splashscreen buffer. */ From patchwork Wed Mar 31 22:16:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 412924 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B155BC43470 for ; Wed, 31 Mar 2021 22:14:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 77CFC6108E for ; Wed, 31 Mar 2021 22:14:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232746AbhCaWNk (ORCPT ); Wed, 31 Mar 2021 18:13:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231818AbhCaWNO (ORCPT ); Wed, 31 Mar 2021 18:13:14 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA4C2C061574; Wed, 31 Mar 2021 15:13:14 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id d8so8633385plh.11; Wed, 31 Mar 2021 15:13:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gScWN8UenNyK27brBaNwQHa1Z/Ca80GDMmaeXW0ls/U=; b=EMGnrNo6o01pjvX6L9vpQwX2gqn+Vh+JuULwjpOKQZj9fzNYa5XpK18wNHu9aJ+0Ot K9C+sg1Q+Ru4q6Xz5tNRlgz+WNmtJ1M0zUC+DeJ8dI3816K6EmknuuZPlLiMAcG3ZpEi YnpOl0jI8zjyw4w5UBUOPqaG4ySd+tmpkPzR1uxpgro++c+50UmXWhMMUW4Go+g75pId 3wYKkYe3ww3EysZgDhhzdXLNuig/TP7HoYY0TNEOjMcgttBEep1d8z/7rCA4RaCCBtN5 YoJ+dK+niOsagtWY56FKZBX3FN+UeizKl+EQs1oDuZB+aZD0Go6S7VUX2IMlUG+li139 iNqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gScWN8UenNyK27brBaNwQHa1Z/Ca80GDMmaeXW0ls/U=; b=UsAG1CEVibp5Cg5B8Hl7m/Q4wp4saV/wd2lRSJissJOSlay7Gb9mWXTcOiPNT/uMjk 2uN4OXgAAVBBGCgNREu1rW5BFuAttpvTigp3DmfFc3eBX17GrBonbBtTsZxAtMNUBYvd X4I7xbRiCFR1BkrxXXDQ5sNuFc76Jl7BJDBAGs3L14F+9swtqq6y98ftp97u7bW+n368 OCVWfpqKgGdZrHVjS2J0mOXmcP0B6wj7RRjxIFm47NWLB+P7LFAaE9wlDtUx95xZyDvp Yng+W0jIExnLCpMxa4PueYGWzB1WSukCrVDufR1CNeTyxGoAwGawdUF9oF0yYCmcZZ5Z q4gQ== X-Gm-Message-State: AOAM532QtK8fw8g4NLj9GHQMZ96y9SX2LSeOae97nUb1yd5z8lk4LOIF AiT+BuNIM28z1Z6W1tewrB0= X-Google-Smtp-Source: ABdhPJybF1XAVvGu+A4tCkpz5Wi/SotZeU3+SzH73gXmXupa7G+jjb2S2kVleqBbQBshj3Pq+1pYRg== X-Received: by 2002:a17:90a:f005:: with SMTP id bt5mr5688901pjb.127.1617228794328; Wed, 31 Mar 2021 15:13:14 -0700 (PDT) Received: from localhost (c-73-25-156-94.hsd1.or.comcast.net. [73.25.156.94]) by smtp.gmail.com with ESMTPSA id l14sm2883965pja.37.2021.03.31.15.13.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Mar 2021 15:13:13 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: Rob Clark , Rob Clark , Sean Paul , David Airlie , Daniel Vetter , Jordan Crouse , "Kristian H. Kristensen" , linux-arm-msm@vger.kernel.org (open list:DRM DRIVER FOR MSM ADRENO GPU), freedreno@lists.freedesktop.org (open list:DRM DRIVER FOR MSM ADRENO GPU), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 3/4] drm/msm: Fix debugfs deadlock Date: Wed, 31 Mar 2021 15:16:28 -0700 Message-Id: <20210331221630.488498-4-robdclark@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210331221630.488498-1-robdclark@gmail.com> References: <20210331221630.488498-1-robdclark@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Rob Clark In normal cases the gem obj lock is acquired first before mm_lock. The exception is iterating the various object lists. In the shrinker path, deadlock is avoided by using msm_gem_trylock() and skipping over objects that cannot be locked. But for debugfs the straightforward thing is to split things out into a separate list of all objects protected by it's own lock. Fixes: d984457b31c4 ("drm/msm: Add priv->mm_lock to protect active/inactive lists") Signed-off-by: Rob Clark --- drivers/gpu/drm/msm/msm_debugfs.c | 14 +++----------- drivers/gpu/drm/msm/msm_drv.c | 3 +++ drivers/gpu/drm/msm/msm_drv.h | 8 +++++++- drivers/gpu/drm/msm/msm_gem.c | 14 +++++++++++++- drivers/gpu/drm/msm/msm_gem.h | 13 ++++++++++--- 5 files changed, 36 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_debugfs.c b/drivers/gpu/drm/msm/msm_debugfs.c index 85ad0babc326..d611cc8e54a4 100644 --- a/drivers/gpu/drm/msm/msm_debugfs.c +++ b/drivers/gpu/drm/msm/msm_debugfs.c @@ -111,23 +111,15 @@ static const struct file_operations msm_gpu_fops = { static int msm_gem_show(struct drm_device *dev, struct seq_file *m) { struct msm_drm_private *priv = dev->dev_private; - struct msm_gpu *gpu = priv->gpu; int ret; - ret = mutex_lock_interruptible(&priv->mm_lock); + ret = mutex_lock_interruptible(&priv->obj_lock); if (ret) return ret; - if (gpu) { - seq_printf(m, "Active Objects (%s):\n", gpu->name); - msm_gem_describe_objects(&gpu->active_list, m); - } - - seq_printf(m, "Inactive Objects:\n"); - msm_gem_describe_objects(&priv->inactive_dontneed, m); - msm_gem_describe_objects(&priv->inactive_willneed, m); + msm_gem_describe_objects(&priv->objects, m); - mutex_unlock(&priv->mm_lock); + mutex_unlock(&priv->obj_lock); return 0; } diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 3462b0ea14c6..1ef1cd0cc714 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -474,6 +474,9 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv) priv->wq = alloc_ordered_workqueue("msm", 0); + INIT_LIST_HEAD(&priv->objects); + mutex_init(&priv->obj_lock); + INIT_LIST_HEAD(&priv->inactive_willneed); INIT_LIST_HEAD(&priv->inactive_dontneed); INIT_LIST_HEAD(&priv->inactive_purged); diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index 3ead5755f695..d69f4263bd4e 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h @@ -174,7 +174,13 @@ struct msm_drm_private { struct msm_rd_state *hangrd; /* debugfs to dump hanging submits */ struct msm_perf_state *perf; - /* + /** + * List of all GEM objects (mainly for debugfs, protected by obj_lock + */ + struct list_head objects; + struct mutex obj_lock; + + /** * Lists of inactive GEM objects. Every bo is either in one of the * inactive lists (depending on whether or not it is shrinkable) or * gpu->active_list (for the gpu it is active on[1]) diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c index 74a92eedc992..c184ea68a6d0 100644 --- a/drivers/gpu/drm/msm/msm_gem.c +++ b/drivers/gpu/drm/msm/msm_gem.c @@ -961,7 +961,7 @@ void msm_gem_describe_objects(struct list_head *list, struct seq_file *m) size_t size = 0; seq_puts(m, " flags id ref offset kaddr size madv name\n"); - list_for_each_entry(msm_obj, list, mm_list) { + list_for_each_entry(msm_obj, list, node) { struct drm_gem_object *obj = &msm_obj->base; seq_puts(m, " "); msm_gem_describe(obj, m); @@ -980,6 +980,10 @@ void msm_gem_free_object(struct drm_gem_object *obj) struct drm_device *dev = obj->dev; struct msm_drm_private *priv = dev->dev_private; + mutex_lock(&priv->obj_lock); + list_del(&msm_obj->node); + mutex_unlock(&priv->obj_lock); + mutex_lock(&priv->mm_lock); if (msm_obj->dontneed) mark_unpurgable(msm_obj); @@ -1170,6 +1174,10 @@ static struct drm_gem_object *_msm_gem_new(struct drm_device *dev, list_add_tail(&msm_obj->mm_list, &priv->inactive_willneed); mutex_unlock(&priv->mm_lock); + mutex_lock(&priv->obj_lock); + list_add_tail(&msm_obj->node, &priv->objects); + mutex_unlock(&priv->obj_lock); + return obj; fail: @@ -1240,6 +1248,10 @@ struct drm_gem_object *msm_gem_import(struct drm_device *dev, list_add_tail(&msm_obj->mm_list, &priv->inactive_willneed); mutex_unlock(&priv->mm_lock); + mutex_lock(&priv->obj_lock); + list_add_tail(&msm_obj->node, &priv->objects); + mutex_unlock(&priv->obj_lock); + return obj; fail: diff --git a/drivers/gpu/drm/msm/msm_gem.h b/drivers/gpu/drm/msm/msm_gem.h index 0feabae75d3d..49956196025e 100644 --- a/drivers/gpu/drm/msm/msm_gem.h +++ b/drivers/gpu/drm/msm/msm_gem.h @@ -60,13 +60,20 @@ struct msm_gem_object { */ uint8_t vmap_count; - /* And object is either: - * inactive - on priv->inactive_list + /** + * Node in list of all objects (mainly for debugfs, protected by + * struct_mutex + */ + struct list_head node; + + /** + * An object is either: + * inactive - on priv->inactive_dontneed or priv->inactive_willneed + * (depending on purgability status) * active - on one one of the gpu's active_list.. well, at * least for now we don't have (I don't think) hw sync between * 2d and 3d one devices which have both, meaning we need to * block on submit if a bo is already on other ring - * */ struct list_head mm_list; From patchwork Thu Apr 1 01:27:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 413732 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1256BC433ED for ; Thu, 1 Apr 2021 01:25:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DE97A61076 for ; Thu, 1 Apr 2021 01:25:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233286AbhDABYe (ORCPT ); Wed, 31 Mar 2021 21:24:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233028AbhDABYE (ORCPT ); Wed, 31 Mar 2021 21:24:04 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE3E9C061574; Wed, 31 Mar 2021 18:24:03 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id v23so152031ple.9; Wed, 31 Mar 2021 18:24:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zsCSqM7YP3RCVWsP5WM5Atj6TW8UyCzrw8pSRQkMoNc=; b=LMbTOJkEXOm6POeA3AvN2jWp+gm7OYjAEInVGJH/FBXpQgQexNOAfHPhPH1blrp+Hk QfxUXb88N0cw1YHrVpuNOlBjs2SQs4pfqX7CgsNyL9By5Yir/XkzzxoFPDLRzNQm9vXK G7MVU+v9lw15hwZfxLV87elkv2gpj0x9gDfnWfvf5F4/uRJw/U1dkjX19wm+/AXQlTnL wrj4qnT3SN83ShjI9YUEFf6qsgcElJh10iAodoEJZTbuRRBjrDvJUl/ihho7RDVa0uTx /R/efHGHsCCddrUS4tDSCMqDECdYvdrut1Z8vxKVtEV0ICXwwnnoijt7jWhtb2Fs/kW7 z60Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zsCSqM7YP3RCVWsP5WM5Atj6TW8UyCzrw8pSRQkMoNc=; b=ssx6aZSF1oji9opCRQin/IPHeZxzU5/HMo5Q+rgxUsd8WFg+BiE9pxQGcvRqAUkyjW 3USiO3nknaMYVzm2Q/Mg3h9fJ+fYIchossL2T19t3eOnbW5MmRXTrQjD4yIAsxoJrDal wDDJsrV6dl3kKwBDzW1YSN1RAW2jlAbes3uVbMVf36aHfCEWh5zDNBuU/GP3ZNIi5dQv NSu8SHWr1sFXVR130uToKjbVMp1io1SppHnkEYjx+HX+l0AjYUFggH5dDtB+/F2pJZ6O 0hH6tcDTvsG+T6/up7/CwAMiaQ7fUzWUDeYaqnmSLjnt3iVOc9GBEinSmFDBCFz8g0kG Y4FA== X-Gm-Message-State: AOAM531i7a5Is2Wc11AW3G6zpnSsL4cD0d9uZGhtKT13gjMQqkXRUXSe 6xYPx+4/We341OGgX7FJi7U= X-Google-Smtp-Source: ABdhPJy+Ipg5FOivJlIvHzZ6cboe/AYEvu38Avnp5oGumsFN75ULhelm0LN9Knlc4dEZiTXcaaUkhg== X-Received: by 2002:a17:90a:b293:: with SMTP id c19mr6227917pjr.193.1617240243491; Wed, 31 Mar 2021 18:24:03 -0700 (PDT) Received: from localhost ([2601:1c0:5200:a6:307:a401:7b76:c6e5]) by smtp.gmail.com with ESMTPSA id y12sm3520619pfq.118.2021.03.31.18.24.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Mar 2021 18:24:02 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: Rob Clark , Douglas Anderson , Rob Clark , Sean Paul , David Airlie , Daniel Vetter , linux-arm-msm@vger.kernel.org (open list:DRM DRIVER FOR MSM ADRENO GPU), freedreno@lists.freedesktop.org (open list:DRM DRIVER FOR MSM ADRENO GPU), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 4/4] drm/msm: Improved debugfs gem stats Date: Wed, 31 Mar 2021 18:27:21 -0700 Message-Id: <20210401012722.527712-5-robdclark@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210401012722.527712-1-robdclark@gmail.com> References: <20210331221630.488498-1-robdclark@gmail.com> <20210401012722.527712-1-robdclark@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Rob Clark The last patch lost the breakdown of active vs inactive GEM objects in $debugfs/gem. But we can add some better stats to summarize not just active vs inactive, but also purgable/purged to make up for that. Signed-off-by: Rob Clark Tested-by: Douglas Anderson Reviewed-by: Douglas Anderson --- drivers/gpu/drm/msm/msm_fb.c | 3 ++- drivers/gpu/drm/msm/msm_gem.c | 31 ++++++++++++++++++++++++------- drivers/gpu/drm/msm/msm_gem.h | 11 ++++++++++- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_fb.c b/drivers/gpu/drm/msm/msm_fb.c index d42f0665359a..91c0e493aed5 100644 --- a/drivers/gpu/drm/msm/msm_fb.c +++ b/drivers/gpu/drm/msm/msm_fb.c @@ -33,6 +33,7 @@ static const struct drm_framebuffer_funcs msm_framebuffer_funcs = { #ifdef CONFIG_DEBUG_FS void msm_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m) { + struct msm_gem_stats stats = {}; int i, n = fb->format->num_planes; seq_printf(m, "fb: %dx%d@%4.4s (%2d, ID:%d)\n", @@ -42,7 +43,7 @@ void msm_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m) for (i = 0; i < n; i++) { seq_printf(m, " %d: offset=%d pitch=%d, obj: ", i, fb->offsets[i], fb->pitches[i]); - msm_gem_describe(fb->obj[i], m); + msm_gem_describe(fb->obj[i], m, &stats); } } #endif diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c index 7ca30e362222..2ecf7f1cef25 100644 --- a/drivers/gpu/drm/msm/msm_gem.c +++ b/drivers/gpu/drm/msm/msm_gem.c @@ -873,7 +873,8 @@ static void describe_fence(struct dma_fence *fence, const char *type, fence->seqno); } -void msm_gem_describe(struct drm_gem_object *obj, struct seq_file *m) +void msm_gem_describe(struct drm_gem_object *obj, struct seq_file *m, + struct msm_gem_stats *stats) { struct msm_gem_object *msm_obj = to_msm_bo(obj); struct dma_resv *robj = obj->resv; @@ -885,11 +886,23 @@ void msm_gem_describe(struct drm_gem_object *obj, struct seq_file *m) msm_gem_lock(obj); + stats->all.count++; + stats->all.size += obj->size; + + if (is_active(msm_obj)) { + stats->active.count++; + stats->active.size += obj->size; + } + switch (msm_obj->madv) { case __MSM_MADV_PURGED: + stats->purged.count++; + stats->purged.size += obj->size; madv = " purged"; break; case MSM_MADV_DONTNEED: + stats->purgable.count++; + stats->purgable.size += obj->size; madv = " purgeable"; break; case MSM_MADV_WILLNEED: @@ -956,20 +969,24 @@ void msm_gem_describe(struct drm_gem_object *obj, struct seq_file *m) void msm_gem_describe_objects(struct list_head *list, struct seq_file *m) { + struct msm_gem_stats stats = {}; struct msm_gem_object *msm_obj; - int count = 0; - size_t size = 0; seq_puts(m, " flags id ref offset kaddr size madv name\n"); list_for_each_entry(msm_obj, list, node) { struct drm_gem_object *obj = &msm_obj->base; seq_puts(m, " "); - msm_gem_describe(obj, m); - count++; - size += obj->size; + msm_gem_describe(obj, m, &stats); } - seq_printf(m, "Total %d objects, %zu bytes\n", count, size); + seq_printf(m, "Total: %4d objects, %9zu bytes\n", + stats.all.count, stats.all.size); + seq_printf(m, "Active: %4d objects, %9zu bytes\n", + stats.active.count, stats.active.size); + seq_printf(m, "Purgable: %4d objects, %9zu bytes\n", + stats.purgable.count, stats.purgable.size); + seq_printf(m, "Purged: %4d objects, %9zu bytes\n", + stats.purged.count, stats.purged.size); } #endif diff --git a/drivers/gpu/drm/msm/msm_gem.h b/drivers/gpu/drm/msm/msm_gem.h index e6b28edb1db9..7c7d54bad189 100644 --- a/drivers/gpu/drm/msm/msm_gem.h +++ b/drivers/gpu/drm/msm/msm_gem.h @@ -158,7 +158,16 @@ struct drm_gem_object *msm_gem_import(struct drm_device *dev, __printf(2, 3) void msm_gem_object_set_name(struct drm_gem_object *bo, const char *fmt, ...); #ifdef CONFIG_DEBUG_FS -void msm_gem_describe(struct drm_gem_object *obj, struct seq_file *m); + +struct msm_gem_stats { + struct { + unsigned count; + size_t size; + } all, active, purgable, purged; +}; + +void msm_gem_describe(struct drm_gem_object *obj, struct seq_file *m, + struct msm_gem_stats *stats); void msm_gem_describe_objects(struct list_head *list, struct seq_file *m); #endif