Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: "Leizhen (ThunderTown)" <thunder.leizhen@huawei.com>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Doug Ledford <dledford@redhat.com>,
	Leon Romanovsky <leon@kernel.org>,
	linux-rdma <linux-rdma@vger.kernel.org>
Subject: Re: [PATCH v2 2/2] RDMA/cm: Optimise rbtree searching
Date: Wed, 12 May 2021 21:12:08 +0800	[thread overview]
Message-ID: <afb85ebf-4b76-d5e7-847a-14461bcf7310@huawei.com> (raw)
In-Reply-To: <20210512125006.GE1096940@ziepe.ca>



On 2021/5/12 20:50, Jason Gunthorpe wrote:
> On Wed, May 12, 2021 at 06:05:37PM +0800, Zhen Lei wrote:
>>  static struct cm_id_private *cm_find_listen(struct ib_device *device,
>> @@ -686,22 +687,23 @@ static struct cm_id_private *cm_find_listen(struct ib_device *device,
>>  
>>  	while (node) {
>>  		cm_id_priv = rb_entry(node, struct cm_id_private, service_node);
>> -		if ((cm_id_priv->id.service_mask & service_id) ==
>> -		     cm_id_priv->id.service_id &&
>> -		    (cm_id_priv->id.device == device)) {
>> -			refcount_inc(&cm_id_priv->refcount);
>> -			return cm_id_priv;
>> -		}
>> +
>>  		if (device < cm_id_priv->id.device)
>>  			node = node->rb_left;
>>  		else if (device > cm_id_priv->id.device)
>>  			node = node->rb_right;
>> +		else if ((cm_id_priv->id.service_mask & service_id) == cm_id_priv->id.service_id)
>> +			goto found;
>>  		else if (be64_lt(service_id, cm_id_priv->id.service_id))
>>  			node = node->rb_left;
>>  		else
>>  			node = node->rb_right;
>>  	}
> 
> This is not the pattern I showed you. Drop the first patch and rely on
> the implicit equality in the final else.

Do you mean treate the "found" process as the else branch?

But ((cm_id_priv->id.service_mask & service_id) == cm_id_priv->id.service_id) is different from
(service_id == cm_id_priv->id.service_id),I'm just worried that it might change the original logic.

> 
> Jason
> 
> .
> 


  reply	other threads:[~2021-05-12 13:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-12 10:05 [PATCH v2 0/2] RDMA/cm: Optimise rbtree searching Zhen Lei
2021-05-12 10:05 ` [PATCH v2 1/2] RDMA/cm: Delete two redundant condition branches Zhen Lei
2021-05-12 10:05 ` [PATCH v2 2/2] RDMA/cm: Optimise rbtree searching Zhen Lei
2021-05-12 12:50   ` Jason Gunthorpe
2021-05-12 13:12     ` Leizhen (ThunderTown) [this message]
2021-05-12 14:26       ` Jason Gunthorpe
2021-05-13  2:25         ` Leizhen (ThunderTown)

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=afb85ebf-4b76-d5e7-847a-14461bcf7310@huawei.com \
    --to=thunder.leizhen@huawei.com \
    --cc=dledford@redhat.com \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    /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