From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: Jonathan Cavitt <jonathan.cavitt@intel.com>,
dri-devel@lists.freedesktop.org
Cc: saurabhg.gupta@intel.com, alex.zuo@intel.com,
intel-xe@lists.freedesktop.org, matthew.brost@intel.com,
maarten.lankhorst@linux.intel.com
Subject: Re: [PATCH v3] drm/pagemap_util: Ensure proper cache lock management on free
Date: Mon, 16 Mar 2026 10:32:05 +0100 [thread overview]
Message-ID: <0c1376275156c4a1392f9e19a20b78184c27cfc5.camel@linux.intel.com> (raw)
In-Reply-To: <20260306154322.60120-2-jonathan.cavitt@intel.com>
On Fri, 2026-03-06 at 15:43 +0000, Jonathan Cavitt wrote:
> Static analysis issue:
>
> Though probably unnecessary given the cache is being freed at this
> step,
> for the sake of consistency, ensure that the cache lock is always
> unlocked after drm_pagemap_cache_fini.
>
Typically you don't start the commit message with the tool that found
it, like "fixing an error found by checkpatch.pl" or something similar,
but rather mention it at the bottom after explaining the fix and its
implications.
Also I'd skip the "Though probably unnecessary..." sentence. Spinlocks
typically disable preemption and if the code-path missing the unlock is
hit, preemption will remain disabled even if the lock is subsequently
freed.
Fix looks good, so with the commit message fixed,
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> v2:
> - Use requested code flow (Maarten)
>
> v3:
> - Clear cache->dpagemap (Matt Brost, Maarten)
>
> Fixes: 77f14f2f2d73f ("drm/pagemap: Add a drm_pagemap cache and
> shrinker")
> Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
> Cc: Thomas Hellstrom <thomas.hellstrom@linux.intel.com>
> Cc: Matthew Brost <matthew.brost@intel.com>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
> drivers/gpu/drm/drm_pagemap_util.c | 14 +++++---------
> 1 file changed, 5 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_pagemap_util.c
> b/drivers/gpu/drm/drm_pagemap_util.c
> index 14ddb948a32e..6111d90a38e2 100644
> --- a/drivers/gpu/drm/drm_pagemap_util.c
> +++ b/drivers/gpu/drm/drm_pagemap_util.c
> @@ -65,18 +65,14 @@ static void drm_pagemap_cache_fini(void *arg)
> drm_dbg(cache->shrinker->drm, "Destroying dpagemap
> cache.\n");
> spin_lock(&cache->lock);
> dpagemap = cache->dpagemap;
> - if (!dpagemap) {
> - spin_unlock(&cache->lock);
> - goto out;
> - }
> + cache->dpagemap = NULL;
> + if (dpagemap && !drm_pagemap_shrinker_cancel(dpagemap))
> + dpagemap = NULL;
> + spin_unlock(&cache->lock);
>
> - if (drm_pagemap_shrinker_cancel(dpagemap)) {
> - cache->dpagemap = NULL;
> - spin_unlock(&cache->lock);
> + if (dpagemap)
> drm_pagemap_destroy(dpagemap, false);
> - }
>
> -out:
> mutex_destroy(&cache->lookup_mutex);
> kfree(cache);
> }
next prev parent reply other threads:[~2026-03-16 9:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-06 15:43 [PATCH v3] drm/pagemap_util: Ensure proper cache lock management on free Jonathan Cavitt
2026-03-06 21:57 ` ✓ CI.KUnit: success for " Patchwork
2026-03-06 22:38 ` ✓ Xe.CI.BAT: " Patchwork
2026-03-08 1:13 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-03-12 14:37 ` Cavitt, Jonathan
2026-03-16 9:32 ` Thomas Hellström [this message]
2026-03-16 9:36 ` [PATCH v3] " Maarten Lankhorst
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=0c1376275156c4a1392f9e19a20b78184c27cfc5.camel@linux.intel.com \
--to=thomas.hellstrom@linux.intel.com \
--cc=alex.zuo@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=jonathan.cavitt@intel.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matthew.brost@intel.com \
--cc=saurabhg.gupta@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox