Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755510AbdGTQts (ORCPT ); Thu, 20 Jul 2017 12:49:48 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:37138 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755385AbdGTQtq (ORCPT ); Thu, 20 Jul 2017 12:49:46 -0400 Subject: Re: [PATCH net] rds: Make sure updates to cp_send_gen can be observed To: =?UTF-8?Q?H=c3=a5kon_Bugge?= Cc: "David S . Miller" , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, rds-devel@oss.oracle.com, linux-kernel@vger.kernel.org References: <20170720102855.21961-1-Haakon.Bugge@oracle.com> From: Santosh Shilimkar Organization: Oracle Corporation Message-ID: <1b3210e2-6701-733c-f7f4-5f1ab7581a99@oracle.com> Date: Thu, 20 Jul 2017 09:50:03 -0700 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170720102855.21961-1-Haakon.Bugge@oracle.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 981 Lines: 26 On 7/20/2017 3:28 AM, Håkon Bugge wrote: > cp->cp_send_gen is treated as a normal variable, although it may be > used by different threads. > > This is fixed by using {READ,WRITE}_ONCE when it is incremented and > READ_ONCE when it is read outside the {acquire,release}_in_xmit > protection. > There is explicit memory barrier before the value is read outside the {acquire,release}_in_xmit so it takes care of load/store sync. > Normative reference from the Linux-Kernel Memory Model: > > Loads from and stores to shared (but non-atomic) variables should > be protected with the READ_ONCE(), WRITE_ONCE(), and > ACCESS_ONCE(). > > Clause 5.1.2.4/25 in the C standard is also relevant. > > Signed-off-by: Håkon Bugge > Reviewed-by: Knut Omang > --- Having said that, {READ,WRITE}_ONCE usages seems to make it clear and explicit. So its fine with me. Acked-by: Santosh Shilimkar