mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Richard Cheng <icheng@nvidia.com>
Cc: dave@stgolabs.net, dave.jiang@intel.com,
	alison.schofield@intel.com, vishal.l.verma@intel.com,
	iweiny@kernel.org, ming.li@zohomail.com, gourry@gourry.net,
	rrichter@amd.com, linux-cxl@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH] cxl/region: Calculate peer distance only for reused targets
Date: Fri, 16 Oct 2026 19:23:05 +0100	[thread overview]
Message-ID: <20261016192305.1d1e01c5@jic23-hlaptop> (raw)
In-Reply-To: <20261015094059.46818-1-icheng@nvidia.com>

On Thu, 15 Oct 2026 17:40:59 +0800
Richard Cheng <icheng@nvidia.com> wrote:

> This patch depends on Alison Schofield's v3 "cxl/region: Refactor
> cxl_port_setup_targets()" series [1], this is inspired from that serie

series is a an odd word in English. Singular and plural are the same.

> as well, since her serie contains no functional change, I pull this one
> out as a standalone patch.
> 
> 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.
> 
> [1]:
> https://lore.kernel.org/linux-cxl/cover.1791860305.git.alison.schofield@intel.com/

Use a link tag.

> Signed-off-by: Richard Cheng <icheng@nvidia.com>
> ---
> I don't have available HW for multi-way interleaving setup, so I can't
> exercise the case optimized here. I would appreciate if someone is
> williing to validate the actual benefit of this.

Maybe give it a spin on qemu.  But it looks like it's just a code reorder
effectively so It would be very odd if it is a problem.

I'd just put this as a comment on Alison's series as I don't think
that has merged yet.

Seems like a nice little optimization.


> 
> 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 50f4830c225d..efd173c57dad 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -1666,10 +1666,10 @@ static int cxl_switch_port_setup_targets(struct cxl_port *port, struct cxl_regio
>  
>  	cxlsd = to_cxl_switch_decoder(&cxld->dev);
>  	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)


  reply	other threads:[~2026-10-16 18:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15  9:40 Richard Cheng
2026-10-16 18:23 ` Jonathan Cameron [this message]
2026-10-17  0:30 ` Alison Schofield

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=20261016192305.1d1e01c5@jic23-hlaptop \
    --to=jic23@kernel.org \
    --cc=alison.schofield@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dave@stgolabs.net \
    --cc=gourry@gourry.net \
    --cc=icheng@nvidia.com \
    --cc=iweiny@kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ming.li@zohomail.com \
    --cc=rrichter@amd.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 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®