Received: by 10.192.165.156 with SMTP id m28csp185990imm; Wed, 18 Apr 2018 20:01:19 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+/fMW8hgmaBlqIpAKK+pHC6kbBXGhAu1uPwgC8NH05Phza1QBOidGTcQbUDR4ldUPapm0t X-Received: by 10.101.97.200 with SMTP id j8mr3693225pgv.443.1524106879633; Wed, 18 Apr 2018 20:01:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524106879; cv=none; d=google.com; s=arc-20160816; b=hbDEOq+99OZPq27EepvrGwaFCGQtvt7xqK0y81XDXRoIz9WlvVwO/vfCfCgjI8eyHh P/tykdaxQesgJEYLR4KJcT954ZUI52/zmBhXycPTVNDOjvtPO9YrgrhwACiVaVE/D5Ax R13zxDnFlfsOh9DdjLFC2GR4xjhI+iZQY2wBqb8DyDiLB6P3bZ4RzfuqycrlX7/KGOs6 UBCD1YZLF0UPcja+D/LOGCZdOV3gkSPg6rvVpDfb6JbJh584w/sxi573X4KG8EPs0iUI t20KPzlVihHWjCjFniz8BKCufOZT/SEr0ZfYNZLObZNcBA1gCZlGQY0zJokc7qa4SZXX MdrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :dkim-signature:arc-authentication-results; bh=rtLpJUG8UIAHPc/6nr0T9/4FE0O+zk4ITxYEn3EkaKA=; b=zxTecpCmUXP3hntfR1koQ4kVF+fwa15qv+yu81sOVRVKdyRXbdF4Yol6Vr/ka7BcJ1 5QU86MP8DlXRNGA1imO0lss6HgE62TPemsQ2LVvkv0dze/Kh76xr/as2dUzt8aw4SMwx hJKnHkbUfTPJmQdogw0yCmlOY5OxUSmNtV+SIUYWoVt6pVBILpJBGWMMoXU3aXud1wTX bF/RVPCS6iWqc7jlNOc1B7Ape/ffGOiHBhc9jXQGCX6lBJ2+lZMEye1B8WvYKhZYwWWk BiE2jawlWLIfmtLC6JKmIjpvP2RpE+kfIkloB5t/CoEWoBpbG5QSyx84j69SYE1NF9pp MGGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=n9XHvyVg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n71si2322371pfk.277.2018.04.18.20.01.05; Wed, 18 Apr 2018 20:01:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=n9XHvyVg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753139AbeDSC7x (ORCPT + 99 others); Wed, 18 Apr 2018 22:59:53 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:58408 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752792AbeDSC7v (ORCPT ); Wed, 18 Apr 2018 22:59:51 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w3J2uNI1070248; Thu, 19 Apr 2018 02:59:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=rtLpJUG8UIAHPc/6nr0T9/4FE0O+zk4ITxYEn3EkaKA=; b=n9XHvyVgU1Z4fGgQoTkaVPVf/VRPRixneBOUsaHdS42t2yNmsRDf3I5WyN+wJ+re58VK Wc3hJF2t4B4UEYF0loRySLapKbbusO9VqKJCgjDODNhqqkcH32956NRGt4L0Bfgu7bMt k/nf2v3+/JxSbttjzzTfoGxnZQ6zJPCuk11Ey9BJMIkiJDTu/ANJbThpWyvBabO4PzKn s6338PUCmuEgtPTJDP+2NSIB1bhLdW8qkpY317wUSlou+yAqlPAQoNJhVuYpqazeOyr4 RtAaZtp+hEnTsfEudv8sQcYt9Y5BNrM+M9Nzu9kcWgW6Y7b3Fekjse9S3JClTD0XPHa/ BQ== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2hdrxp5bm1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 19 Apr 2018 02:59:33 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w3J2xVw4000661 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 19 Apr 2018 02:59:32 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w3J2xVon008107; Thu, 19 Apr 2018 02:59:31 GMT Received: from [10.182.71.69] (/10.182.71.69) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 18 Apr 2018 19:59:31 -0700 Subject: Re: [PATCH] IB/core: Make ib_mad_client_id atomic To: =?UTF-8?Q?H=c3=a5kon_Bugge?= , Doug Ledford , Don Hiatt , Dasaratharaman Chandramouli , Ira Weiny , Sean Hefty Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org References: <20180418142450.15581-1-Haakon.Bugge@oracle.com> From: Yanjun Zhu Organization: Oracle Corporation Message-ID: Date: Thu, 19 Apr 2018 10:59:28 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180418142450.15581-1-Haakon.Bugge@oracle.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8867 signatures=668698 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1804190027 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/4/18 22:24, Håkon Bugge wrote: > Two kernel threads may get the same value for agent.hi_tid, if the > agents are registered for different ports. As of now, this works, as > the agent list is per port. > > It is however confusing and not future robust. Hence, making it > atomic. > > Signed-off-by: Håkon Bugge > Reviewed-by: Jack Morgenstein Reviewed-by: Zhu Yanjun > --- > drivers/infiniband/core/mad.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c > index c50596f7f98a..b28452a55a08 100644 > --- a/drivers/infiniband/core/mad.c > +++ b/drivers/infiniband/core/mad.c > @@ -59,7 +59,7 @@ module_param_named(recv_queue_size, mad_recvq_size, int, 0444); > MODULE_PARM_DESC(recv_queue_size, "Size of receive queue in number of work requests"); > > static struct list_head ib_mad_port_list; > -static u32 ib_mad_client_id = 0; > +static atomic_t ib_mad_client_id = ATOMIC_INIT(0); > > /* Port list lock */ > static DEFINE_SPINLOCK(ib_mad_port_list_lock); > @@ -377,7 +377,7 @@ struct ib_mad_agent *ib_register_mad_agent(struct ib_device *device, > } > > spin_lock_irqsave(&port_priv->reg_lock, flags); > - mad_agent_priv->agent.hi_tid = ++ib_mad_client_id; > + mad_agent_priv->agent.hi_tid = atomic_inc_return(&ib_mad_client_id); > > /* > * Make sure MAD registration (if supplied)