From: Jonathan Cameron <jonathan.cameron@huawei.com>
To: Dave Jiang <dave.jiang@intel.com>
Cc: <nvdimm@lists.linux.dev>, <linux-cxl@vger.kernel.org>,
<dan.j.williams@intel.com>, <vishal.l.verma@intel.com>,
<ira.weiny@intel.com>
Subject: Re: [PATCH] dax/hmem: Fix lockdep warning for hmem_register_resource()
Date: Tue, 7 Oct 2025 15:52:27 +0100 [thread overview]
Message-ID: <20251007155227.00003bbe@huawei.com> (raw)
In-Reply-To: <20251007001252.2710860-1-dave.jiang@intel.com>
> The lock ordering can cause potential deadlock. There are instances
> where hmem_resource_lock is taken after (node_chain).rwsem, and vice
> versa. Narrow the scope of hmem_resource_lock in hmem_register_resource()
> to avoid the circular locking dependency. The locking is only needed when
> hmem_active needs to be protected.
>
> Fixes: 7dab174e2e27 ("dax/hmem: Move hmem device registration to dax_hmem.ko")
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
One trivial thing...
> ---
> drivers/dax/hmem/device.c | 42 +++++++++++++++++++++++----------------
> 1 file changed, 25 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/dax/hmem/device.c b/drivers/dax/hmem/device.c
> index f9e1a76a04a9..ab5977d75d1f 100644
> --- a/drivers/dax/hmem/device.c
> +++ b/drivers/dax/hmem/device.c
> @@ -33,21 +33,37 @@ int walk_hmem_resources(struct device *host, walk_hmem_fn fn)
> }
> EXPORT_SYMBOL_GPL(walk_hmem_resources);
>
> -static void __hmem_register_resource(int target_nid, struct resource *res)
> +static struct resource *hmem_request_resource(int target_nid,
> + struct resource *res)
> {
> - struct platform_device *pdev;
> struct resource *new;
> - int rc;
>
> - new = __request_region(&hmem_active, res->start, resource_size(res), "",
> - 0);
> + guard(mutex)(&hmem_resource_lock);
> + new = __request_region(&hmem_active, res->start,
> + resource_size(res), "", 0);
Why the rewrap? Arguably it is slightly prettier but original was 80 chars
(I think) and making this change adds noise to the real code in this patch.
> if (!new) {
> pr_debug("hmem range %pr already active\n", res);
> - return;
> + return ERR_PTR(-ENOMEM);
> }
>
> new->desc = target_nid;
>
> + return new;
> +}
prev parent reply other threads:[~2025-10-07 14:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-07 0:12 [PATCH] dax/hmem: Fix lockdep warning for hmem_register_resource() Dave Jiang
2025-10-07 1:16 ` dan.j.williams
2025-10-07 16:04 ` Ira Weiny
2025-10-07 16:11 ` Dave Jiang
2025-10-07 14:52 ` Jonathan Cameron [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=20251007155227.00003bbe@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=ira.weiny@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=nvdimm@lists.linux.dev \
--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