Skip to contentSkip to conversation

RDMA/iwcm: Fix WARNING:at_kernel/workqueue.c:#check_flush_dependency

PATCH Superseded Zhu Yanjun 3 participants 5 messages Aug 17, 2024 – Aug 19, 2024 InfiniBand

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Zhu Yanjun

author
#0 lore raw

PATCH 1/1 RDMA/iwcm: Fix WARNING:at_kernel/workqueue.c:#check_flush_dependency

When workqueue_flush is invoked, WQ_MEM_RECLAIM is checked to avoid errors.

---
 drivers/infiniband/core/iwcm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/iwcm.c +1 -1
index 1a6339f3a63f..7e3a55349e10 100644
@@ -1182,7 +1182,7 @@ static int __init iw_cm_init(void)
 	if (ret)
 		return ret;
 
-	iwcm_wq = alloc_ordered_workqueue("iw_cm_wq", 0);
+	iwcm_wq = alloc_ordered_workqueue("iw_cm_wq", WQ_MEM_RECLAIM);
 	if (!iwcm_wq)
 		goto err_alloc;
 
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 2 lines · Zhu Yanjun

When workqueue_flush is invoked, WQ_MEM_RECLAIM is checked to avoid errors.

Include backtraces please, these things are tricky and we often have to go back and figure out why.

Explaine exactly why it is needed with traces in the commit message and summarize in a comment.

Jason

author
#2 lore raw
Quoted 8 lines · Jason Gunthorpe
Quoted 2 lines · Zhu Yanjun

When workqueue_flush is invoked, WQ_MEM_RECLAIM is checked to avoid errors.

Include backtraces please, these things are tricky and we often have to go back and figure out why.

Explaine exactly why it is needed with traces in the commit message and summarize in a comment.

Got it. I will make changes in the commit log and add backtraces.

Zhu Yanjun

Quoted 2 lines

Jason

Signature · 2 lines
Best Regards,
Yanjun.Zhu
#3 lore raw
In reply to Zhu Yanjun
Quoted 2 lines · Zhu Yanjun

When workqueue_flush is invoked, WQ_MEM_RECLAIM is checked to avoid errors.

This description is too brief and not entirely correct. In the
description of this patch it should be explained that WQ_MEM_RECLAIM must be set for workqueues that are flushed from a work item queued on a WQ_MEM_RECLAIM workqueue or from a memory reclaim context. Otherwise a
deadlock can occur. From kernel/workqueue.c:

/**
* check_flush_dependency - check for flush dependency sanity
* @target_wq: workqueue being flushed
* @target_work: work item being flushed (NULL for workqueue flushes) *
* %current is trying to flush the whole @target_wq or @target_work on it.
* If @target_wq doesn't have %WQ_MEM_RECLAIM, verify that %current is not
* reclaiming memory or running on a workqueue which doesn't have
* %WQ_MEM_RECLAIM as that can break forward-progress guarantee leading to
* a deadlock.
*/

Quoted 3 lines

Since this is a fix, please include a "Fixes:" tag.

Thanks,

Bart.

author
#4 lore raw
Quoted 8 lines · Bart Van Assche
Quoted 2 lines · Zhu Yanjun

When workqueue_flush is invoked, WQ_MEM_RECLAIM is checked to avoid errors.

This description is too brief and not entirely correct. In the
description of this patch it should be explained that WQ_MEM_RECLAIM must be set for workqueues that are flushed from a work item queued on a WQ_MEM_RECLAIM workqueue or from a memory reclaim context. Otherwise a
deadlock can occur. From kernel/workqueue.c:

Yeah. I will make changes to the commit logs based on the above comments.

Thanks for your advice.

Quoted 13 lines

/**
 * check_flush_dependency - check for flush dependency sanity
 * @target_wq: workqueue being flushed
 * @target_work: work item being flushed (NULL for workqueue flushes) *
 * %current is trying to flush the whole @target_wq or @target_work on it.
 * If @target_wq doesn't have %WQ_MEM_RECLAIM, verify that %current is not
 * reclaiming memory or running on a workqueue which doesn't have
 * %WQ_MEM_RECLAIM as that can break forward-progress guarantee leading to
 * a deadlock.
 */

Quoted 5 lines
Quoted 3 lines

Since this is a fix, please include a "Fixes:" tag.

Got it. I will add a "Fixes:" tag.

Best Regards,

Zhu Yanjun

Quoted 5 lines

Thanks,

Bart.

Signature · 2 lines
Best Regards,
Yanjun.Zhu