From: sashiko-bot@kernel.org
To: "Rob Clark" <robin.clark@oss.qualcomm.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 2/2] drm/msm/gem: Add modparam to disable shrinker blocking
Date: Thu, 03 Sep 2026 18:47:58 +0000 [thread overview]
Message-ID: <20260903184758.8608E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260903183725.15835-2-robin.clark@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The shrinker scan function `msm_gem_shrinker_scan` loses count of freed objects and aborts prematurely by returning `SHRINK_STOP` when all scanned objects are successfully freed.
--
commit 1da508dba68cbcbae647ca4f3177e66e5a19e756
Author: Rob Clark <robin.clark@oss.qualcomm.com>
drm/msm/gem: Add modparam to disable shrinker blocking
This commit adds a module parameter, eviction_can_block, to disable
blocking for GEM buffers to become idle during shrinker eviction. This
helps prevent the shrinker from waiting on idle BOs during high memory
pressure, which is undesirable in latency-sensitive use-cases.
> diff --git a/drivers/gpu/drm/msm/msm_gem_shrinker.c b/drivers/gpu/drm/msm/msm_gem_shrinker.c
> index 9d2788f79acee..db57609046d1b 100644
> --- a/drivers/gpu/drm/msm/msm_gem_shrinker.c
> +++ b/drivers/gpu/drm/msm/msm_gem_shrinker.c
> @@ -19,6 +19,10 @@ static bool enable_eviction = true;
> MODULE_PARM_DESC(enable_eviction, "Enable swappable GEM buffers");
> module_param(enable_eviction, bool, 0600);
>
> +static bool eviction_can_block = true;
> +MODULE_PARM_DESC(eviction_can_block, "Enable blocking for GEM buffer to become idle for eviction");
> +module_param(eviction_can_block, bool, 0600);
> +
> static bool can_swap(void)
> {
> return enable_eviction && get_nr_swap_pages() > 0;
> @@ -26,6 +30,8 @@ static bool can_swap(void)
>
> static bool can_block(struct shrink_control *sc)
> {
> + if (!eviction_can_block)
> + return false;
[Severity: High]
This is a pre-existing issue, but I noticed the shrinker scan function can
lose count of freed objects and abort prematurely.
When the VM calls msm_gem_shrinker_scan(), it loops over LRU stages calling
drm_gem_lru_scan():
drivers/gpu/drm/msm/msm_gem_shrinker.c:msm_gem_shrinker_scan() {
...
for (unsigned i = 0; (nr > 0) && (i < ARRAY_SIZE(stages)); i++) {
...
stages[i].freed =
drm_gem_lru_scan(priv->dev, stages[i].lru, nr,
&stages[i].remaining,
stages[i].shrink,
NULL);
nr -= stages[i].freed;
freed += stages[i].freed;
remaining += stages[i].remaining;
}
...
return (freed > 0 && remaining > 0) ? freed : SHRINK_STOP;
}
In drm_gem_lru_scan(), the remaining parameter is only populated with objects
that failed to be shrunk:
drivers/gpu/drm/drm_gem.c:drm_gem_lru_scan() {
...
if (!ww_mutex_trylock(&obj->resv->lock, ticket)) {
*remaining += obj->size >> PAGE_SHIFT;
goto tail;
}
...
}
If all scanned objects in a batch are successfully freed without encountering
a locked object, remaining will be 0. The return expression
(freed > 0 && remaining > 0) ? freed : SHRINK_STOP; then evaluates to
SHRINK_STOP instead of the number of freed items.
Does this prematurely abort the core memory management shrinker
(do_shrink_slab) and under-report the amount of reclaimed memory,
potentially degrading memory reclaim efficiency and triggering unnecessary
OOM kills?
> return (sc->gfp_mask & __GFP_DIRECT_RECLAIM) ||
> (current_is_kswapd() && (sc->gfp_mask & __GFP_KSWAPD_RECLAIM));
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260903183725.15835-1-robin.clark@oss.qualcomm.com?part=2
next prev parent reply other threads:[~2026-09-03 18:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 18:37 [PATCH 1/2] drm/msm: Enable THP for GEM buffers Rob Clark
2026-09-03 18:37 ` [PATCH 2/2] drm/msm/gem: Add modparam to disable shrinker blocking Rob Clark
2026-09-03 18:47 ` sashiko-bot [this message]
2026-09-03 18:48 ` [PATCH 1/2] drm/msm: Enable THP for GEM buffers sashiko-bot
2026-09-08 16:49 ` 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=20260903184758.8608E1F000E9@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.