[PATCH] IB/cm: Remove redundant WARN_ON in cm_free_priv_msg

Li Zhijian posted 1 patch 9 months ago
drivers/infiniband/core/cm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] IB/cm: Remove redundant WARN_ON in cm_free_priv_msg
Posted by Li Zhijian 9 months ago
Sometimes, the blktests triggered this WARN_ON():
 ------------[ cut here ]------------
 WARNING: CPU: 3 PID: 1330889 at cm.c:353 cm_free_priv_msg+0xaa/0xc0 [ib_cm]
...
 CPU: 3 UID: 0 PID: 1330889 Comm: kworker/u16:1 Tainted: G        W  OE      6.13.0-rc3+ #3
 Tainted: [W]=WARN, [O]=OOT_MODULE, [E]=UNSIGNED_MODULE
 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.16.3-0-ga6ed6b701f0a-prebuilt.qemu.org 04/01/2014
 Workqueue: ib_mad1 timeout_sends [ib_core]
 RIP: 0010:cm_free_priv_msg+0xaa/0xc0 [ib_cm]
...
 Call Trace:
  <TASK>
  ? cm_free_priv_msg+0xaa/0xc0 [ib_cm]
  ? __warn.cold+0x93/0xfa
  ? cm_free_priv_msg+0xaa/0xc0 [ib_cm]
  ? report_bug+0xff/0x140
  ? handle_bug+0x58/0x90
  ? exc_invalid_op+0x17/0x70
  ? asm_exc_invalid_op+0x1a/0x20
  ? cm_free_priv_msg+0xaa/0xc0 [ib_cm]
  cm_process_send_error+0x64/0x1f0 [ib_cm]
  timeout_sends+0x1e5/0x2d0 [ib_core]
  process_one_work+0x156/0x310
  worker_thread+0x252/0x390
  ? __pfx_worker_thread+0x10/0x10
  kthread+0xd2/0x100
  ? __pfx_kthread+0x10/0x10
  ret_from_fork+0x34/0x50
  ? __pfx_kthread+0x10/0x10
  ret_from_fork_asm+0x1a/0x30
  </TASK>
 ---[ end trace 0000000000000000 ]---

In cm_process_send_error(), cm_free_priv_msg() will be called
when (msg != cm_id_priv->msg) is true. And all other calling to
cm_free_priv_msg() cases, msg is always the same as cm_id_priv->msg.

So it's safe to remove this WARN_ON

Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
---
 drivers/infiniband/core/cm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index 142170473e75..1a8e5b0e4d85 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -350,7 +350,7 @@ static void cm_free_priv_msg(struct ib_mad_send_buf *msg)
 
 	lockdep_assert_held(&cm_id_priv->lock);
 
-	if (!WARN_ON(cm_id_priv->msg != msg))
+	if (cm_id_priv->msg == msg)
 		cm_id_priv->msg = NULL;
 
 	if (msg->ah)
-- 
2.44.0
Re: [PATCH] IB/cm: Remove redundant WARN_ON in cm_free_priv_msg
Posted by Leon Romanovsky 9 months ago
On Fri, May 09, 2025 at 04:18:40PM +0800, Li Zhijian wrote:
> Sometimes, the blktests triggered this WARN_ON():
>  ------------[ cut here ]------------
>  WARNING: CPU: 3 PID: 1330889 at cm.c:353 cm_free_priv_msg+0xaa/0xc0 [ib_cm]
> ...
>  CPU: 3 UID: 0 PID: 1330889 Comm: kworker/u16:1 Tainted: G        W  OE      6.13.0-rc3+ #3
>  Tainted: [W]=WARN, [O]=OOT_MODULE, [E]=UNSIGNED_MODULE
>  Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.16.3-0-ga6ed6b701f0a-prebuilt.qemu.org 04/01/2014
>  Workqueue: ib_mad1 timeout_sends [ib_core]
>  RIP: 0010:cm_free_priv_msg+0xaa/0xc0 [ib_cm]
> ...
>  Call Trace:
>   <TASK>
>   ? cm_free_priv_msg+0xaa/0xc0 [ib_cm]
>   ? __warn.cold+0x93/0xfa
>   ? cm_free_priv_msg+0xaa/0xc0 [ib_cm]
>   ? report_bug+0xff/0x140
>   ? handle_bug+0x58/0x90
>   ? exc_invalid_op+0x17/0x70
>   ? asm_exc_invalid_op+0x1a/0x20
>   ? cm_free_priv_msg+0xaa/0xc0 [ib_cm]
>   cm_process_send_error+0x64/0x1f0 [ib_cm]
>   timeout_sends+0x1e5/0x2d0 [ib_core]
>   process_one_work+0x156/0x310
>   worker_thread+0x252/0x390
>   ? __pfx_worker_thread+0x10/0x10
>   kthread+0xd2/0x100
>   ? __pfx_kthread+0x10/0x10
>   ret_from_fork+0x34/0x50
>   ? __pfx_kthread+0x10/0x10
>   ret_from_fork_asm+0x1a/0x30
>   </TASK>
>  ---[ end trace 0000000000000000 ]---
> 
> In cm_process_send_error(), cm_free_priv_msg() will be called
> when (msg != cm_id_priv->msg) is true. And all other calling to
> cm_free_priv_msg() cases, msg is always the same as cm_id_priv->msg.
> 
> So it's safe to remove this WARN_ON

This patch should fix the issue.
https://lore.kernel.org/all/0c364c29142f72b7875fdeba51f3c9bd6ca863ee.1745839788.git.leon@kernel.org/
7590649ee7af ("IB/cm: Drop lockdep assert and WARN when freeing old msg")

Thanks
Re: [PATCH] IB/cm: Remove redundant WARN_ON in cm_free_priv_msg
Posted by Zhijian Li (Fujitsu) 9 months ago

On 12/05/2025 18:53, Leon Romanovsky wrote:
> On Fri, May 09, 2025 at 04:18:40PM +0800, Li Zhijian wrote:
>> Sometimes, the blktests triggered this WARN_ON():
>>   ------------[ cut here ]------------
>>   WARNING: CPU: 3 PID: 1330889 at cm.c:353 cm_free_priv_msg+0xaa/0xc0 [ib_cm]
>> ...
>>   CPU: 3 UID: 0 PID: 1330889 Comm: kworker/u16:1 Tainted: G        W  OE      6.13.0-rc3+ #3
>>   Tainted: [W]=WARN, [O]=OOT_MODULE, [E]=UNSIGNED_MODULE
>>   Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.16.3-0-ga6ed6b701f0a-prebuilt.qemu.org 04/01/2014
>>   Workqueue: ib_mad1 timeout_sends [ib_core]
>>   RIP: 0010:cm_free_priv_msg+0xaa/0xc0 [ib_cm]
>> ...
>>   Call Trace:
>>    <TASK>
>>    ? cm_free_priv_msg+0xaa/0xc0 [ib_cm]
>>    ? __warn.cold+0x93/0xfa
>>    ? cm_free_priv_msg+0xaa/0xc0 [ib_cm]
>>    ? report_bug+0xff/0x140
>>    ? handle_bug+0x58/0x90
>>    ? exc_invalid_op+0x17/0x70
>>    ? asm_exc_invalid_op+0x1a/0x20
>>    ? cm_free_priv_msg+0xaa/0xc0 [ib_cm]
>>    cm_process_send_error+0x64/0x1f0 [ib_cm]
>>    timeout_sends+0x1e5/0x2d0 [ib_core]
>>    process_one_work+0x156/0x310
>>    worker_thread+0x252/0x390
>>    ? __pfx_worker_thread+0x10/0x10
>>    kthread+0xd2/0x100
>>    ? __pfx_kthread+0x10/0x10
>>    ret_from_fork+0x34/0x50
>>    ? __pfx_kthread+0x10/0x10
>>    ret_from_fork_asm+0x1a/0x30
>>    </TASK>
>>   ---[ end trace 0000000000000000 ]---
>>
>> In cm_process_send_error(), cm_free_priv_msg() will be called
>> when (msg != cm_id_priv->msg) is true. And all other calling to
>> cm_free_priv_msg() cases, msg is always the same as cm_id_priv->msg.
>>
>> So it's safe to remove this WARN_ON
> 
> This patch should fix the issue.
> https://lore.kernel.org/all/0c364c29142f72b7875fdeba51f3c9bd6ca863ee.1745839788.git.leon@kernel.org/
> 7590649ee7af ("IB/cm: Drop lockdep assert and WARN when freeing old msg")


Yeah, thanks for this information.



> 
> Thanks