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 09/14] cxl/mem: Enforce tag-group semantics
Date: Mon, 30 Nov 2026 12:45:39 -0800	[thread overview]
Message-ID: <aw3gc1ObD_K05Rn0@aschofie-mobl2.lan> (raw)
In-Reply-To: <20261104230445.66625-10-anisa.su@samsung.com>

On Thu, Nov 05, 2026 at 08:02:33AM +0900, Anisa Su wrote:
> The previous commits added validation for individual extents.  Add
> two group-level checks to cxl_validate_group():


"The previous commits" depends on the series order.
How about something like this "Individual extents are validated as
they are added, but some rules apply to a tag group as a whole."


> 
>   - Sequence integrity (cxl_check_group_seq): sharability is taken from
>     the group's DC partition attribute (cxl_group_is_shareable).
> 
>     For a sharable partition, extents have a shared_extn_seq number,
>     which must be 0..n-1 for a tag. Any gaps or duplicate values are an
>     error.
> 
>     The field is reserved for non-sharable extents, and
>     cxl_validate_extent() rejects a non-zero value there when the group
>     is realized.  Therefore, cxl_check_group_seq only applies to
>     sharable groups.


Table 8-30 says field shall be 0, not reserved.

> 
>   - cxl_check_group_partition: verify tagged allocations
>     don't span DC partitions.


Func names in changelog read better w parens.
Use parens, or describe the checks without naming the helpers.


> 
> Each check drops the whole group on violation.
> 
> Tag uniqueness checks land in a subsequent commit.


This depends on the series order too. Perhaps drop or say
"Tag uniqueness is enforced separately."

snip
>  drivers/cxl/core/mbox.c | 138 ++++++++++++++++++++++++++++++++++++++--
snip


> +/*
> + * For tagged groups, reject allocations that span DC partitions.  A tag
> + * is an allocation identity; the partition's CDAT DSMAS entry is what
> + * tells the host which attributes (sharable, writable, coherency)
> + * apply.  Untagged groups are skipped — the spec does not define a
> + * cross-chain identity for them.
> + */
> +static int cxl_check_group_partition(struct cxl_memdev_state *mds,
> +				     const uuid_t *tag,
> +				     const struct list_head *group)
> +{
> +	struct device *dev = mds->cxlds.dev;
> +	const struct cxl_dpa_partition *first_part = NULL;
> +	u64 first_dpa = 0;
> +	struct cxl_extent_list_node *pos;


Reverse fir tree order please.


> +
> +	if (uuid_is_null(tag) || list_empty(group))
> +		return 0;
> +
> +	list_for_each_entry(pos, group, list) {
> +		struct cxl_extent *extent = pos->extent;
> +		struct range ext_range = (struct range) {
> +			.start = le64_to_cpu(extent->start_dpa),
> +			.end = le64_to_cpu(extent->start_dpa) +
> +				le64_to_cpu(extent->length) - 1,
> +		};
> +		const struct cxl_dpa_partition *part;
> +
> +		part = cxl_extent_dc_partition(mds, extent, &ext_range);
> +		if (!part)
> +			return -ENXIO;


Maybe the partition can be looked up once per extent?
With cxl_group_is_shareable() and cxl_validate_extent() this is up to
three lookups, and an extent outside every DC partition is logged twice.


> +
> +		if (!first_part) {
> +			first_part = part;
> +			first_dpa = ext_range.start;
> +			continue;
> +		}
> +
> +		if (part != first_part) {
> +			dev_warn_ratelimited(dev,
> +					     "Tag %pUb: extents span DC partitions (DPA:%#llx and DPA:%#llx), firmware bug\n",
> +					     tag, first_dpa, ext_range.start);
> +			return -EINVAL;
> +		}
> +	}
> +	return 0;
> +}


Should this also catch the 2 region case raised in patch 6?



> +
>  /*
>   * Realize a tag @group: assign each extent its dax-side @seq_num and add it
>   * via cxl_add_extent(), then online the resulting tag group.  Returns the
> @@ -1460,7 +1573,7 @@ static void extract_tag_group(struct list_head *pending,
>   * the caller to drop.
>   */
>  static int cxl_realize_group(struct cxl_memdev_state *mds, const uuid_t *tag,
> -			     struct list_head *group)
> +			     struct list_head *group, bool shareable)
>  {
>  	struct device *dev = mds->cxlds.dev;
>  	struct cxl_extent_list_node *pos;
> @@ -1475,7 +1588,12 @@ static int cxl_realize_group(struct cxl_memdev_state *mds, const uuid_t *tag,
>  	/* Each extent gets a dense dax-side seq_num, 0..n-1 */
>  	seq_num = -1;
>  	list_for_each_entry(pos, group, list) {
> -		seq_num++;
> +		/* Sharable: device-assigned dense 0..n-1; otherwise by arrival */
> +		if (shareable)
> +			seq_num = le16_to_cpu(pos->extent->shared_extn_seq);
> +		else
> +			seq_num++;
> +
>  		rc = cxl_add_extent(mds, pos->extent, seq_num);


Is shareable branch above needed? The group is already sorted by
shared_extn_seq and checked to be 0..n-1, so seq_num++ gives each
extent its shared_extn_seq anyway.


>  		if (rc < 0) {
>  			dev_dbg(dev,
> @@ -1517,11 +1635,19 @@ static int cxl_realize_group(struct cxl_memdev_state *mds, const uuid_t *tag,
>   * added, or a negative errno if it must be dropped.
>   */
>  static int cxl_validate_group(struct cxl_memdev_state *mds, const uuid_t *tag,
> -			      struct list_head *group)
> +			      struct list_head *group, bool shareable)
>  {
>  	struct device *dev = mds->cxlds.dev;
>  	struct cxl_extent_list_node *pos;
>  
> +	/* Sequence-number integrity */
> +	if (cxl_check_group_seq(dev, tag, group, shareable))
> +		return -EINVAL;
> +
> +	/* Partition equality (skipped for null UUID) */
> +	if (cxl_check_group_partition(mds, tag, group))
> +		return -EINVAL;
> +
>  	/* Alignment gate — drop the group if any member fails */
>  	list_for_each_entry(pos, group, list) {
>  		if (!cxl_extent_dcd_aligned(pos->extent)) {
> @@ -1559,6 +1685,7 @@ static int cxl_add_pending(struct cxl_memdev_state *mds,
>  	while (!list_empty(pending)) {
>  		struct cxl_extent_list_node *first;
>  		LIST_HEAD(group);
> +		bool shareable;
>  		uuid_t tag;
>  		int cnt;
>  
> @@ -1581,13 +1708,14 @@ static int cxl_add_pending(struct cxl_memdev_state *mds,
>  		 * the stable sort maintains arrival order.
>  		 */
>  		list_sort(NULL, &group, extent_seq_compare);
> +		shareable = cxl_group_is_shareable(mds, &group);
>  
> -		if (cxl_validate_group(mds, &tag, &group)) {
> +		if (cxl_validate_group(mds, &tag, &group, shareable)) {
>  			drop_extent_group(&group);
>  			continue;
>  		}
>  
> -		cnt = cxl_realize_group(mds, &tag, &group);
> +		cnt = cxl_realize_group(mds, &tag, &group, shareable);
>  		if (cnt < 0) {
>  			drop_extent_group(&group);
>  			continue;
> -- 
> 2.43.0
> 

  reply	other threads:[~2026-11-30 20:46 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 [this message]
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
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=aw3gc1ObD_K05Rn0@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®