All of lore.kernel.org
 help / color / mirror / Atom feed
From: Haakon Bugge <haakon.bugge@oracle.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: Doug Ledford <dledford@redhat.com>,
	Leon Romanovsky <leon@kernel.org>,
	OFED mailing list <linux-rdma@vger.kernel.org>
Subject: Re: [PATCH for-next] RDMA/cma: Replace RMW with atomic bit-ops
Date: Tue, 22 Jun 2021 07:44:20 +0000	[thread overview]
Message-ID: <7934D5F5-C150-4998-88E4-9DF149CF1CA9@oracle.com> (raw)
In-Reply-To: <8CD791BA-F945-4F4F-869A-1625E7F95648@oracle.com>



> On 22 Jun 2021, at 09:34, Haakon Bugge <haakon.bugge@oracle.com> wrote:
> 
> 
> 
>> On 22 Jun 2021, at 01:29, Jason Gunthorpe <jgg@nvidia.com> wrote:
>> 
>> On Mon, Jun 21, 2021 at 03:37:10PM +0000, Haakon Bugge wrote:
>>> 
>>> 
>>>> On 21 Jun 2021, at 17:32, Jason Gunthorpe <jgg@nvidia.com> wrote:
>>>> 
>>>> On Mon, Jun 21, 2021 at 03:30:14PM +0000, Haakon Bugge wrote:
>>>>> 
>>>>> 
>>>>>> On 21 Jun 2021, at 16:35, Jason Gunthorpe <jgg@nvidia.com> wrote:
>>>>>> 
>>>>>> On Wed, Jun 16, 2021 at 04:35:53PM +0200, Håkon Bugge wrote:
>>>>>>> +#define BIT_ACCESS_FUNCTIONS(b)							\
>>>>>>> +	static inline void set_##b(unsigned long flags)				\
>>>>>>> +	{									\
>>>>>>> +		/* set_bit() does not imply a memory barrier */			\
>>>>>>> +		smp_mb__before_atomic();					\
>>>>>>> +		set_bit(b, &flags);						\
>>>>>>> +		/* set_bit() does not imply a memory barrier */			\
>>>>>>> +		smp_mb__after_atomic();						\
>>>>>>> +	}
>>>>>> 
>>>>>> This isn't needed, set_bit/test_bit are already atomic with
>>>>>> themselves, we should not need to introduce release semantics.
>>>>> 
>>>>> They are atomic, yes. But set_bit() does not provide a memory barrier (on x86_64, yes, but not as per the Linux definition of set_bit()).
>>>>> 
>>>>> We have (paraphrased):
>>>>> 
>>>>> 	id_priv->min_rnr_timer = min_rnr_timer;
>>>>> 	set_bit(MIN_RNR_TIMER_SET, &id_priv->flags);
>>>>> 
>>>>> Since set_bit() does not provide a memory barrier, another thread
>>>>> may observe the MIN_RNR_TIMER_SET bit in id_priv->flags, but the
>>>>> id_priv->min_rnr_timer value is not yet globally visible. Hence,
>>>>> IMHO, we need the memory barriers.
>>>> 
>>>> No, you need proper locks.
>>> 
>>> Either will work in my opinion. If you prefer locking, I can do
>>> that. This is not performance critical.
>> 
>> Yes, use locks please
> 
> With locking, there is no need for changing the bit fields to a flags variable and set/test_bit. But, for the fix to be complete, the locking must then be done all three places. Hence. I'll send one commit with locking.

Adding to that, I will make a series of this and include ("RDMA/cma: Remove unnecessary INIT->INIT transition") here. The reason is that the transitions of the QP state of a connected QP is not protected by a lock when called from rdma_create_qp() [what protects the cm_id from being destroyed whilst rdma_create_qp() executes?].

With commit ("RDMA/cma: Remove unnecessary INIT->INIT transition"), the QP state transitions on a connected QP is removed from rdma_create_qp(), and when called from  cma_modify_qp_rtr(), the qp_lock is held, which fits well with fixing the unprotected RMW to the bitfields.


Thxs, Håkon


> 
> 
> Thxs, Håkon


      reply	other threads:[~2021-06-22  7:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-16 14:35 [PATCH for-next] RDMA/cma: Replace RMW with atomic bit-ops Håkon Bugge
2021-06-16 15:02 ` Stefan Metzmacher
2021-06-16 16:03   ` Haakon Bugge
2021-06-17  6:51 ` Leon Romanovsky
2021-06-17  6:56   ` Haakon Bugge
2021-06-17  7:38     ` Leon Romanovsky
2021-06-17  9:19       ` Haakon Bugge
2021-06-17 12:49         ` Leon Romanovsky
2021-06-18 13:57           ` Haakon Bugge
2021-06-21 14:35 ` Jason Gunthorpe
2021-06-21 15:30   ` Haakon Bugge
2021-06-21 15:32     ` Jason Gunthorpe
2021-06-21 15:37       ` Haakon Bugge
2021-06-21 23:29         ` Jason Gunthorpe
2021-06-22  7:34           ` Haakon Bugge
2021-06-22  7:44             ` Haakon Bugge [this message]

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=7934D5F5-C150-4998-88E4-9DF149CF1CA9@oracle.com \
    --to=haakon.bugge@oracle.com \
    --cc=dledford@redhat.com \
    --cc=jgg@nvidia.com \
    --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 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.