All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alison Schofield <alison.schofield@intel.com>
To: Richard Cheng <icheng@nvidia.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>,
	Jonathan Cameron <jic23@kernel.org>,
	Dave Jiang <dave.jiang@intel.com>,
	Vishal Verma <vishal.l.verma@intel.com>,
	Ira Weiny <iweiny@kernel.org>, Li Ming <ming.li@zohomail.com>,
	<linux-cxl@vger.kernel.org>
Subject: Re: [PATCH v4 4/9] cxl/region: Calculate peer distance only for reused targets
Date: Mon, 19 Oct 2026 12:53:56 -0700	[thread overview]
Message-ID: <atZ1VABsLShhEPm4@aschofie-mobl2.lan> (raw)
In-Reply-To: <atXHAZIgcNlLURSx@MWDK4CY14F>

On Mon, Oct 19, 2026 at 03:31:29PM +0800, Richard Cheng wrote:
> On Sat, Oct 17, 2026 at 12:19:49PM +0800, Alison Schofield wrote:
> > From: Richard Cheng <icheng@nvidia.com>
> > 
> > cxl_switch_port_setup_targets() calculates peer distance before
> > searching the existing targets. When the endpoint needs a new target,
> > the calculated distance is never used.
> > 
> > Move cxl_port_peer_distance() into the matching-target branch,
> > immediately before check_last_peer(). This avoids unnecessary ancestor
> > walks and per-port region lookups when adding distinct targets.

With cxl_test, the x8 region in cxl-region-sysfs.sh reduces calls to
cxl_port_peer_distance() from 10 to 4, and the x2 auto region from 2
to 1. A misordered-endpoint test confirms that peer validation still
rejects mismatched peers.


> > 
> > Signed-off-by: Richard Cheng <icheng@nvidia.com>
> > Tested-by: Alison Schofield <alison.schofield@intel.com>
> > Signed-off-by: Alison Schofield <alison.schofield@intel.com>
> 
> Hi Alison,
> 
> Really appreciate for the testing and if we can, can we add the testing result
> in the commit message demonstrate benefit it can bring us ?

Added the above for v5, taken from:
https://lore.kernel.org/linux-cxl/atLBlibv3kbT7xv5@aschofie-mobl2.lan/) 

Let me know if you want something else.

-- Alison

> 
> Best regards,
> Richard Cheng.
> 
> 
> > ---
> >  drivers/cxl/core/region.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> > index 4ab5a1d025a9..8bfebe3e1025 100644
> > --- a/drivers/cxl/core/region.c
> > +++ b/drivers/cxl/core/region.c
> > @@ -1485,10 +1485,10 @@ static int cxl_switch_port_setup_targets(struct cxl_switch_decoder *cxlsd,
> >  	}
> >  
> >  	if (cxl_rr->nr_targets_set) {
> > -		int distance = cxl_port_peer_distance(port, cxlr);
> > -
> >  		for (int i = 0; i < cxl_rr->nr_targets_set; i++)
> >  			if (ep->dport == cxlsd->target[i]) {
> > +				int distance = cxl_port_peer_distance(port, cxlr);
> > +
> >  				rc = check_last_peer(cxled, ep, cxl_rr,
> >  						     distance);
> >  				if (rc)
> > -- 
> > 2.37.3
> > 

  reply	other threads:[~2026-10-19 19:54 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-17 19:19 [PATCH v4 0/9] cxl/region: Refactor cxl_port_setup_targets() Alison Schofield
2026-10-17 19:19 ` [PATCH v4 1/9] cxl: Add interleave encoding validity helpers Alison Schofield
2026-10-17 19:19 ` [PATCH v4 2/9] cxl/region: Rename cxl_port_setup_targets() to cxl_switch_port_setup_targets() Alison Schofield
2026-10-17 19:19 ` [PATCH v4 3/9] cxl/region: Factor out cxl_port_peer_distance() Alison Schofield
2026-10-17 19:19 ` [PATCH v4 4/9] cxl/region: Calculate peer distance only for reused targets Alison Schofield
2026-10-19  7:31   ` Richard Cheng
2026-10-19 19:53     ` Alison Schofield [this message]
2026-10-20  1:24   ` Jonathan Cameron
2026-10-20  2:29   ` Li Ming
2026-10-17 19:19 ` [PATCH v4 5/9] cxl/region: Factor out cxl_port_parent_interleave() Alison Schofield
2026-10-17 19:19 ` [PATCH v4 6/9] cxl/region: Factor out cxl_port_calc_interleave() Alison Schofield
2026-10-17 19:28 ` [PATCH v4 7/9] cxl/region: Factor out cxl_port_setup_decoder() Alison Schofield
2026-10-20  1:26   ` Jonathan Cameron
2026-10-17 19:28 ` [PATCH v4 8/9] cxl/region: Simplify switch port target setup control flow Alison Schofield
2026-10-20  1:27   ` Jonathan Cameron
2026-10-20  2:33   ` Li Ming
2026-10-17 19:28 ` [PATCH v4 9/9] cxl/region: Factor out cxl_switch_port_add_target() Alison Schofield
2026-10-20  1:28   ` Jonathan Cameron

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=atZ1VABsLShhEPm4@aschofie-mobl2.lan \
    --to=alison.schofield@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dave@stgolabs.net \
    --cc=icheng@nvidia.com \
    --cc=iweiny@kernel.org \
    --cc=jic23@kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=ming.li@zohomail.com \
    --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 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.