From patchwork Tue Aug 26 14:49:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreea-Cristina Bernat X-Patchwork-Id: 4782721 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2C8889F383 for ; Tue, 26 Aug 2014 14:49:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1809F20142 for ; Tue, 26 Aug 2014 14:49:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DB37820158 for ; Tue, 26 Aug 2014 14:49:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755424AbaHZOtc (ORCPT ); Tue, 26 Aug 2014 10:49:32 -0400 Received: from mail-lb0-f176.google.com ([209.85.217.176]:58732 "EHLO mail-lb0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750950AbaHZOtb (ORCPT ); Tue, 26 Aug 2014 10:49:31 -0400 Received: by mail-lb0-f176.google.com with SMTP id c11so1519670lbj.35 for ; Tue, 26 Aug 2014 07:49:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=rb2nYpaLsbZ+3qo3e4ToSg5n7sc6eRcsf1zq67rAATw=; b=yAf/vJCj4smB7aVKvMk/yUrQW50WVtCNvFrWnKUjnY8KUieOKKqJYVeXm8fZUi/WeI rQsMJB0K4Rxv5VQUageC5CXKo7oibzPZYRnxcGKbzIL/dalNWbQxXWIcvriLbPeORb5X vk6oonfkk+mvy0Rf6Yv6+pxGEmTI+UUdlaM07QCTz/vF7Sa4kvUxT4ANYKgOCuSoDTUF unUHA5rfgJB/wLOFT/V6IFLLWbwUqk/3bgwjhwWx4jX+8QkDYMdNLHI2i2NMUChCX6eS hcgwVTI40Q1ZfR4jS4ng3gT/aNm5v90jenEeMOAjzxiF4U1s1z5z0f2mE6N4bhrpNP9g 32Yg== X-Received: by 10.113.4.132 with SMTP id ce4mr26637776lbd.2.1409064569989; Tue, 26 Aug 2014 07:49:29 -0700 (PDT) Received: from ada ([85.204.3.189]) by mx.google.com with ESMTPSA id xh2sm5552955lbb.7.2014.08.26.07.49.28 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 26 Aug 2014 07:49:29 -0700 (PDT) Date: Tue, 26 Aug 2014 17:49:21 +0300 From: Andreea-Cristina Bernat To: roland@kernel.org, sean.hefty@intel.com, hal.rosenstock@gmail.com, mschmidt@redhat.com, erezsh@mellanox.com, ogerlitz@mellanox.com, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Cc: paulmck@linux.vnet.ibm.com Subject: [PATCH] ipoib: ipoib_main: Replace rcu_assign_pointer() with RCU_INIT_POINTER() Message-ID: <20140826144921.GA2950@ada> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP According to RCU_INIT_POINTER()'s block comment 3.a, it can be used if "3. The referenced data structure has already been exposed to readers either at compile time or via rcu_assign_pointer() -and- a. You have not made -any- reader-visible changes to this structure since then". These cases fulfill the conditions above because between the rcu_dereference_protected() calls and the rcu_assign_pointer() calls there are no updates of those values. Therefore, this patch makes the replacements. The following Coccinelle semantic patch was used: @@ @@ - rcu_assign_pointer + RCU_INIT_POINTER (..., ( rtnl_dereference(...) | rcu_dereference_protected(...) ) ) Signed-off-by: Andreea-Cristina Bernat --- drivers/infiniband/ulp/ipoib/ipoib_main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index 64cd5b5..c348b14 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c @@ -929,7 +929,7 @@ static void __ipoib_reap_neigh(struct ipoib_dev_priv *priv) lockdep_is_held(&priv->lock))) != NULL) { /* was the neigh idle for two GC periods */ if (time_after(neigh_obsolete, neigh->alive)) { - rcu_assign_pointer(*np, + RCU_INIT_POINTER(*np, rcu_dereference_protected(neigh->hnext, lockdep_is_held(&priv->lock))); /* remove from path/mc list */ @@ -1024,7 +1024,7 @@ struct ipoib_neigh *ipoib_neigh_alloc(u8 *daddr, atomic_inc(&neigh->refcnt); neigh->alive = jiffies; /* put in hash */ - rcu_assign_pointer(neigh->hnext, + RCU_INIT_POINTER(neigh->hnext, rcu_dereference_protected(htbl->buckets[hash_val], lockdep_is_held(&priv->lock))); rcu_assign_pointer(htbl->buckets[hash_val], neigh); @@ -1092,7 +1092,7 @@ void ipoib_neigh_free(struct ipoib_neigh *neigh) lockdep_is_held(&priv->lock))) { if (n == neigh) { /* found */ - rcu_assign_pointer(*np, + RCU_INIT_POINTER(*np, rcu_dereference_protected(neigh->hnext, lockdep_is_held(&priv->lock))); /* remove from parent list */ @@ -1177,7 +1177,7 @@ void ipoib_del_neighs_by_gid(struct net_device *dev, u8 *gid) lockdep_is_held(&priv->lock))) != NULL) { /* delete neighs belong to this parent */ if (!memcmp(gid, neigh->daddr + 4, sizeof (union ib_gid))) { - rcu_assign_pointer(*np, + RCU_INIT_POINTER(*np, rcu_dereference_protected(neigh->hnext, lockdep_is_held(&priv->lock))); /* remove from parent list */ @@ -1219,7 +1219,7 @@ static void ipoib_flush_neighs(struct ipoib_dev_priv *priv) while ((neigh = rcu_dereference_protected(*np, lockdep_is_held(&priv->lock))) != NULL) { - rcu_assign_pointer(*np, + RCU_INIT_POINTER(*np, rcu_dereference_protected(neigh->hnext, lockdep_is_held(&priv->lock))); /* remove from path/mc list */