public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: liweihang <liweihang@huawei.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: "dledford@redhat.com" <dledford@redhat.com>,
	"leon@kernel.org" <leon@kernel.org>,
	"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
	Linuxarm <linuxarm@huawei.com>
Subject: Re: [PATCH v4 for-next 06/12] RDMA/core: Use refcount_t instead of atomic_t on refcount of mcast_group
Date: Wed, 9 Jun 2021 03:45:19 +0000	[thread overview]
Message-ID: <4cd2bfc3eba6410896835744be88bd13@huawei.com> (raw)
In-Reply-To: 20210608175533.GA964838@nvidia.com

On 2021/6/9 1:55, Jason Gunthorpe wrote:
> On Fri, May 28, 2021 at 05:37:37PM +0800, Weihang Li wrote:
>> @@ -565,8 +565,11 @@ static struct mcast_group *acquire_group(struct mcast_port *port,
>>  	if (!is_mgid0) {
>>  		spin_lock_irqsave(&port->lock, flags);
>>  		group = mcast_find(port, mgid);
>> -		if (group)
>> +		if (group) {
>> +			refcount_inc(&group->refcount);
>>  			goto found;
>> +		}
>> +
>>  		spin_unlock_irqrestore(&port->lock, flags);
>>  	}
>>  
>> @@ -590,8 +593,10 @@ static struct mcast_group *acquire_group(struct mcast_port *port,
>>  		group = cur_group;
>>  	} else
>>  		refcount_inc(&port->refcount);
>> +
>> +	refcount_set(&group->refcount, 1);
>> +
> 
> This isn't right, when mcast_insert() returns an existing group we
> need to incr not set the refcount. Change it like this:
> 

Thanks, I will modify it.

Weihang

> diff --git a/drivers/infiniband/core/multicast.c b/drivers/infiniband/core/multicast.c
> index 17abc212b87d05..cf99e17b81ce79 100644
> --- a/drivers/infiniband/core/multicast.c
> +++ b/drivers/infiniband/core/multicast.c
> @@ -585,17 +585,17 @@ static struct mcast_group *acquire_group(struct mcast_port *port,
>  	INIT_LIST_HEAD(&group->active_list);
>  	INIT_WORK(&group->work, mcast_work_handler);
>  	spin_lock_init(&group->lock);
> +	refcount_set(&group->refcount, 1);
>  
>  	spin_lock_irqsave(&port->lock, flags);
>  	cur_group = mcast_insert(port, group, is_mgid0);
>  	if (cur_group) {
>  		kfree(group);
>  		group = cur_group;
> +		refcount_inc(&group->refcount);
>  	} else
>  		refcount_inc(&port->refcount);
>  
> -	refcount_set(&group->refcount, 1);
> -
>  found:
>  	spin_unlock_irqrestore(&port->lock, flags);
>  	return group;
> 


  reply	other threads:[~2021-06-09  3:45 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-28  9:37 [PATCH v4 for-next 00/12] RDMA: Use refcount_t for reference counting Weihang Li
2021-05-28  9:37 ` [PATCH v4 for-next 01/12] RDMA/core: Use refcount_t instead of atomic_t on refcount of iwcm_id_private Weihang Li
2021-05-28  9:37 ` [PATCH v4 for-next 02/12] RDMA/core: Use refcount_t instead of atomic_t on refcount of iwpm_admin_data Weihang Li
2021-05-28  9:37 ` [PATCH v4 for-next 03/12] RDMA/core: Use refcount_t instead of atomic_t on refcount of ib_mad_snoop_private Weihang Li
2021-06-08 18:04   ` Jason Gunthorpe
2021-06-09  3:27     ` liweihang
2021-05-28  9:37 ` [PATCH v4 for-next 04/12] RDMA/core: Use refcount_t instead of atomic_t on refcount of mcast_member Weihang Li
2021-05-28  9:37 ` [PATCH v4 for-next 05/12] RDMA/core: Use refcount_t instead of atomic_t on refcount of mcast_port Weihang Li
2021-05-28  9:37 ` [PATCH v4 for-next 06/12] RDMA/core: Use refcount_t instead of atomic_t on refcount of mcast_group Weihang Li
2021-06-08 17:55   ` Jason Gunthorpe
2021-06-09  3:45     ` liweihang [this message]
2021-05-28  9:37 ` [PATCH v4 for-next 07/12] RDMA/core: Use refcount_t instead of atomic_t on refcount of ib_uverbs_device Weihang Li
2021-05-28  9:37 ` [PATCH v4 for-next 08/12] RDMA/hns: Use refcount_t instead of atomic_t for CQ reference counting Weihang Li
2021-05-28  9:37 ` [PATCH v4 for-next 09/12] RDMA/hns: Use refcount_t instead of atomic_t for SRQ " Weihang Li
2021-05-28  9:37 ` [PATCH v4 for-next 10/12] RDMA/hns: Use refcount_t instead of atomic_t for QP " Weihang Li
2021-05-28  9:37 ` [PATCH v4 for-next 11/12] RDMA/cxgb4: Use refcount_t instead of atomic_t for " Weihang Li
2021-05-28  9:37 ` [PATCH v4 for-next 12/12] RDMA/ipoib: " Weihang Li
2021-06-08 18:08 ` [PATCH v4 for-next 00/12] RDMA: Use refcount_t " Jason Gunthorpe

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=4cd2bfc3eba6410896835744be88bd13@huawei.com \
    --to=liweihang@huawei.com \
    --cc=dledford@redhat.com \
    --cc=jgg@nvidia.com \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linuxarm@huawei.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