All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: gregkh@linuxfoundation.org
Cc: intel-xe@lists.freedesktop.org
Subject: Re: Patch "drm/xe: Fix shrinker accounting double-subtraction on nested external pins" has been added to the 7.2-stable tree
Date: Mon, 12 Oct 2026 15:58:09 +0000	[thread overview]
Message-ID: <sashiko-outbox-168370@kernel.org> (raw)
In-Reply-To: <2026101238-calm-footing-389c@gregkh>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] drm/xe: MADVISE on pinned FB double-subtracts shrinker pages
--

commit fd0d0cc5f1317ebe67563e2a71be658497f18472
Author: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Subject: drm/xe: Fix shrinker accounting double-subtraction on nested external pins

This commit introduces helpers to ensure shrinker accounting is only updated
on the outermost pin and final unpin transitions. It also excludes imported
dma-bufs from pin/unpin shrinker accounting and updates the framebuffer pin
paths to use these new helpers.

Link: https://patch.msgid.link/20261002100830.12297-2-thomas.hellstrom@linux.intel.com

> diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c b/drivers/gpu/drm/xe/display/xe_fb_pin.c
> --- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
> +++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
> @@ -356,7 +356,7 @@ static struct i915_vma *__xe_pin_fb_vma(struct drm_gem_object *obj, bool is_dpt,
>  		drm_exec_retry_on_contention(&exec);
>  		xe_validation_retry_on_oom(&ctx, &ret);
>  		if (!ret)
> -			ttm_bo_pin(&bo->ttm);
> +			xe_bo_pin_account(bo);

[Severity: High]
Can this new shrinker accounting for framebuffers lead to a
double-subtraction underflow?

When a user creates a BO, maps it (creating a VMA, willneed_count = 1), and
uses it as a display framebuffer, this path calls xe_bo_pin_account() which
subtracts the BO's pages from the shrinkable count. However, FB pinning does
not increment willneed_count to prevent MADVISE transitions while pinned.

If the user then invokes the DRM_IOCTL_XE_VM_MADVISE ioctl to set the BO to
DONTNEED, the willneed_count drops to 0 and xe_bo_set_purgeable_shrinker()
is called. xe_bo_set_purgeable_shrinker() will unconditionally transition
the state and subtract the pages from the shrinkable count again:

xe_bo_set_purgeable_shrinker() {
        /* Transfer pages from shrinkable to purgeable count */
        xe_shrinker_mod_pages(xe->mem.shrinker, -tt_pages, tt_pages);
}

Since the count is stored as a signed long but added to an unsigned long
total in xe_shrinker_count(), dropping below zero causes an enormous
positive value. Could this cause the kernel memory reclaimer to excessively
invoke the shrinker under memory pressure, leading to a system livelock
or severe performance degradation?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/2026101238-calm-footing-389c@gregkh?part=1

      reply	other threads:[~2026-10-12 15:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-12 15:38 Patch "drm/xe: Fix shrinker accounting double-subtraction on nested external pins" has been added to the 7.2-stable tree gregkh
2026-10-12 15:58 ` sashiko-bot [this message]

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-168370@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=intel-xe@lists.freedesktop.org \
    --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.