From: sashiko-bot@kernel.org
To: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v4 4/4] drm/xe: Update non-purgeable shrinker batch size based on average BO size
Date: Fri, 16 Oct 2026 13:45:13 +0000 [thread overview]
Message-ID: <sashiko-outbox-174403@kernel.org> (raw)
In-Reply-To: <20261016133523.3622-5-thomas.hellstrom@linux.intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] drm/xe: shrinker count callback serializes direct reclaim via write_lock
--
commit a78bd8842e67f957a2ced6d827e1c4a6430ff29b
Author: Thomas Hellström <thomas.hellstrom@linux.intel.com>
drm/xe: Update non-purgeable shrinker batch size based on average BO size
This commit updates the preferred vmscan batch size for the non-purgeable
shrinker based on the average buffer object size. It introduces an
exponential moving average that is updated during the shrinker count phase.
> diff --git a/drivers/gpu/drm/xe/xe_shrinker.c b/drivers/gpu/drm/xe/xe_shrinker.c
> index 8e3fe675e0f34..955908b3bdf3e 100644
> --- a/drivers/gpu/drm/xe/xe_shrinker.c
> +++ b/drivers/gpu/drm/xe/xe_shrinker.c
[ ... ]
> @@ -210,15 +235,26 @@ xe_shrinker_count(struct shrinker *shrink, struct shrink_control *sc)
> unsigned long num_pages;
> bool can_backup = !!(sc->gfp_mask & __GFP_FS);
>
> + if (!can_backup)
> + return SHRINK_EMPTY;
> +
> num_pages = ttm_backup_bytes_avail() >> PAGE_SHIFT;
> - read_lock(&shrinker->lock);
> + /* Consistently use write_lock() for simplicity. */
> + write_lock(&shrinker->lock);
[Severity: Medium]
Will this exclusive write lock create a system-wide performance bottleneck
during memory reclaim?
The core mm subsystem frequently calls the shrinker's count_objects callback
(xe_shrinker_count) from do_shrink_slab() during direct reclaim. This occurs
concurrently across multiple allocating tasks and CPUs when under memory
pressure.
By changing read_lock() to write_lock() to update the batch_avg heuristic,
this forces all concurrent direct reclaimers system-wide to serialize on this
single lock, which could lead to severe lock contention and performance
degradation.
>
> - if (can_backup)
> - num_pages = min_t(unsigned long, num_pages, shrinker->shrinkable_pages);
> - else
> - num_pages = 0;
> + num_pages = min_t(unsigned long, num_pages, shrinker->shrinkable_pages);
>
> - read_unlock(&shrinker->lock);
> + if (shrinker->populated_tts) {
> + unsigned long avg = 2 * (shrinker->shrinkable_pages +
> + shrinker->purgeable_pages) /
> + shrinker->populated_tts;
> +
> + shrinker->batch_avg = max((shrinker->batch_avg + (long)avg) >> 1,
> + 128L /* default SHRINK_BATCH */);
> + WRITE_ONCE(shrink->batch, shrinker->batch_avg);
> + }
> +
> + write_unlock(&shrinker->lock);
>
> return num_pages ? num_pages : SHRINK_EMPTY;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261016133523.3622-1-thomas.hellstrom@linux.intel.com?part=4
next prev parent reply other threads:[~2026-10-16 13:45 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 13:35 [PATCH v4 0/4] drm/xe: Adjust the bo shrinker batch size Thomas Hellström
2026-10-16 13:35 ` [PATCH v4 1/4] drm/xe: Don't abort the shrinker walk on -EBUSY Thomas Hellström
2026-10-16 13:44 ` sashiko-bot
2026-10-16 13:55 ` Matthew Brost
2026-10-16 13:35 ` [PATCH v4 2/4] drm/xe: Track number of populated ttm_tts in the shrinker Thomas Hellström
2026-10-16 14:26 ` Matthew Brost
2026-10-16 13:35 ` [PATCH v4 3/4] drm/xe: Split the bo shrinker into purgeable and non-purgeable shrinkers Thomas Hellström
2026-10-16 13:53 ` sashiko-bot
2026-10-16 14:09 ` Thomas Hellström
2026-10-16 18:41 ` Matthew Brost
2026-10-16 18:16 ` Matthew Brost
2026-10-16 13:35 ` [PATCH v4 4/4] drm/xe: Update non-purgeable shrinker batch size based on average BO size Thomas Hellström
2026-10-16 13:45 ` sashiko-bot [this message]
2026-10-16 14:06 ` Thomas Hellström
2026-10-16 18:42 ` Matthew Brost
2026-10-16 18:44 ` Matthew Brost
2026-10-16 13:45 ` ✓ CI.KUnit: success for drm/xe: Adjust the bo shrinker batch size (rev4) Patchwork
2026-10-16 14:37 ` ✓ Xe.CI.BAT: " Patchwork
2026-10-16 22:14 ` ✓ Xe.CI.FULL: " Patchwork
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=sashiko-outbox-174403@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=thomas.hellstrom@linux.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 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.