From: sashiko-bot@kernel.org
To: "Gregory Price" <gourry@gourry.net>
Cc: nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org
Subject: Re: [PATCH v6 09/10] dax/kmem: add sysfs interface for atomic whole-device hotplug
Date: Tue, 30 Jun 2026 21:32:17 +0000 [thread overview]
Message-ID: <20260630213218.4A90E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260630211842.2252800-10-gourry@gourry.net>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Missing error cleanup in state_store() leaks resource reservations and corrupts state for subsequent unplug operations if dax_kmem_do_hotplug() fails.
--
commit 48ff7b34b13219e34e3823e263b700c3183a5d86
Author: Gregory Price <gourry@gourry.net>
dax/kmem: add sysfs interface for atomic whole-device hotplug
Adds a new 'state' sysfs attribute to daxX.Y devices that allows an atomic
whole-device hotplug operation across its entire memory region. The device
can be transitioned between unplugged, online, online_kernel, and
online_movable states.
> diff --git a/drivers/dax/kmem.c b/drivers/dax/kmem.c
> index 72dcccee41e16..19effe0da3dce 100644
> --- a/drivers/dax/kmem.c
> +++ b/drivers/dax/kmem.c
[ ... ]
> @@ -123,14 +145,14 @@ static int dax_kmem_do_hotplug(struct dev_dax *dev_dax,
> kfree(data->res[i]);
> data->res[i] = NULL;
> }
> - if (onlined)
> + if (added)
> continue;
> return rc;
[Severity: High]
If this fails on the first range (added == 0), it returns immediately.
Since dax_kmem_init_resources() reserves all ranges beforehand, doesn't this
leave reservations for subsequent ranges (i+1 to N) allocated in data->res?
> }
> - onlined++;
> + added++;
> }
>
> - return onlined;
> + return added;
> }
[ ... ]
> @@ -256,6 +309,85 @@ static void dax_kmem_cleanup_resources(struct dev_dax *dev_dax,
[ ... ]
> +static ssize_t state_store(struct device *dev, struct device_attribute *attr,
> + const char *buf, size_t len)
> +{
[ ... ]
> + /* Re-acquire resources if previously unplugged, otherwise no-op */
> + rc = dax_kmem_init_resources(dev_dax, data);
> + if (rc < 0)
> + return rc;
> +
> + rc = dax_kmem_do_hotplug(dev_dax, data, online_type);
> + if (rc < 0)
> + return rc;
[Severity: High]
If dax_kmem_do_hotplug() returns an error here, state_store() returns
directly without calling dax_kmem_cleanup_resources().
If the first range fails to hotplug, does this leave the remaining ranges
reserved but not added?
If the user later writes "unplugged" to sysfs, would dax_kmem_do_hotremove()
attempt to offline and remove memory that was never successfully added to the
hotplug subsystem?
> +
> + data->state = online_type;
> + return len;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260630211842.2252800-1-gourry@gourry.net?part=9
next prev parent reply other threads:[~2026-06-30 21:32 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 21:18 [PATCH v6 00/10] dax/kmem: atomic whole-device hotplug via sysfs Gregory Price
2026-06-30 21:18 ` [PATCH v6 01/10] mm/memory: add memory_block_aligned_range() helper Gregory Price
2026-07-09 17:58 ` Dave Jiang
2026-06-30 21:18 ` [PATCH v6 02/10] mm/memory_hotplug: add mhp_online_type_to_str() and export string helpers Gregory Price
2026-07-01 8:30 ` David Hildenbrand (Arm)
2026-07-09 17:59 ` Dave Jiang
2026-07-09 21:08 ` Dave Jiang
2026-07-09 21:57 ` Gregory Price
2026-07-10 12:44 ` David Hildenbrand (Arm)
2026-06-30 21:18 ` [PATCH v6 03/10] mm/memory_hotplug: pass online_type to online_memory_block() via arg Gregory Price
2026-07-09 18:22 ` Dave Jiang
2026-06-30 21:18 ` [PATCH v6 04/10] mm/memory_hotplug: export mhp_get_default_online_type Gregory Price
2026-07-09 18:30 ` Dave Jiang
2026-06-30 21:18 ` [PATCH v6 05/10] mm/memory_hotplug: add __add_memory_driver_managed() with online_type arg Gregory Price
2026-07-09 18:48 ` Dave Jiang
2026-06-30 21:18 ` [PATCH v6 06/10] mm/memory_hotplug: add offline_and_remove_memory_ranges() Gregory Price
2026-07-01 8:32 ` David Hildenbrand (Arm)
2026-07-09 8:45 ` Richard Cheng
2026-07-09 15:06 ` Gregory Price
2026-07-09 17:15 ` Gregory Price
2026-07-09 18:53 ` Dave Jiang
2026-06-30 21:18 ` [PATCH v6 07/10] dax: plumb hotplug online_type through dax Gregory Price
2026-07-09 21:07 ` Dave Jiang
2026-07-09 21:46 ` Dan Williams (nvidia)
2026-07-09 22:08 ` Gregory Price
2026-07-10 1:30 ` Gregory Price
2026-07-11 0:44 ` Dan Williams (nvidia)
2026-07-12 13:19 ` Gregory Price
2026-07-12 13:27 ` Gregory Price
2026-06-30 21:18 ` [PATCH v6 08/10] dax/kmem: extract hotplug/hotremove helper functions Gregory Price
2026-07-09 21:44 ` Dave Jiang
2026-07-09 21:57 ` Gregory Price
2026-06-30 21:18 ` [PATCH v6 09/10] dax/kmem: add sysfs interface for atomic whole-device hotplug Gregory Price
2026-06-30 21:32 ` sashiko-bot [this message]
2026-06-30 22:14 ` Gregory Price
2026-07-01 6:13 ` Hannes Reinecke
2026-07-01 6:23 ` Gregory Price
2026-07-09 8:07 ` Richard Cheng
2026-07-09 14:57 ` Gregory Price
2026-07-09 22:14 ` Dave Jiang
2026-07-09 22:22 ` Gregory Price
2026-07-09 22:36 ` Dan Williams (nvidia)
2026-07-09 23:06 ` Gregory Price
2026-07-09 23:57 ` Dan Williams (nvidia)
2026-07-10 3:08 ` Gregory Price
2026-06-30 21:18 ` [PATCH v6 10/10] selftests/dax: add dax/kmem hotplug sysfs regression test Gregory Price
2026-07-09 8:20 ` Richard Cheng
2026-07-09 15:02 ` Gregory Price
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=20260630213218.4A90E1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=gourry@gourry.net \
--cc=linux-cxl@vger.kernel.org \
--cc=nvdimm@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.