Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] drm/xe/client: fix deadlock in show_meminfo()
@ 2024-09-10 13:11 Matthew Auld
  2024-09-10 13:11 ` [PATCH 2/4] drm/xe/client: add missing bo locking " Matthew Auld
                   ` (12 more replies)
  0 siblings, 13 replies; 28+ messages in thread
From: Matthew Auld @ 2024-09-10 13:11 UTC (permalink / raw)
  To: intel-xe
  Cc: Himal Prasad Ghimiray, Tejas Upadhyay, Thomas Hellström,
	stable

There is a real deadlock as well as sleeping in atomic() bug in here, if
the bo put happens to be the last ref, since bo destruction wants to
grab the same spinlock and sleeping locks.  Fix that by dropping the ref
using xe_bo_put_deferred(), and moving the final commit outside of the
lock. Dropping the lock around the put is tricky since the bo can go
out of scope and delete itself from the list, making it difficult to
navigate to the next list entry.

Fixes: 0845233388f8 ("drm/xe: Implement fdinfo memory stats printing")
Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/2727
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Cc: Tejas Upadhyay <tejas.upadhyay@intel.com>
Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Cc: <stable@vger.kernel.org> # v6.8+
---
 drivers/gpu/drm/xe/xe_drm_client.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/xe_drm_client.c b/drivers/gpu/drm/xe/xe_drm_client.c
index e64f4b645e2e..badfa045ead8 100644
--- a/drivers/gpu/drm/xe/xe_drm_client.c
+++ b/drivers/gpu/drm/xe/xe_drm_client.c
@@ -196,6 +196,7 @@ static void show_meminfo(struct drm_printer *p, struct drm_file *file)
 	struct xe_drm_client *client;
 	struct drm_gem_object *obj;
 	struct xe_bo *bo;
+	LLIST_HEAD(deferred);
 	unsigned int id;
 	u32 mem_type;
 
@@ -215,11 +216,14 @@ static void show_meminfo(struct drm_printer *p, struct drm_file *file)
 	list_for_each_entry(bo, &client->bos_list, client_link) {
 		if (!kref_get_unless_zero(&bo->ttm.base.refcount))
 			continue;
+
 		bo_meminfo(bo, stats);
-		xe_bo_put(bo);
+		xe_bo_put_deferred(bo, &deferred);
 	}
 	spin_unlock(&client->bos_lock);
 
+	xe_bo_put_commit(&deferred);
+
 	for (mem_type = XE_PL_SYSTEM; mem_type < TTM_NUM_MEM_TYPES; ++mem_type) {
 		if (!xe_mem_type_to_name[mem_type])
 			continue;
-- 
2.46.0


^ permalink raw reply related	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2024-09-11  9:41 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-10 13:11 [PATCH 1/4] drm/xe/client: fix deadlock in show_meminfo() Matthew Auld
2024-09-10 13:11 ` [PATCH 2/4] drm/xe/client: add missing bo locking " Matthew Auld
2024-09-10 14:16   ` Matthew Brost
2024-09-11  5:39   ` Upadhyay, Tejas
2024-09-11  8:35     ` Matthew Auld
2024-09-11  9:40       ` Upadhyay, Tejas
2024-09-10 13:11 ` [PATCH 3/4] drm/xe/client: use mem_type from the current resource Matthew Auld
2024-09-10 14:18   ` Matthew Brost
2024-09-11  5:45   ` Upadhyay, Tejas
2024-09-10 13:11 ` [PATCH 4/4] drm/xe/bo: add some annotations in bo_put() Matthew Auld
2024-09-10 13:59   ` Matthew Brost
2024-09-10 14:52     ` Matthew Auld
2024-09-10 15:59       ` Matthew Brost
2024-09-10 14:49   ` Matthew Brost
2024-09-10 15:03     ` Matthew Auld
2024-09-10 15:26       ` Matthew Brost
2024-09-10 15:29         ` Matthew Brost
2024-09-11  5:40   ` Upadhyay, Tejas
2024-09-10 13:29 ` ✓ CI.Patch_applied: success for series starting with [1/4] drm/xe/client: fix deadlock in show_meminfo() Patchwork
2024-09-10 13:30 ` ✓ CI.checkpatch: " Patchwork
2024-09-10 13:31 ` ✓ CI.KUnit: " Patchwork
2024-09-10 13:48 ` ✓ CI.Build: " Patchwork
2024-09-10 13:53 ` ✓ CI.Hooks: " Patchwork
2024-09-10 13:55 ` [PATCH 1/4] " Matthew Brost
2024-09-10 13:56 ` ✓ CI.checksparse: success for series starting with [1/4] " Patchwork
2024-09-10 14:39 ` ✓ CI.BAT: " Patchwork
2024-09-10 15:45 ` ✗ CI.FULL: failure " Patchwork
2024-09-11  5:19 ` [PATCH 1/4] " Upadhyay, Tejas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox