From patchwork Tue Nov 17 16:33:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 11912851 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,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=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 AA528C2D0E4 for ; Tue, 17 Nov 2020 16:33:53 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 493A3216C4 for ; Tue, 17 Nov 2020 16:33:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bUN349d3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 493A3216C4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 89FC86E045; Tue, 17 Nov 2020 16:33:50 +0000 (UTC) Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by gabe.freedesktop.org (Postfix) with ESMTPS id A38F16E03F for ; Tue, 17 Nov 2020 16:33:44 +0000 (UTC) Received: by mail-lf1-x144.google.com with SMTP id z21so30953848lfe.12 for ; Tue, 17 Nov 2020 08:33:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=yHenESt0YCXt7Dke2MvZKSdiLhMjPYH5mUI6oiXVzEs=; b=bUN349d3QGzxFTSVnRDxbj4W8yhvD5cxoR8bQmdamvmTKc3ROxHva2XPyGfxcUcF35 hZ/umZO+iSVVu1lbuOrKFvl2/czmy/woGshVOgwJZmLmNjcLiefnQGigXpVT2ZTQ+lXf 7gtsWQTQTA0H1zYOhZE85BYhVaIKx9FsHtThuLJvLGn846OCPv/4obIW1YIjq58wko0X 0aB3Da3hRVeOiNgjfys5zKDzRfnQE+KJKVRQVQ2gv2/oMTgSO3KE41UDdyNmoTrGK1i8 LdAZRYXqSYzc+pA5nTPXUNyHII6XAocp0f+Tb+QV7XR98jUd7YihITHBZWPsgHWVai35 ubXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yHenESt0YCXt7Dke2MvZKSdiLhMjPYH5mUI6oiXVzEs=; b=a2U4uyL8DKKuYOHOesTgS+jE3Kn5/DM86dZ2pAPQJLduNy5zR4kweyHtfZBcRZm3Hu 8sL3ogfsQtUZO78DtG4/5TDdy1Rbp/O7Dse/szMLnHd7XgArHFDJrIojTmXEVfQ6P1w4 Q4PmAgMtnNLHRwjiDDYCSTC4BtQN1tMgBh1ITs9RO6K5kOeRNiwS2aLNc3z8TSM+BCpc RT1aMyOW+iU1fgqxG0i2GuSdOeD1tcZZaoGvG7eQ9Ku+SJNdhLqHSXpEh0Loxk0o2Cf1 pp84KnaosWuK/5jKXv+R7zFmiJ6MF1Yn3WmJcj5znBN0J0EbfzmKbXXYiiDr6B1lIRWp bmAw== X-Gm-Message-State: AOAM5300biHjALTmqzjswwhYxyprtkZr/hg4oJvdZkYxnU2i2dTn4iiK PzW5fu5cdI4CQQSLnMPiVepHvkVOhDw= X-Google-Smtp-Source: ABdhPJy0cSzD2RVcvXDxxYOokr1If7g+QKAaPpoRnrocuABRrnkDnSO6BKEaucT2VyliCjwY3ztTEA== X-Received: by 2002:a17:906:b01:: with SMTP id u1mr20742472ejg.427.1605630821710; Tue, 17 Nov 2020 08:33:41 -0800 (PST) Received: from abel.fritz.box ([2a02:908:1252:fb60:dd48:f15c:7bed:4c52]) by smtp.gmail.com with ESMTPSA id dn16sm12225351edb.19.2020.11.17.08.33.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Nov 2020 08:33:41 -0800 (PST) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/4] drm/ttm: add a debugfs file for the global page pools Date: Tue, 17 Nov 2020 17:33:37 +0100 Message-Id: <20201117163338.1784-3-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201117163338.1784-1-christian.koenig@amd.com> References: <20201117163338.1784-1-christian.koenig@amd.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Instead of printing this on the per device pool. Signed-off-by: Christian König --- drivers/gpu/drm/ttm/ttm_pool.c | 70 ++++++++++++++++++++++++---------- 1 file changed, 50 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_pool.c index 24ae7c23cfd0..5daf812551ee 100644 --- a/drivers/gpu/drm/ttm/ttm_pool.c +++ b/drivers/gpu/drm/ttm/ttm_pool.c @@ -42,6 +42,8 @@ #include #include +#include "ttm_module.h" + /** * struct ttm_pool_dma - Helper object for coherent DMA mappings * @@ -533,6 +535,17 @@ EXPORT_SYMBOL(ttm_pool_fini); #ifdef CONFIG_DEBUG_FS +/* Print a nice header for the order */ +static void ttm_pool_debugfs_header(struct seq_file *m) +{ + unsigned int i; + + seq_puts(m, "\t "); + for (i = 0; i < MAX_ORDER; ++i) + seq_printf(m, " ---%2u---", i); + seq_puts(m, "\n"); +} + /* Dump information about the different pool types */ static void ttm_pool_debugfs_orders(struct ttm_pool_type *pt, struct seq_file *m) @@ -544,6 +557,35 @@ static void ttm_pool_debugfs_orders(struct ttm_pool_type *pt, seq_puts(m, "\n"); } +/* Dump the total amount of allocated pages */ +static void ttm_pool_debugfs_footer(struct seq_file *m) +{ + seq_printf(m, "\ntotal\t: %8lu of %8lu\n", + atomic_long_read(&allocated_pages), page_pool_size); +} + +/* Dump the information for the global pools */ +static int ttm_pool_debugfs_globals_show(struct seq_file *m, void *data) +{ + ttm_pool_debugfs_header(m); + + spin_lock(&shrinker_lock); + seq_puts(m, "wc\t:"); + ttm_pool_debugfs_orders(global_write_combined, m); + seq_puts(m, "uc\t:"); + ttm_pool_debugfs_orders(global_uncached, m); + seq_puts(m, "wc 32\t:"); + ttm_pool_debugfs_orders(global_dma32_write_combined, m); + seq_puts(m, "uc 32\t:"); + ttm_pool_debugfs_orders(global_dma32_uncached, m); + spin_unlock(&shrinker_lock); + + ttm_pool_debugfs_footer(m); + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(ttm_pool_debugfs_globals); + /** * ttm_pool_debugfs - Debugfs dump function for a pool * @@ -556,23 +598,9 @@ int ttm_pool_debugfs(struct ttm_pool *pool, struct seq_file *m) { unsigned int i; - spin_lock(&shrinker_lock); - - seq_puts(m, "\t "); - for (i = 0; i < MAX_ORDER; ++i) - seq_printf(m, " ---%2u---", i); - seq_puts(m, "\n"); - - seq_puts(m, "wc\t:"); - ttm_pool_debugfs_orders(global_write_combined, m); - seq_puts(m, "uc\t:"); - ttm_pool_debugfs_orders(global_uncached, m); - - seq_puts(m, "wc 32\t:"); - ttm_pool_debugfs_orders(global_dma32_write_combined, m); - seq_puts(m, "uc 32\t:"); - ttm_pool_debugfs_orders(global_dma32_uncached, m); + ttm_pool_debugfs_header(m); + spin_lock(&shrinker_lock); for (i = 0; i < TTM_NUM_CACHING_TYPES; ++i) { seq_puts(m, "DMA "); switch (i) { @@ -588,12 +616,9 @@ int ttm_pool_debugfs(struct ttm_pool *pool, struct seq_file *m) } ttm_pool_debugfs_orders(pool->caching[i].orders, m); } - - seq_printf(m, "\ntotal\t: %8lu of %8lu\n", - atomic_long_read(&allocated_pages), page_pool_size); - spin_unlock(&shrinker_lock); + ttm_pool_debugfs_footer(m); return 0; } EXPORT_SYMBOL(ttm_pool_debugfs); @@ -650,6 +675,11 @@ int ttm_pool_mgr_init(unsigned long num_pages) ttm_uncached, i); } +#ifdef CONFIG_DEBUG_FS + debugfs_create_file("page_pool", 0444, ttm_debugfs_root, NULL, + &ttm_pool_debugfs_globals_fops); +#endif + mm_shrinker.count_objects = ttm_pool_shrinker_count; mm_shrinker.scan_objects = ttm_pool_shrinker_scan; mm_shrinker.seeks = 1;