mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] dmaengine: idxd: Check availability of workqueue allocated by idxd wq driver before using
@ 2025-05-09  0:03 Yi Sun
  2025-05-09  0:07 ` Dave Jiang
  2025-05-14 15:03 ` Vinod Koul
  0 siblings, 2 replies; 4+ messages in thread
From: Yi Sun @ 2025-05-09  0:03 UTC (permalink / raw)
  To: dave.jiang, vinicius.gomes, dmaengine, linux-kernel
  Cc: yi.sun, anil.s.keshavamurthy, gordon.jin

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.

Signed-off-by: Yi Sun <yi.sun@intel.com>

diff --git a/drivers/dma/idxd/cdev.c b/drivers/dma/idxd/cdev.c
index ff94ee892339..a202fe4937a7 100644
--- a/drivers/dma/idxd/cdev.c
+++ b/drivers/dma/idxd/cdev.c
@@ -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.43.0


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

* Re: [PATCH] dmaengine: idxd: Check availability of workqueue allocated by idxd wq driver before using
  2025-05-09  0:03 [PATCH] dmaengine: idxd: Check availability of workqueue allocated by idxd wq driver before using Yi Sun
@ 2025-05-09  0:07 ` Dave Jiang
  2025-05-09  0:49   ` Keshavamurthy, Anil S
  2025-05-14 15:03 ` Vinod Koul
  1 sibling, 1 reply; 4+ messages in thread
From: Dave Jiang @ 2025-05-09  0:07 UTC (permalink / raw)
  To: Yi Sun, vinicius.gomes, dmaengine, linux-kernel
  Cc: anil.s.keshavamurthy, gordon.jin



On 5/8/25 5:03 PM, Yi Sun wrote:
> 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.

> 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.
> 
> Signed-off-by: Yi Sun <yi.sun@intel.com>

Reviewed-by: Dave Jiang <dave.jiang@intel.com>

> 
> diff --git a/drivers/dma/idxd/cdev.c b/drivers/dma/idxd/cdev.c
> index ff94ee892339..a202fe4937a7 100644
> --- a/drivers/dma/idxd/cdev.c
> +++ b/drivers/dma/idxd/cdev.c
> @@ -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);
>  }
>  


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

* Re: [PATCH] dmaengine: idxd: Check availability of workqueue allocated by idxd wq driver before using
  2025-05-09  0:07 ` Dave Jiang
@ 2025-05-09  0:49   ` Keshavamurthy, Anil S
  0 siblings, 0 replies; 4+ messages in thread
From: Keshavamurthy, Anil S @ 2025-05-09  0:49 UTC (permalink / raw)
  To: Dave Jiang, Yi Sun, vinicius.gomes, dmaengine, linux-kernel; +Cc: gordon.jin


On 5/8/2025 5:07 PM, Dave Jiang wrote:
>
> On 5/8/25 5:03 PM, Yi Sun wrote:
>> 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.
>
>> 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.
>>
>> Signed-off-by: Yi Sun <yi.sun@intel.com>
> Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
>
>> diff --git a/drivers/dma/idxd/cdev.c b/drivers/dma/idxd/cdev.c
>> index ff94ee892339..a202fe4937a7 100644
>> --- a/drivers/dma/idxd/cdev.c
>> +++ b/drivers/dma/idxd/cdev.c
>> @@ -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);
>>   }
>>   

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

* Re: [PATCH] dmaengine: idxd: Check availability of workqueue allocated by idxd wq driver before using
  2025-05-09  0:03 [PATCH] dmaengine: idxd: Check availability of workqueue allocated by idxd wq driver before using Yi Sun
  2025-05-09  0:07 ` Dave Jiang
@ 2025-05-14 15:03 ` Vinod Koul
  1 sibling, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2025-05-14 15:03 UTC (permalink / raw)
  To: dave.jiang, vinicius.gomes, dmaengine, linux-kernel, Yi Sun
  Cc: anil.s.keshavamurthy, gordon.jin


On Fri, 09 May 2025 08:03:04 +0800, Yi Sun wrote:
> 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,
-- 
~Vinod



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

end of thread, other threads:[~2025-05-14 15:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-09  0:03 [PATCH] dmaengine: idxd: Check availability of workqueue allocated by idxd wq driver before using Yi Sun
2025-05-09  0:07 ` Dave Jiang
2025-05-09  0:49   ` Keshavamurthy, Anil S
2025-05-14 15:03 ` Vinod Koul

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

all inboxes | Powered by JetHome®