All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Rob Clark" <robin.clark@oss.qualcomm.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 5/6] drm/msm/gem: Stop calling get_pages() for imported dma-bufs
Date: Sat, 26 Sep 2026 18:43:14 +0000	[thread overview]
Message-ID: <20260926184315.0F1351F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260926183051.25754-6-robin.clark@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] drm/msm: memory leak and LRU invariant violation due to is_resident() relying only on sgt
--

commit 5c4dfee34fe56ce4eb175d5b53ce5d68a5bafe60
Author: Rob Clark <robin.clark@oss.qualcomm.com>

drm/msm/gem: Stop calling get_pages() for imported dma-bufs

This commit stops calling get_pages() for imported dma-bufs and uses
the sgt instead of pages to determine if an object is resident.

> diff --git a/drivers/gpu/drm/msm/msm_gem.h b/drivers/gpu/drm/msm/msm_gem.h
> index d7df016b1f272..d8ec696d89d74 100644
> --- a/drivers/gpu/drm/msm/msm_gem.h
> +++ b/drivers/gpu/drm/msm/msm_gem.h
> @@ -425,7 +425,7 @@ static inline bool is_unevictable(struct msm_gem_object *msm_obj)
>  /* Are backing pages/sgt allocated? */
>  static inline bool is_resident(struct msm_gem_object *msm_obj)
>  {
> -	return !!msm_obj->pages;
> +	return !!msm_obj->sgt;
>  }

[Severity: High]
Can this cause a memory leak and trigger a WARN_ON?

If get_pages() successfully allocates msm_obj->pages but fails at
drm_prime_pages_to_sg(), it returns an error but retains msm_obj->pages
while msm_obj->sgt is NULL. With is_resident() now relying strictly on
sgt, this partially backed object is considered non-resident.

If userspace retries pinning the object, get_pages() sees msm_obj->pages
is already populated, returns success, and increments pin_count while sgt
remains NULL. A subsequent unpin or madvise will call update_lru_locked(),
which uses is_resident():

drivers/gpu/drm/msm/msm_gem.c:update_lru_locked() {
    ...
	if (!is_resident(msm_obj)) {
		GEM_WARN_ON(msm_obj->pin_count);

		drm_gem_lru_move_tail_locked(&priv->lru.unbacked, obj);
	}
    ...
}

Because is_resident() returns false, the object is placed in the unbacked
LRU list, causing a memory leak since the shrinker only scans dontneed and
willneed lists. It will also trigger the GEM_WARN_ON splat.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260926183051.25754-1-robin.clark@oss.qualcomm.com?part=5

  reply	other threads:[~2026-09-26 18:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-26 18:30 [PATCH 0/6] drm/msm/gem: Drop use of pages for imported dma-bufs Rob Clark
2026-09-26 18:30 ` [PATCH 1/6] drm/msm/gem: Add helper to check if resident Rob Clark
2026-09-26 18:30 ` [PATCH 2/6] drm/msm/gem: Mmap imported dma-bufs via the exporter Rob Clark
2026-09-28  8:37   ` Christian König
2026-09-26 18:30 ` [PATCH 3/6] drm/msm/gem: Use get_pages() directly in vmap path Rob Clark
2026-09-26 18:30 ` [PATCH 4/6] drm/msm/gem: Stop exposing a page array Rob Clark
2026-09-26 18:40   ` sashiko-bot
2026-09-26 18:30 ` [PATCH 5/6] drm/msm/gem: Stop calling get_pages() for imported dma-bufs Rob Clark
2026-09-26 18:43   ` sashiko-bot [this message]
2026-09-26 18:30 ` [PATCH 6/6] drm/msm/gem: Drop use of drm_prime_sg_to_page_array() Rob Clark

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=20260926184315.0F1351F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=robin.clark@oss.qualcomm.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.