From: sashiko-bot@kernel.org
To: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v2 2/2] drm/xe: Update shrinker batch size based on average BO size
Date: Fri, 14 Aug 2026 14:45:15 +0000 [thread overview]
Message-ID: <20260814144515.C8CC01F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260814143737.49684-3-thomas.hellstrom@linux.intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Concurrent read-modify-write of the shared shrinker batch size without synchronization causes a data race.
--
--- Patch [2]: [PATCH v2 2/2] drm/xe: Update shrinker batch size based on average BO size ---
commit 93a100ad39134ef7ca30d7a7dc94040b4d8bbe71
Author: Thomas Hellström <thomas.hellstrom@linux.intel.com>
drm/xe: Update shrinker batch size based on average BO size
This commit updates the preferred vmscan batch size based on the average
number of pages per GEM object. It adjusts the batch size as an exponential
moving average to avoid firing the shrinker for requests that are too small
to free an average-sized object.
> diff --git a/drivers/gpu/drm/xe/xe_shrinker.c b/drivers/gpu/drm/xe/xe_shrinker.c
> index cded230f5459c..284fce207705c 100644
> --- a/drivers/gpu/drm/xe/xe_shrinker.c
> +++ b/drivers/gpu/drm/xe/xe_shrinker.c
[ ... ]
> @@ -157,8 +159,32 @@ xe_shrinker_count(struct shrinker *shrink, struct shrink_control *sc)
> num_pages = 0;
>
> num_pages += shrinker->purgeable_pages;
> + total_pages = shrinker->shrinkable_pages + shrinker->purgeable_pages;
> + populated_tts = shrinker->populated_tts;
> read_unlock(&shrinker->lock);
>
> + /*
> + * Update our preferred vmscan batch size for the next pass.
[ ... ]
> + */
> + if (populated_tts) {
> + unsigned long avg = 2 * total_pages / populated_tts;
> +
> + shrinker->shrink->batch =
> + max((shrinker->shrink->batch + avg) >> 1,
> + 128UL /* default SHRINK_BATCH */);
[Severity: Medium]
Will this concurrent update cause a data race?
Since the lock is released with read_unlock just before this block, multiple
tasks entering xe_shrinker_count during direct reclaim or kswapd could
perform this read-modify-write concurrently.
While occasional lost updates to this heuristic might be functionally benign,
could this unprotected access trigger concurrency sanitizers?
> + }
> +
> return num_pages ? num_pages : SHRINK_EMPTY;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260814143737.49684-1-thomas.hellstrom@linux.intel.com?part=2
next prev parent reply other threads:[~2026-08-14 14:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 14:37 [PATCH v2 0/2] drm/xe: Adjust the bo shrinker batch size Thomas Hellström
2026-08-14 14:37 ` [PATCH v2 1/2] drm/xe: Track number of populated ttm_tts in the shrinker Thomas Hellström
2026-08-14 14:56 ` sashiko-bot
2026-08-14 14:37 ` [PATCH v2 2/2] drm/xe: Update shrinker batch size based on average BO size Thomas Hellström
2026-08-14 14:45 ` sashiko-bot [this message]
2026-08-14 15:17 ` ✓ CI.KUnit: success for drm/xe: Adjust the bo shrinker batch size (rev2) Patchwork
2026-08-14 16:14 ` ✗ Xe.CI.BAT: failure " Patchwork
2026-08-14 18:07 ` ✓ Xe.CI.FULL: success " 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=20260814144515.C8CC01F00A3A@smtp.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.