mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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 10/14] cxl/extent: Enforce cross-region tag uniqueness
Date: Mon, 30 Nov 2026 13:01:40 -0800	[thread overview]
Message-ID: <aw3kND2j37PJowuI@aschofie-mobl2.lan> (raw)
In-Reply-To: <20261104230445.66625-11-anisa.su@samsung.com>

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
> 

  reply	other threads:[~2026-11-30 21:01 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 [this message]
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
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=aw3kND2j37PJowuI@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®