All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>
Cc: ray.huang@amd.com, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 2/4] drm/ttm: add a debugfs file for the global page pools
Date: Tue, 19 Jan 2021 15:02:51 +0100	[thread overview]
Message-ID: <YAbmi4h86TnV3yjR@phenom.ffwll.local> (raw)
In-Reply-To: <20210119121821.2320-2-christian.koenig@amd.com>

On Tue, Jan 19, 2021 at 01:18:19PM +0100, Christian König wrote:
> Instead of printing this on the per device pool.
> 
> Signed-off-by: Christian König <christian.koenig@amd.com>

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

btw I think ttm should also set up the per-bdev debugfs stuff, feels silly
having that boilerplate. Same for the per-ttm_manager thing we have I
think.
-Daniel

> ---
>  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 <drm/ttm/ttm_bo_driver.h>
>  #include <drm/ttm/ttm_tt.h>
>  
> +#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;
> -- 
> 2.25.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2021-01-19 14:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-19 12:18 [PATCH 1/4] drm/ttm: add debugfs directory v2 Christian König
2021-01-19 12:18 ` [PATCH 2/4] drm/ttm: add a debugfs file for the global page pools Christian König
2021-01-19 14:02   ` Daniel Vetter [this message]
2021-01-19 12:18 ` [PATCH 3/4] drm/ttm: add debugfs entry to test pool shrinker v2 Christian König
2021-01-19 14:07   ` Daniel Vetter
2021-01-19 12:18 ` [PATCH 4/4] drm/ttm: optimize ttm pool shrinker a bit Christian König
2021-01-19 14:10   ` Daniel Vetter
  -- strict thread matches above, loose matches on Subject: below --
2020-12-18 17:55 [PATCH 1/4] drm/ttm: add debugfs directory v2 Christian König
2020-12-18 17:55 ` [PATCH 2/4] drm/ttm: add a debugfs file for the global page pools Christian König
2020-12-22 13:36   ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YAbmi4h86TnV3yjR@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=ckoenig.leichtzumerken@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ray.huang@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.