Skip to content

drm/xe: Fix two bo pin/unpin accounting bugs

Thomas Hellström intel-xe stable 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest2 patches 2 repliesIn review
  2. v22 patches 5 repliesSuperseded
  3. v11 patch 1 replySuperseded

Changes in v3 from the cover letter

- Fixed an additional shrinker accounting underflow in 1/2, affecting imported dma-bufs, found by Sashiko AI review.
- Rebased 2/2 on top of 1/2's changes.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2drm/xe: Fix shrinker accounting double-subtraction on nested external pinsdrivers/gpu/drm/xe/display/xe_fb_pin.c drivers/gpu/drm/xe/xe_bo.c drivers/gpu/drm/xe/xe_bo.h+95 -291 reply
2/2drm/xe: Fix stale pinned_link entry when fb-pin performs the final unpindrivers/gpu/drm/xe/xe_bo.c+16 -91 reply

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchMatthew AuldHimal Prasad Ghimiray
1/2R-b R-b
2/2R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/2] drm/xe: Fix two bo pin/unpin accounting bugs

Two independent fixes uncovered while auditing the bo pin/unpin and shrinker accounting paths:

1/2 fixes a double-subtraction of the shrinker's page/object accounting on nested xe_bo_pin_external()/xe_bo_unpin_external() calls, which can desynchronize the shrinker's counts from reality and, due to a signed-to-unsigned interpretation in xe_shrinker_count(), turn into a huge bogus shrinkable/purgeable page count that causes the shrinker to be invoked excessively under memory pressure.

2/2 fixes a stale xe->pinned.late.external list entry left behind when a bo pinned both externally and as an fb has its final unpin performed via the fb-pin path, which bypasses pinned_link maintenance and can lead to list corruption or a use-after-free once the bo is freed.

Both are tagged for stable.

v2:
- Added 2/2, fixing a stale pinned_link entry found by Sashiko AI review.
- Minor cleanup in 1/2.

v3:
- Fixed an additional shrinker accounting underflow in 1/2, affecting imported dma-bufs, found by Sashiko AI review.
- Rebased 2/2 on top of 1/2's changes.

Thomas Hellström (2):
drm/xe: Fix shrinker accounting double-subtraction on nested external
pins
drm/xe: Fix stale pinned_link entry when fb-pin performs the final
unpin

 drivers/gpu/drm/xe/display/xe_fb_pin.c |   6 +-
 drivers/gpu/drm/xe/xe_bo.c             | 139 +++++++++++++++++++------
 drivers/gpu/drm/xe/xe_bo.h             |   2 +
 3 files changed, 110 insertions(+), 37 deletions(-)
Signature · 1 line
2.55.0