Re: [PATCH v1 10/14] cxl/extent: Enforce cross-region tag uniqueness
From: Alison Schofield
Date: Mon Nov 30 2026 - 16:02:00 EST
On Thu, Nov 05, 2026 at 08:02:34AM +0900, Anisa Su wrote:
> A tag uuid identifies one allocation across all regions and memdevs,
> but nothing checks a new group's tag against the allocations already
> live on the host: cxlr_add_extent() only compares it with the chain
> group being assembled. The orchestrator owns tag allocation and is
> responsible for global uniqueness, but if a firmware bug or other issue
> causes a repeated tag, the kernel should also reject it.
>
> Add a host-wide list of live tag groups with non-null uuids. Null uuids
> are skipped because untagged extents are not associated with a single
> logical allocation.
>
> Check the list during tag group validation and return -EEXIST if the tag
> is already live on the host via cxl_tag_already_committed(). New tags
> are inserted to the list via cxl_tag_register(), which inserts atomically
> under cxl_tag_lock.
"is already live on the host via cxl_tag_already_committed()" reads as
if the tag were live via that function. Maybe better as ...
Reject a group during validation if its tag is already live on the
host. Register a tag when its group is allocated.
snip
> diff --git a/drivers/cxl/core/extent.c b/drivers/cxl/core/extent.c
> index 334a97ab583d..4a59db823af4 100644
> --- a/drivers/cxl/core/extent.c
> +++ b/drivers/cxl/core/extent.c
> @@ -6,6 +6,54 @@
>
> #include "core.h"
>
> +/*
> + * Host-wide list of live tag groups with non-null uuids: a tag uuid
> + * identifies exactly one allocation across all regions and memdevs.
> + * The orchestrator owns tag allocation; this rejects a repeated tag
> + * from a firmware bug or other issue. Untagged (null uuid) extents are
> + * not tracked: they are not associated with a single allocation.
> + */
> +static DEFINE_MUTEX(cxl_tag_lock);
> +static LIST_HEAD(cxl_tag_groups);
> +
> +static int cxl_tag_register(struct cxl_dc_tag_group *grp)
> +{
> + struct cxl_dc_tag_group *g;
Everywhere else in extent.c a struct cxl_dc_tag_group pointer is called
@group. Can cxl_tag_register() and cxl_tag_unregister() use @group too?
> +
> + if (uuid_is_null(&grp->uuid))
> + return 0;
> +
> + guard(mutex)(&cxl_tag_lock);
> + list_for_each_entry(g, &cxl_tag_groups, registry_node)
> + if (uuid_equal(&g->uuid, &grp->uuid))
> + return -EBUSY;
> + list_add_tail(&grp->registry_node, &cxl_tag_groups);
> + return 0;
> +}
> +
> +static void cxl_tag_unregister(struct cxl_dc_tag_group *grp)
> +{
> + if (uuid_is_null(&grp->uuid))
> + return;
> +
> + guard(mutex)(&cxl_tag_lock);
> + list_del(&grp->registry_node);
> +}
> +
> +bool cxl_tag_already_committed(const uuid_t *tag)
> +{
> + struct cxl_dc_tag_group *g;
> +
> + if (uuid_is_null(tag))
> + return false;
> +
> + guard(mutex)(&cxl_tag_lock);
> + list_for_each_entry(g, &cxl_tag_groups, registry_node)
> + if (uuid_equal(&g->uuid, tag))
> + return true;
> + return false;
> +}
already_commited not really true. The list also holds groups still
being assembled. Wondering if this check is needed, because
cxl_tag_register() arleady refuses dup tag under same lock.
> +
> static struct cxl_dc_tag_group *to_dc_tag_group(struct device *dev)
> {
> return container_of(dev, struct cxl_dc_tag_group, dev);
> @@ -15,6 +63,7 @@ static void dc_tag_group_release(struct device *dev)
> {
> struct cxl_dc_tag_group *group = to_dc_tag_group(dev);
>
> + cxl_tag_unregister(group);
> xa_destroy(&group->dc_extents);
Should the tag be unregistered when the group is torn down, rather than
when its memory is freed? Thinking about deferred release in Patch 6.
snip
> diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
snip
> @@ -1640,6 +1640,22 @@ static int cxl_validate_group(struct cxl_memdev_state *mds, const uuid_t *tag,
> struct device *dev = mds->cxlds.dev;
> struct cxl_extent_list_node *pos;
>
> + /*
> + * Cross-More-chain uniqueness. A non-null tag seen in this group must
> + * not already correspond to a committed tag group anywhere on this
> + * host. More=0 was supposed to close that allocation, and tag uuids
> + * must be unique across all regions and memdevs (the orchestrator owns
> + * assignment per spec). Either constraint failing — same chain
> + * redelivered, or two distinct allocations colliding on the same uuid —
> + * is a firmware/orchestrator bug; reject the whole group.
> + */
> + if (cxl_tag_already_committed(tag)) {
> + dev_warn_ratelimited(dev,
> + "Tag %pUb: dropping group, tag already committed (firmware/orchestrator bug)\n",
> + tag);
> + return -EEXIST;
> + }
Does spec require a tag to be unique across all memdevs of a host?
Where is that section? If it's not 'per spec', let's say so.
> +
> /* Sequence-number integrity */
> if (cxl_check_group_seq(dev, tag, group, shareable))
> return -EINVAL;
> diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h
> index f7d7749d704c..79f5773f8f81 100644
> --- a/drivers/cxl/cxl.h
> +++ b/drivers/cxl/cxl.h
> @@ -642,6 +642,8 @@ struct cxl_dax_region {
> * allocations.
> * @nr_extents: live count of dc_extents in the group; the group is freed
> * when the last dc_extent device is released.
> + * @registry_node: anchor in the host-wide non-null-tag registry that
> + * enforces tag uuid uniqueness across all regions and memdevs.
> */
> struct cxl_dc_tag_group {
> struct device dev;
> @@ -649,6 +651,7 @@ struct cxl_dc_tag_group {
> uuid_t uuid;
> struct xarray dc_extents;
> unsigned int nr_extents;
> + struct list_head registry_node;
> };
>
> bool is_dc_extent(struct device *dev);
> --
> 2.43.0
>