Skip to contentSkip to conversation

dmaengine: idxd: Check availability of workqueue allocated by idxd wq driver before using

PATCH Applied Yi Sun 4 participants 4 messages May 9, 2025 – May 14, 2025

Subsystems (2)
lore
Share & tools
lore

Yi Sun

author
#0 lore raw

PATCH 1/1 dmaengine: idxd: Check availability of workqueue allocated by idxd wq driver before using

Running IDXD workloads in a container with the /dev directory mounted can trigger a call trace or even a kernel panic when the parent process of the container is terminated.

This issue occurs because, under certain configurations, Docker does not properly propagate the mount replica back to the original mount point.

In this case, when the user driver detaches, the WQ is destroyed but it still calls destroy_workqueue() attempting to completes all pending work. It's necessary to check wq->wq and skip the drain if it no longer exists.

drivers/dma/idxd/cdev.c +3 -1
index ff94ee892339..a202fe4937a7 100644
@@ -349,7 +349,9 @@ static void idxd_cdev_evl_drain_pasid(struct idxd_wq *wq, u32 pasid)
 			set_bit(h, evl->bmap);
 		h = (h + 1) % size;
 	}
-	drain_workqueue(wq->wq);
+	if (wq->wq)
+		drain_workqueue(wq->wq);
+
 	mutex_unlock(&evl->lock);
 }
 
Signature · 1 line
2.43.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Yi Sun

Running IDXD workloads in a container with the /dev directory mounted can trigger a call trace or even a kernel panic when the parent process of the container is terminated.

This issue occurs because, under certain configurations, Docker does not properly propagate the mount replica back to the original mount point.

In this case, when the user driver detaches, the WQ is destroyed but it

I would be more specific. wq->wq (workqueue) that is allocated by the cdev user driver during ->probe() is destroyed when the driver is unbound.

Quoted 4 lines

still calls destroy_workqueue() attempting to completes all pending work. It's necessary to check wq->wq and skip the drain if it no longer exists.

Quoted 16 lines
drivers/dma/idxd/cdev.c +3 -1
index ff94ee892339..a202fe4937a7 100644
@@ -349,7 +349,9 @@ static void idxd_cdev_evl_drain_pasid(struct idxd_wq *wq, u32 pasid)
 			set_bit(h, evl->bmap);
 		h = (h + 1) % size;
 	}
-	drain_workqueue(wq->wq);
+	if (wq->wq)
+		drain_workqueue(wq->wq);
+
 	mutex_unlock(&evl->lock);
 }
 
#2 lore raw
Quoted 9 lines · Dave Jiang
Quoted 7 lines · Yi Sun

Running IDXD workloads in a container with the /dev directory mounted can trigger a call trace or even a kernel panic when the parent process of the container is terminated.

This issue occurs because, under certain configurations, Docker does not properly propagate the mount replica back to the original mount point.

Quoted 8 lines
Quoted 1 line

In this case, when the user driver detaches, the WQ is destroyed but it

I would be more specific. wq->wq (workqueue) that is allocated by the cdev user driver during ->probe() is destroyed when the driver is unbound.

Quoted 4 lines

still calls destroy_workqueue() attempting to completes all pending work. It's necessary to check wq->wq and skip the drain if it no longer exists.

Quoted 16 lines
Quoted 16 lines
drivers/dma/idxd/cdev.c +3 -1
index ff94ee892339..a202fe4937a7 100644
@@ -349,7 +349,9 @@ static void idxd_cdev_evl_drain_pasid(struct idxd_wq *wq, u32 pasid)
  			set_bit(h, evl->bmap);
  		h = (h + 1) % size;
  	}
-	drain_workqueue(wq->wq);
+	if (wq->wq)
+		drain_workqueue(wq->wq);
+
  	mutex_unlock(&evl->lock);
  }
 
maintainer Applied
#3 lore raw
In reply to Yi Sun
Quoted 8 lines · Yi Sun

Running IDXD workloads in a container with the /dev directory mounted can trigger a call trace or even a kernel panic when the parent process of the container is terminated.

This issue occurs because, under certain configurations, Docker does not properly propagate the mount replica back to the original mount point.

[...]

Applied, thanks!

[1/1] dmaengine: idxd: Check availability of workqueue allocated by idxd wq driver before using

      commit: 17502e7d7b7113346296f6758324798d536c31fd

Best regards,

Signature · 1 line
~Vinod