From patchwork Fri Dec 18 17:55:36 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: 11982687 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 BBBC1C4361B for ; Fri, 18 Dec 2020 17:55:43 +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 70E9523B5D for ; Fri, 18 Dec 2020 17:55:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 70E9523B5D 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 D616C8935B; Fri, 18 Dec 2020 17:55:42 +0000 (UTC) Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7AAF88935B for ; Fri, 18 Dec 2020 17:55:42 +0000 (UTC) Received: by mail-ed1-x534.google.com with SMTP id u19so3248383edx.2 for ; Fri, 18 Dec 2020 09:55:42 -0800 (PST) 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=1sgM5aPNlx24eTbGufLHiwY95EFfN7VzZFf07UEyVAs=; b=TuKZFh7eLJf29HN4FLwEYZNVZTje2+cqIO0wkTM4oTDJgY91LmE17mbD8wEGIMEHD4 I6yVkxbuOCEK9Q9dAr0/JIJ1YGxSSzJgduOACAtpZ+RY05mZ5G2b0LEAUSoLIWQ1R5cT 7HiQCEqfnLWo6r7bFNJiB8LHUb9gCjciV0smBlDwqkNSHoDA+jefrkfTWuRfetsp49fT ipsbLbBd5MtM07yy+yVBHMlq/zjYtbSKzEwLCX5aYCfnAvhaS7cLCDFYDB0UD+cXYJLR kzreCWImVGpp5PVzQzE9LMyCrENzj5WEQ/HQZz6clyOHN6vP23Sy20GTV7JEPEZNr1AM LMUw== 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=1sgM5aPNlx24eTbGufLHiwY95EFfN7VzZFf07UEyVAs=; b=nck+rTEqRAXfUolwxdEN9dCY4XmaeLE0a2r0oz8i7Z3ftIMgcXjqKaaWfEoTzjr8VS /QZntJ0f5J+ub0u29WrQ51X/RT+/dsN2IX7if43y5T52cvOjjvc5idyBKYEKC7/rRTuB 5FsWAO6m6HDxWO3DmxXMRKBf/UDTl7W9VdK8GwZgeEDononMBwCtOJS3U00Z073iCoHf e54q60TzEsaoGs4l1EU3ftbeVWJcMdA2yA7lAw+kWcdPcnXLuyS3nmeKfdvPdqWsx2G3 JKUtf09/a7WxNYuPq7KPEH7rNHKaPbKjAn6PEwDpdNQoEqcG+YB4oK6O15sYuQ0GAk3Z ObxQ== X-Gm-Message-State: AOAM531rjgWRazouxN184dV0Z/a9z834A9Vm3pcWBeUULVQDrWm86WWt W6IiGHCD3SidPkBnVWeOKA3Iz6L4bHw= X-Google-Smtp-Source: ABdhPJwdhUIL4Ow42cMMlJS+OGlkZqfxooRaZ0u40UliqED9IcZFFM2mmT08CcIWCTjgcaXIb0d2NQ== X-Received: by 2002:a50:d50a:: with SMTP id u10mr5549684edi.58.1608314140958; Fri, 18 Dec 2020 09:55:40 -0800 (PST) Received: from abel.fritz.box ([2a02:908:1252:fb60:4769:42ab:9b50:97cf]) by smtp.gmail.com with ESMTPSA id x6sm26751795edl.67.2020.12.18.09.55.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 09:55:40 -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 2/4] drm/ttm: add a debugfs file for the global page pools Date: Fri, 18 Dec 2020 18:55:36 +0100 Message-Id: <20201218175538.1364-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201218175538.1364-1-christian.koenig@amd.com> References: <20201218175538.1364-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: , Cc: ray.huang@amd.com 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 7b2f60616750..1d61e8fc0e81 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 * @@ -543,6 +545,17 @@ static unsigned int ttm_pool_type_count(struct ttm_pool_type *pt) return count; } +/* 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) @@ -554,6 +567,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 * @@ -566,23 +608,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) { @@ -598,12 +626,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); @@ -660,6 +685,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;