Skip to contentSkip to conversation

dma-buf: Suppress a thread-safety complaint

PATCH In review Bart Van Assche 2 participants 4 messages Feb 27 – Apr 3

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 dma-buf: Suppress a thread-safety complaint

Handle all possible dma_resv_lock() return values. This patch prepares for enabling compile-time thread-safety analysis. This will cause the compiler to check whether all dma_resv_lock() return values are handled.

---

Changes compared to v1:
- Removed dead code.
- Removed the return value changes.
- Added a comment and a WARN_ON() statement.

 drivers/dma-buf/dma-resv.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/dma-buf/dma-resv.c +4 -1
index bea3e9858aca..ce9e6c04897f 100644
@@ -790,8 +790,11 @@ static int __init dma_resv_lockdep(void)
 	mmap_read_lock(mm);
 	ww_acquire_init(&ctx, &reservation_ww_class);
 	ret = dma_resv_lock(&obj, &ctx);
-	if (ret == -EDEADLK)
+	if (ret) {
+		/* Only EDEADLK from the error injection is possible here */
+		WARN_ON(ret != -EDEADLK);
 		dma_resv_lock_slow(&obj, &ctx);
+	}
 	fs_reclaim_acquire(GFP_KERNEL);
 	/* for unmap_mapping_range on trylocked buffer objects in shrinkers */
 	i_mmap_lock_write(&mapping);
maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 5 lines · Bart Van Assche

Handle all possible dma_resv_lock() return values. This patch prepares for enabling compile-time thread-safety analysis. This will cause the compiler to check whether all dma_resv_lock() return values are handled.

Do you want to push that one upstream through the DMA-buf path or do you want to upstream it through some other branch?

Regards,
Christian.

Quoted 27 lines

---

Changes compared to v1:
- Removed dead code.
- Removed the return value changes.
- Added a comment and a WARN_ON() statement.

 drivers/dma-buf/dma-resv.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/dma-buf/dma-resv.c +4 -1
index bea3e9858aca..ce9e6c04897f 100644
@@ -790,8 +790,11 @@ static int __init dma_resv_lockdep(void)
 	mmap_read_lock(mm);
 	ww_acquire_init(&ctx, &reservation_ww_class);
 	ret = dma_resv_lock(&obj, &ctx);
-	if (ret == -EDEADLK)
+	if (ret) {
+		/* Only EDEADLK from the error injection is possible here */
+		WARN_ON(ret != -EDEADLK);
 		dma_resv_lock_slow(&obj, &ctx);
+	}
 	fs_reclaim_acquire(GFP_KERNEL);
 	/* for unmap_mapping_range on trylocked buffer objects in shrinkers */
 	i_mmap_lock_write(&mapping);
#2 lore raw
Quoted 11 lines · Christian König
Quoted 5 lines · Bart Van Assche

Handle all possible dma_resv_lock() return values. This patch prepares for enabling compile-time thread-safety analysis. This will cause the compiler to check whether all dma_resv_lock() return values are handled.

Do you want to push that one upstream through the DMA-buf path or do you want to upstream it through some other branch?

The DMA-buf path please. Peter Zijlstra requested this as one can see here:
https://lore.kernel.org/lkml/[email protected]/

Thanks,

Bart.

#3 lore raw
Quoted 8 lines · Bart Van Assche
Quoted 7 lines · Christian König
Quoted 5 lines · Bart Van Assche

Handle all possible dma_resv_lock() return values. This patch prepares for enabling compile-time thread-safety analysis. This will cause the compiler to check whether all dma_resv_lock() return values are handled.

Quoted 7 lines
Quoted 4 lines

Do you want to push that one upstream through the DMA-buf path or do you want to upstream it through some other branch?

The DMA-buf path please. Peter Zijlstra requested this as one can see here:
https://lore.kernel.org/ lkml/[email protected]/

(replying to my own email)

Is my understanding correct that this patch has not yet been queued? If so, please let me know if I'm expected to repost this patch.

Thanks,

Bart.