From: "Cheatham, Benjamin" <benjamin.cheatham@amd.com>
To: 차준호 <junho.cha@xcena.com>, "Dave Jiang" <dave.jiang@intel.com>,
"linux-cxl@vger.kernel.org" <linux-cxl@vger.kernel.org>
Cc: Davidlohr Bueso <dave@stgolabs.net>,
Jonathan Cameron <jic23@kernel.org>,
Alison Schofield <alison.schofield@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
Ira Weiny <iweiny@kernel.org>, Li Ming <ming.li@zohomail.com>,
Alejandro Lucero <alucerop@amd.com>,
Richard Cheng <icheng@nvidia.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] cxl/region: Fix self-deadlock when cxl_memdev_attach_region() fails
Date: Wed, 18 Nov 2026 11:43:34 -0600 [thread overview]
Message-ID: <4c1a43e7-9f73-4a1b-a954-534072baa7ec@amd.com> (raw)
In-Reply-To: <SE1P216MB2499A0F74C7505ED91303105F67A2@SE1P216MB2499.KORP216.PROD.OUTLOOK.COM>
On 11/17/2026 8:36 PM, 차준호 wrote:
> [You don't often get email from junho.cha@xcena.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> On Tue, Nov 17, 2026 at 03:49:39PM -0600, Cheatham, Benjamin wrote:
>> On 11/16/2026 8:59 PM, Junho Cha via B4 Relay wrote:
>>> The task then waits for a write lock while holding the same rwsem for
>>> read, and never makes progress. Before it hangs, lockdep also reports
>>> a circular dependency: endpoint_unregister_region() takes
>>> cxlrd->regions_lock under cxl_rwsem.dpa, while cxl_add_to_region()
>>> takes cxlrd->regions_lock before both rwsems.
>>
>> I don't think the lockdep dependency is related to this, it's in a completely
>> different code path. That said, it may be fixable by converting the guard() on
>> the cxlrd->regions_lock in cxl_add_to_region() to a scoped_guard().
>
> Hi Ben,
>
> Thanks for the review.
>
> The report does come from this failure path. The new dependency is
> endpoint_unregister_region() taking regions_lock while
> cxl_memdev_attach_region() still holds both rwsems:
>
> -> #0 (&cxlrd->regions_lock){+.+.}-{4:4}:
> endpoint_unregister_region+0x2a/0x60 [cxl_core]
> cxl_memdev_attach_region+0x1ca/0x200 [cxl_core]
>
> It goes away with the fix, and changing cxl_add_to_region() would not
> fix the hang itself. I'll make that clearer in the changelog.
>
Sorry I should've been clearer, I meant the circular dependency isn't related
to the hang.
I think I just missed the part at the end of the commit message where you mention the
lockdep warning goes away. That was reader error and looking at it again it's pretty clear.
If you feel the need to do something go ahead, but it's probably fine as-is.
>> I think this could cause an issue if you have multiple type 2 cards in the same region. Imagine this scenario:
> [...]
>> 3. The second card then successfully adds the action and passes back an HPA range attached to a dead region
>
> Two cards can't share the region here, since nr_targets > 1 is
> rejected. But the window is real with one card: with a delay added
> before the registration, writing to region0/target0 detached the
> target before the action was registered, and the attach still
> returned the region's range.
>
I forgot about that restriction, good to see you can still hit that though!
>> Maybe you can get past this by keeping just the cxl_rwsem.dpa lock through the end of the function? I don't
>> know if that's too hacky, but I don't recall seeing the dpa lock taken by anything after endpoint_unregister_region()
>> gets called so it may work.
>
> Detaching a target doesn't take cxl_rwsem.dpa, so that wouldn't close
> the window, and the unwind would again take regions_lock under it.
>
Good point, I was thinking about preventing two concurrent type 2 devices racing but that's
not applicable here. Makes sense that it wouldn't work in the case you have above.
Thanks,
Ben
> In v2 I'll register the action under both rwsems as before, with
> devm_add_action(), and run the unwind only after dropping them.
>
prev parent reply other threads:[~2026-11-18 17:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 2:59 Junho Cha via B4 Relay
2026-11-17 8:08 ` Lucero Palau, Alejandro
2026-11-17 21:49 ` Cheatham, Benjamin
2026-11-18 2:36 ` 차준호
2026-11-18 17:43 ` Cheatham, Benjamin [this message]
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=4c1a43e7-9f73-4a1b-a954-534072baa7ec@amd.com \
--to=benjamin.cheatham@amd.com \
--cc=alison.schofield@intel.com \
--cc=alucerop@amd.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=icheng@nvidia.com \
--cc=iweiny@kernel.org \
--cc=jic23@kernel.org \
--cc=junho.cha@xcena.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.li@zohomail.com \
--cc=vishal.l.verma@intel.com \
/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
all inboxes | Powered by JetHome®