From: Jason Gunthorpe <jgg@ziepe.ca>
To: wujing <realwujing@qq.com>
Cc: Leon Romanovsky <leon@kernel.org>,
linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
Qiliang Yuan <yuanql9@chinatelecom.cn>
Subject: Re: [PATCH] IB/core: Fix ABBA deadlock in rdma_dev_exit_net
Date: Mon, 15 Dec 2025 20:57:05 -0400 [thread overview]
Message-ID: <20251216005705.GB31492@ziepe.ca> (raw)
In-Reply-To: <tencent_96252FF6CE27E9F41F13AC73CCC1BE350905@qq.com>
On Thu, Dec 11, 2025 at 04:08:13PM +0800, wujing wrote:
> Classic ABBA deadlock due to inconsistent lock ordering between
> rdma_dev_exit_net() and rdma_dev_init_net():
>
> Thread A (cleanup_net workqueue -> kworker/u256:1):
> rdma_dev_exit_net():
> down_write(&rdma_nets_rwsem) <- held at line rdma_dev_exit_net+0x60
> down_read(&devices_rwsem) <- waiting (shown in rwsem_down_write_slowpath)
This isn't right, it unlocked the &rdma_nets_rwsem:
down_write(&rdma_nets_rwsem);
/*
* Prevent the ID from being re-used and hide the id from xa_for_each.
*/
ret = xa_err(xa_store(&rdma_nets, rnet->id, NULL, GFP_KERNEL));
WARN_ON(ret);
up_write(&rdma_nets_rwsem); <------
down_read(&devices_rwsem);
It is not nested and there is not a dependency.
> Thread B (stress-ng-clone processes):
> rdma_dev_init_net():
> down_read(&devices_rwsem) <- held at line rdma_dev_init_net+0x120
> down_read(&rdma_nets_rwsem) <- waiting (blocked by pending writer from Thread A)
This one is nested though.
I don't know what your bug is, but it is not some trivial ABBA
deadlock, lockdep would have found something like that ages ago.
Jason
next prev parent reply other threads:[~2025-12-16 0:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-11 8:08 [PATCH] IB/core: Fix ABBA deadlock in rdma_dev_exit_net wujing
2025-12-16 0:57 ` Jason Gunthorpe [this message]
2025-12-16 9:59 ` wujing
2025-12-16 13:59 ` Michael Gur
2025-12-16 14:22 ` Jason Gunthorpe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251216005705.GB31492@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=realwujing@qq.com \
--cc=yuanql9@chinatelecom.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox