From: Alison Schofield <alison.schofield@intel.com>
To: Anisa Su <anisa.su887@gmail.com>
Cc: <linux-cxl@vger.kernel.org>, <nvdimm@lists.linux.dev>,
<linux-kernel@vger.kernel.org>, Dave Jiang <dave.jiang@intel.com>,
"Jonathan Cameron" <jic23@kernel.org>,
Davidlohr Bueso <dave@stgolabs.net>,
Ira Weiny <iweiny@kernel.org>,
Vishal Verma <vishal.l.verma@intel.com>,
Fan Ni <nifan.cxl@gmail.com>, Li Ming <ming.li@zohomail.com>,
Benjamin Cheatham <benjamin.cheatham@amd.com>,
Gregory Price <gourry@gourry.net>,
Richard Cheng <icheng@nvidia.com>,
Anisa Su <anisa.su@samsung.com>
Subject: Re: [PATCH v1 11/14] cxl/extent: Handle DC Release Capacity events
Date: Mon, 30 Nov 2026 13:31:24 -0800 [thread overview]
Message-ID: <aw3rLA_9Edd97CxL@aschofie-mobl2.lan> (raw)
In-Reply-To: <20261104230445.66625-12-anisa.su@samsung.com>
On Thu, Nov 05, 2026 at 08:02:35AM +0900, Anisa Su wrote:
> From: Ira Weiny <iweiny@kernel.org>
>
> Replace the ack-all stub for Release Capacity chains with the real
> teardown.
>
> Similar to add capacity events, Release Capacity records arrive as a
> More-chain and are staged in mds->dc_chain until the chain closes;
> a chain whose closing record never arrives is dropped by the 20s
> watchdog without a response.
>
> A tag group is one logical allocation, so a well-behaved fabric manager
> is expected to release all members of a tag group together. However,
> CXL r4.0 Section 8.2.10.9.9.4 permits the host to issue an "unsolicited
> release" of extents not corresponding to any event. So as a generous
> policy, the kernel releases all members of a tag group upon receiving a
> Release Capacity record containing any member of the group.
>
> Extents are matched to what the host owns by DPA range and tag. An
> extent not matching any host-owned extent is acknowledged for release
> so the device knows the host is not using it. An extent that overlaps
> owned capacity without matching any host-owned extent by tag and DPA is
> left out of the response so the device keeps the capacity for the host
> and must retry.
Should this also mention that an extent is left ouf of the response
when the cache invalidation fails and if -EBUSY (dax_region's unbind
already owns teardown).
snip
> diff --git a/drivers/cxl/core/extent.c b/drivers/cxl/core/extent.c
snip
> +int cxl_resolve_extent(struct cxl_memdev_state *mds, struct cxl_extent *extent,
> + struct cxl_region **cxlrp,
> + struct cxl_dc_tag_group **groupp)
> +{
> + u64 start_dpa = le64_to_cpu(extent->start_dpa);
> + struct cxl_memdev *cxlmd = mds->cxlds.cxlmd;
> + struct cxl_endpoint_decoder *cxled;
> + struct cxl_dax_region *cxlr_dax;
> + struct dc_extent *dc_extent;
> + struct cxl_region *cxlr;
> + struct range dpa_range;
> + unsigned long idx;
> + uuid_t tag;
> +
> + *cxlrp = NULL;
> + *groupp = NULL;
> +
> + dpa_range = (struct range) {
> + .start = start_dpa,
> + .end = start_dpa + le64_to_cpu(extent->length) - 1,
> + };
Same as Sashiko here wrt a release record w length 0 or a wrapped end.
> +
> + cxlr = cxl_dpa_to_region(cxlmd, start_dpa, &cxled);
> + if (!cxlr)
> + return -ENXIO;
> +
> + cxlr_dax = cxlr->cxlr_dax;
> + if (!cxlr_dax)
> + return -ENXIO;
Same as Sashiko and Richard here wrt releases acknowledged while the
region is being torn down.
> +
> + import_uuid(&tag, extent->uuid);
> +
> + /* RCU keeps entries live during the walk; teardown happens later. */
Is above comment accurate? The group is freed w kfree() so does RCU keep
dc_extent->group live? (I think) same as a Sashiko raised issue.
> + scoped_guard(rcu) {
> + xa_for_each(&cxlr_dax->dc_extents, idx, dc_extent) {
> + if (dc_extent->cxled != cxled)
> + continue;
Can this lookup miss an extent whose tag group belongs to another
region? W the 2-regino tag group raised in Patch 6, every member is
stored in the first regions dc_extents.
> + if (!range_overlaps(&dc_extent->dpa_range, &dpa_range))
> + continue;
> + if (!range_contains(&dc_extent->dpa_range, &dpa_range))
> + return -EINVAL;
> + if (!uuid_equal(&dc_extent->group->uuid, &tag))
> + return -EINVAL;
> + *cxlrp = cxlr;
> + *groupp = dc_extent->group;
> + return 0;
> + }
> + }
> + return -ENXIO;
> +}
> +
> +/**
> + * cxl_release_tag_group() - tear a tag group down for a device release
> + * @cxlr: region owning the group
> + * @group: the group to release
> + *
> + * The caller acknowledges the group to the device as a whole; the group is
> + * dropped without a Release DC of its own.
> + *
> + * Return: 0 when the group is gone, negative when the caller must leave it
> + * intact and let the device retry.
> + */
> +int cxl_release_tag_group(struct cxl_region *cxlr,
> + struct cxl_dc_tag_group *group)
> +{
> + int rc;
> +
> + /*
> + * Invalidate CPU caches for the region before releasing the capacity
> + * back to the device so it cannot reassign the range while stale
> + * cached data lingers. On failure do not release: leave the tag
> + * group intact and let the device retry.
> + */
> + rc = cxl_region_invalidate_memregion(cxlr);
> + if (rc)
> + return rc;
On a host without cache invalidation support, like a guest without
CONFIG_CXL_REGION_INVALIDATION_TEST, this always fails, so every
device-initiated release is held forever and each Release Capacity chain
WARNs. Teardown on the same host releases anyway, as raised on patch 6.
What is the policy we want here?
> +
> + /*
> + * An unbinding dax region has already collected the group's devres
> + * teardown; let that finish the release rather than race it.
> + */
> + if (!rm_tag_group(group))
> + return -EBUSY;
> + return 0;
> +}
> +
> /* The group's device may already be visible: readers walk the xarray under RCU */
> static void cleanup_pending_dc_extent(struct dc_extent *dc_extent)
> {
> diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
> index 0fa501f5800c..c3236fe9e7c5 100644
> --- a/drivers/cxl/core/mbox.c
> +++ b/drivers/cxl/core/mbox.c
> @@ -1747,6 +1747,109 @@ static int cxl_add_pending(struct cxl_memdev_state *mds,
> pending, total_accepted);
> }
>
> +/*
> + * Tear @group down and queue every member on @acks. Members are queued
> + * before rm_tag_group() frees them; on failure nothing is queued and the
> + * group stays intact for the device to retry. Returns the number queued.
> + */
> +static int cxl_release_group(struct cxl_region *cxlr,
> + struct cxl_dc_tag_group *group,
> + struct list_head *acks)
Tidying up needed here. We've got several release group functions now
that are not so crisp in what they actually do:
memdev_release_group() sends a Release DC for the group
(maybe cxl_send_group_release())
cxl_release_group() tears the group down and queues its extents
for the chain's Release DC
(maybe cxl_queue_group_release())
cxl_release_tag_group() flushes caches, then tears the group down
(maybe cxl_flush_rm_tag_group())
rm_tag_group() only tears the group down
(maybe cxl_rm_tag_group())
> +{
> + LIST_HEAD(members);
> + int cnt, rc;
> +
> + cnt = stage_group_release(group, &members);
> + if (cnt < 0)
> + return cnt;
> +
> + rc = cxl_release_tag_group(cxlr, group);
> + if (rc) {
> + drop_extent_group(&members);
> + return rc;
> + }
> +
> + list_splice_tail(&members, acks);
> + return cnt;
> +}
> +
> +/*
> + * Flush a staged Release chain.
> + *
> + * A tag group is one logical allocation: naming any extent of a group
> + * releases the whole group, and members the chain did not name go back as
> + * an unsolicited release (CXL r4.0 9.13.3). Each extent is decided on its
> + * own, so a group that refuses teardown, or an extent that overlaps owned
> + * capacity without naming an owned extent, is held for the device to retry
> + * while the rest proceed. Extents the host is not tracking at all (no
> + * region, no dax region, or nothing owned in range) hold no capacity here
> + * and are acknowledged as named.
> + *
> + * Everything released is acknowledged together in the Release DC response
> + * once the chain is flushed (split across More-chained commands when the
> + * list outgrows the mailbox payload), so a sharable tag is always returned
> + * whole (CXL r4.0 8.2.10.9.9.4).
> + */
> +static int cxl_rm_pending(struct cxl_memdev_state *mds)
> +{
> + struct list_head *pending = &mds->dc_chain.pending_extents;
> + struct device *dev = mds->cxlds.dev;
> + struct cxl_extent_list_node *pos, *tmp;
> + LIST_HEAD(acks);
> + int cnt = 0, rc;
> +
> + /* cxl_resolve_extent() -> cxl_dpa_to_region() walks every decoder's dpa_res */
> + guard(rwsem_read)(&cxl_rwsem.region);
> + guard(rwsem_read)(&cxl_rwsem.dpa);
> +
> + /* Untracked first, before a teardown below makes a sibling look untracked */
> + list_for_each_entry_safe(pos, tmp, pending, list) {
> + struct cxl_dc_tag_group *group;
> + struct cxl_region *cxlr;
> +
> + if (cxl_resolve_extent(mds, pos->extent, &cxlr, &group) != -ENXIO)
> + continue;
> + list_move_tail(&pos->list, &acks);
> + cnt++;
> + }
Should the owned groups get a Release DC of their own? That way a bad
untracked entry can only cuase its own cmd to be rejected.
snip to end
next prev parent reply other threads:[~2026-11-30 21:31 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 23:02 [PATCH v1 00/14] DCD CXL Series: Dynamic Capacity extent handling Anisa Su
2026-11-04 23:02 ` [PATCH v1 01/14] cxl/core: Return endpoint decoder information from region search Anisa Su
2026-11-24 18:31 ` Alison Schofield
2026-11-04 23:02 ` [PATCH v1 02/14] cxl/port: Add dynamic capacity options to endpoint decoder mode Anisa Su
2026-11-17 2:22 ` Jonathan Cameron
2026-11-24 18:36 ` Alison Schofield
2026-11-04 23:02 ` [PATCH v1 03/14] cxl/region: Add dynamic DAX region support Anisa Su
2026-11-17 2:32 ` Jonathan Cameron
2026-11-24 18:55 ` Alison Schofield
2026-11-04 23:02 ` [PATCH v1 04/14] cxl/mem: Introduce DC event handlers Anisa Su
2026-11-17 2:54 ` Jonathan Cameron
2026-11-24 19:29 ` Alison Schofield
2026-11-04 23:02 ` [PATCH v1 05/14] cxl/mem: Add 20 second timeout for stalled DC event chains Anisa Su
2026-11-17 3:00 ` Jonathan Cameron
2026-11-20 20:47 ` Anisa Su
2026-11-24 19:30 ` Alison Schofield
2026-11-04 23:02 ` [PATCH v1 06/14] cxl/extent: Handle DC Add Capacity events Anisa Su
2026-11-12 3:34 ` Richard Cheng
2026-11-16 21:53 ` Anisa Su
2026-11-30 19:54 ` Alison Schofield
2026-11-04 23:02 ` [PATCH v1 07/14] cxl/mem: Drop misaligned DCD extent groups Anisa Su
2026-11-30 19:58 ` Alison Schofield
2026-11-04 23:02 ` [PATCH v1 08/14] cxl/extent: Validate DC extent partition Anisa Su
2026-11-30 20:13 ` Alison Schofield
2026-11-04 23:02 ` [PATCH v1 09/14] cxl/mem: Enforce tag-group semantics Anisa Su
2026-11-30 20:45 ` Alison Schofield
2026-11-04 23:02 ` [PATCH v1 10/14] cxl/extent: Enforce cross-region tag uniqueness Anisa Su
2026-11-30 21:01 ` Alison Schofield
2026-11-04 23:02 ` [PATCH v1 11/14] cxl/extent: Handle DC Release Capacity events Anisa Su
2026-11-12 7:34 ` Richard Cheng
2026-11-30 21:31 ` Alison Schofield [this message]
2026-11-04 23:02 ` [PATCH v1 12/14] cxl/region: Read existing extents on region creation Anisa Su
2026-11-30 22:07 ` Alison Schofield
2026-11-04 23:02 ` [PATCH v1 13/14] cxl/mem: Trace Dynamic capacity Event Record Anisa Su
2026-11-04 23:02 ` [PATCH v1 14/14] Documentation/cxl: Document DCD extent handling Anisa Su
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=aw3rLA_9Edd97CxL@aschofie-mobl2.lan \
--to=alison.schofield@intel.com \
--cc=anisa.su887@gmail.com \
--cc=anisa.su@samsung.com \
--cc=benjamin.cheatham@amd.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=gourry@gourry.net \
--cc=icheng@nvidia.com \
--cc=iweiny@kernel.org \
--cc=jic23@kernel.org \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.li@zohomail.com \
--cc=nifan.cxl@gmail.com \
--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
all inboxes | Powered by JetHome®