From: Daniel Vetter <daniel@ffwll.ch>
To: Jason Ekstrand <jason@jlekstrand.net>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH 5/6] drm/ttm: Initialize debugfs from ttm_global_init()
Date: Tue, 20 Jul 2021 16:22:18 +0200 [thread overview]
Message-ID: <YPbcGrJP3JPIEPDh@phenom.ffwll.local> (raw)
In-Reply-To: <20210719183047.2624569-6-jason@jlekstrand.net>
On Mon, Jul 19, 2021 at 01:30:46PM -0500, Jason Ekstrand wrote:
> We create a bunch of debugfs entries as a side-effect of
> ttm_global_init() and then never clean them up. This isn't usually a
> problem because we free the whole debugfs directory on module unload.
> However, if the global reference count ever goes to zero and then
> ttm_global_init() is called again, we'll re-create those debugfs entries
> and debugfs will complain in dmesg that we're creating entries that
> already exist. This patch fixes this problem by changing the lifetime
> of the whole TTM debugfs directory to match that of the TTM global
> state.
>
> Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
> ---
> drivers/gpu/drm/ttm/ttm_device.c | 12 ++++++++++++
> drivers/gpu/drm/ttm/ttm_module.c | 4 ----
> 2 files changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_device.c b/drivers/gpu/drm/ttm/ttm_device.c
> index 519deea8e39b7..74e3b460132b3 100644
> --- a/drivers/gpu/drm/ttm/ttm_device.c
> +++ b/drivers/gpu/drm/ttm/ttm_device.c
> @@ -44,6 +44,8 @@ static unsigned ttm_glob_use_count;
> struct ttm_global ttm_glob;
> EXPORT_SYMBOL(ttm_glob);
>
> +struct dentry *ttm_debugfs_root;
> +
> static void ttm_global_release(void)
> {
> struct ttm_global *glob = &ttm_glob;
> @@ -53,6 +55,7 @@ static void ttm_global_release(void)
> goto out;
>
> ttm_pool_mgr_fini();
> + debugfs_remove(ttm_debugfs_root);
>
> __free_page(glob->dummy_read_page);
> memset(glob, 0, sizeof(*glob));
> @@ -73,6 +76,13 @@ static int ttm_global_init(void)
>
> si_meminfo(&si);
>
> + ttm_debugfs_root = debugfs_create_dir("ttm", NULL);
> + if (IS_ERR(ttm_debugfs_root)) {
> + ret = PTR_ERR(ttm_debugfs_root);
> + ttm_debugfs_root = NULL;
> + goto out;
> + }
> +
> /* Limit the number of pages in the pool to about 50% of the total
> * system memory.
> */
> @@ -100,6 +110,8 @@ static int ttm_global_init(void)
> debugfs_create_atomic_t("buffer_objects", 0444, ttm_debugfs_root,
> &glob->bo_count);
> out:
> + if (ret && ttm_debugfs_root)
> + debugfs_remove(ttm_debugfs_root);
> if (ret)
> --ttm_glob_use_count;
> mutex_unlock(&ttm_global_mutex);
> diff --git a/drivers/gpu/drm/ttm/ttm_module.c b/drivers/gpu/drm/ttm/ttm_module.c
> index 997c458f68a9a..88554f2db11fe 100644
> --- a/drivers/gpu/drm/ttm/ttm_module.c
> +++ b/drivers/gpu/drm/ttm/ttm_module.c
> @@ -72,17 +72,13 @@ pgprot_t ttm_prot_from_caching(enum ttm_caching caching, pgprot_t tmp)
> return tmp;
> }
>
> -struct dentry *ttm_debugfs_root;
> -
> static int __init ttm_init(void)
> {
> - ttm_debugfs_root = debugfs_create_dir("ttm", NULL);
> return 0;
> }
>
> static void __exit ttm_exit(void)
> {
> - debugfs_remove(ttm_debugfs_root);
> }
I think you can delete these functions and the lines below too, they
should be optional. With that:
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-Daniel
>
> module_init(ttm_init);
> --
> 2.31.1
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
WARNING: multiple messages have this Message-ID (diff)
From: Daniel Vetter <daniel@ffwll.ch>
To: Jason Ekstrand <jason@jlekstrand.net>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 5/6] drm/ttm: Initialize debugfs from ttm_global_init()
Date: Tue, 20 Jul 2021 16:22:18 +0200 [thread overview]
Message-ID: <YPbcGrJP3JPIEPDh@phenom.ffwll.local> (raw)
In-Reply-To: <20210719183047.2624569-6-jason@jlekstrand.net>
On Mon, Jul 19, 2021 at 01:30:46PM -0500, Jason Ekstrand wrote:
> We create a bunch of debugfs entries as a side-effect of
> ttm_global_init() and then never clean them up. This isn't usually a
> problem because we free the whole debugfs directory on module unload.
> However, if the global reference count ever goes to zero and then
> ttm_global_init() is called again, we'll re-create those debugfs entries
> and debugfs will complain in dmesg that we're creating entries that
> already exist. This patch fixes this problem by changing the lifetime
> of the whole TTM debugfs directory to match that of the TTM global
> state.
>
> Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
> ---
> drivers/gpu/drm/ttm/ttm_device.c | 12 ++++++++++++
> drivers/gpu/drm/ttm/ttm_module.c | 4 ----
> 2 files changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_device.c b/drivers/gpu/drm/ttm/ttm_device.c
> index 519deea8e39b7..74e3b460132b3 100644
> --- a/drivers/gpu/drm/ttm/ttm_device.c
> +++ b/drivers/gpu/drm/ttm/ttm_device.c
> @@ -44,6 +44,8 @@ static unsigned ttm_glob_use_count;
> struct ttm_global ttm_glob;
> EXPORT_SYMBOL(ttm_glob);
>
> +struct dentry *ttm_debugfs_root;
> +
> static void ttm_global_release(void)
> {
> struct ttm_global *glob = &ttm_glob;
> @@ -53,6 +55,7 @@ static void ttm_global_release(void)
> goto out;
>
> ttm_pool_mgr_fini();
> + debugfs_remove(ttm_debugfs_root);
>
> __free_page(glob->dummy_read_page);
> memset(glob, 0, sizeof(*glob));
> @@ -73,6 +76,13 @@ static int ttm_global_init(void)
>
> si_meminfo(&si);
>
> + ttm_debugfs_root = debugfs_create_dir("ttm", NULL);
> + if (IS_ERR(ttm_debugfs_root)) {
> + ret = PTR_ERR(ttm_debugfs_root);
> + ttm_debugfs_root = NULL;
> + goto out;
> + }
> +
> /* Limit the number of pages in the pool to about 50% of the total
> * system memory.
> */
> @@ -100,6 +110,8 @@ static int ttm_global_init(void)
> debugfs_create_atomic_t("buffer_objects", 0444, ttm_debugfs_root,
> &glob->bo_count);
> out:
> + if (ret && ttm_debugfs_root)
> + debugfs_remove(ttm_debugfs_root);
> if (ret)
> --ttm_glob_use_count;
> mutex_unlock(&ttm_global_mutex);
> diff --git a/drivers/gpu/drm/ttm/ttm_module.c b/drivers/gpu/drm/ttm/ttm_module.c
> index 997c458f68a9a..88554f2db11fe 100644
> --- a/drivers/gpu/drm/ttm/ttm_module.c
> +++ b/drivers/gpu/drm/ttm/ttm_module.c
> @@ -72,17 +72,13 @@ pgprot_t ttm_prot_from_caching(enum ttm_caching caching, pgprot_t tmp)
> return tmp;
> }
>
> -struct dentry *ttm_debugfs_root;
> -
> static int __init ttm_init(void)
> {
> - ttm_debugfs_root = debugfs_create_dir("ttm", NULL);
> return 0;
> }
>
> static void __exit ttm_exit(void)
> {
> - debugfs_remove(ttm_debugfs_root);
> }
I think you can delete these functions and the lines below too, they
should be optional. With that:
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-Daniel
>
> module_init(ttm_init);
> --
> 2.31.1
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
next prev parent reply other threads:[~2021-07-20 14:22 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-19 18:30 [Intel-gfx] [PATCH 0/6] Fix the debugfs splat from mock selftests Jason Ekstrand
2021-07-19 18:30 ` Jason Ekstrand
2021-07-19 18:30 ` [Intel-gfx] [PATCH 1/6] drm/i915: Call i915_globals_exit() after i915_pmu_exit() Jason Ekstrand
2021-07-19 18:30 ` Jason Ekstrand
2021-07-19 18:30 ` [Intel-gfx] [PATCH 2/6] drm/i915: Call i915_globals_exit() if pci_register_device() fails Jason Ekstrand
2021-07-19 18:30 ` Jason Ekstrand
2021-07-20 14:11 ` [Intel-gfx] " Daniel Vetter
2021-07-20 14:11 ` Daniel Vetter
2021-07-19 18:30 ` [Intel-gfx] [PATCH 3/6] drm/i915: Always call i915_globals_exit() from i915_exit() Jason Ekstrand
2021-07-19 18:30 ` Jason Ekstrand
2021-07-20 8:25 ` [Intel-gfx] " Tvrtko Ursulin
2021-07-20 8:25 ` Tvrtko Ursulin
2021-07-20 14:53 ` Jason Ekstrand
2021-07-20 14:53 ` Jason Ekstrand
2021-07-20 15:22 ` Tvrtko Ursulin
2021-07-20 15:22 ` Tvrtko Ursulin
2021-07-20 15:30 ` Tvrtko Ursulin
2021-07-20 15:30 ` Tvrtko Ursulin
2021-07-20 15:05 ` Jason Ekstrand
2021-07-20 15:05 ` Jason Ekstrand
2021-07-20 15:25 ` Tvrtko Ursulin
2021-07-20 15:25 ` Tvrtko Ursulin
2021-07-20 14:18 ` Daniel Vetter
2021-07-20 14:18 ` Daniel Vetter
2021-07-20 14:55 ` [Intel-gfx] " Jason Ekstrand
2021-07-20 14:55 ` Jason Ekstrand
2021-07-21 11:26 ` [Intel-gfx] " Daniel Vetter
2021-07-21 11:26 ` Daniel Vetter
2021-07-21 15:20 ` [Intel-gfx] " Jason Ekstrand
2021-07-21 15:20 ` Jason Ekstrand
2021-07-19 18:30 ` [Intel-gfx] [PATCH 4/6] drm/ttm: Force re-init if ttm_global_init() fails Jason Ekstrand
2021-07-19 18:30 ` Jason Ekstrand
2021-07-19 19:21 ` [Intel-gfx] " Christian König
2021-07-19 19:21 ` Christian König
2021-07-19 18:30 ` [Intel-gfx] [PATCH 5/6] drm/ttm: Initialize debugfs from ttm_global_init() Jason Ekstrand
2021-07-19 18:30 ` Jason Ekstrand
2021-07-20 14:22 ` Daniel Vetter [this message]
2021-07-20 14:22 ` Daniel Vetter
2021-07-19 18:30 ` [Intel-gfx] [PATCH 6/6] drm/i915: Make the kmem slab for i915_buddy_block a global Jason Ekstrand
2021-07-19 18:30 ` Jason Ekstrand
2021-07-19 18:38 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for Fix the debugfs splat from mock selftests Patchwork
2021-07-19 18:38 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2021-07-19 18:42 ` [Intel-gfx] ✗ Fi.CI.DOCS: " Patchwork
2021-07-19 19:05 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2021-07-19 23:32 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2021-07-20 18:13 [Intel-gfx] [PATCH 0/6] " Jason Ekstrand
2021-07-20 18:13 ` [Intel-gfx] [PATCH 5/6] drm/ttm: Initialize debugfs from ttm_global_init() Jason Ekstrand
2021-07-21 15:23 [Intel-gfx] [PATCH 0/6] Fix the debugfs splat from mock selftests (v3) Jason Ekstrand
2021-07-21 15:23 ` [Intel-gfx] [PATCH 5/6] drm/ttm: Initialize debugfs from ttm_global_init() Jason Ekstrand
2021-07-22 10:09 ` 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=YPbcGrJP3JPIEPDh@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jason@jlekstrand.net \
/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.