netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Leon Romanovsky <leonro@mellanox.com>
To: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Cc: Tariq Toukan <tariqt@mellanox.com>,
	"David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org, Eran Ben Elisha <eranbe@mellanox.com>
Subject: Re: [PATCH net-next V2 3/4] net/mlx4_core: Use RCU to perform radix tree lookup for SRQ
Date: Tue, 20 Sep 2016 16:05:41 +0300	[thread overview]
Message-ID: <20160920130541.GN26673@leon.nu> (raw)
In-Reply-To: <33b95e3f-ae37-4635-1810-c8e65d075e4d@cogentembedded.com>

[-- Attachment #1: Type: text/plain, Size: 2406 bytes --]

On Tue, Sep 20, 2016 at 03:47:49PM +0300, Sergei Shtylyov wrote:
> Hello.
>
> On 9/20/2016 2:39 PM, Tariq Toukan wrote:
>
> >From: Leon Romanovsky <leonro@mellanox.com>
> >
> >Radix tree lookup can be performed without locking.
> >
> >Fixes: 225c7b1feef1 ("IB/mlx4: Add a driver Mellanox ConnectX InfiniBand adapters")
> >Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
> >Suggested-by: Sagi Grimberg <sagi@grimberg.me>
> >Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
> >---
> > drivers/net/ethernet/mellanox/mlx4/srq.c | 14 +++++---------
> > 1 file changed, 5 insertions(+), 9 deletions(-)
> >
> >diff --git a/drivers/net/ethernet/mellanox/mlx4/srq.c b/drivers/net/ethernet/mellanox/mlx4/srq.c
> >index 67146624eb58..f44d089e2ca6 100644
> >--- a/drivers/net/ethernet/mellanox/mlx4/srq.c
> >+++ b/drivers/net/ethernet/mellanox/mlx4/srq.c
> >@@ -45,15 +45,12 @@ void mlx4_srq_event(struct mlx4_dev *dev, u32 srqn, int event_type)
> > 	struct mlx4_srq_table *srq_table = &mlx4_priv(dev)->srq_table;
> > 	struct mlx4_srq *srq;
> >
> >-	spin_lock(&srq_table->lock);
> >-
> >+	rcu_read_lock();
> > 	srq = radix_tree_lookup(&srq_table->tree, srqn & (dev->caps.num_srqs - 1));
> >+	rcu_read_unlock();
> > 	if (srq)
> > 		atomic_inc(&srq->refcount);
> >-
> >-	spin_unlock(&srq_table->lock);
> >-
> >-	if (!srq) {
> >+	else {
> > 		mlx4_warn(dev, "Async event for bogus SRQ %08x\n", srqn);
> > 		return;
> > 	}
>
>    CodingStyle: all branches of the *if* statement should have {} if at
> least one has.

I'm not arguing, but wanted to raise attention that checkpatch.pl
doesn't warn about it.

➜  /tmp wget https://patchwork.ozlabs.org/patch/672216/mbox/
➜  linux-rdma git:(master) ./scripts/checkpatch.pl /tmp/index.html
total: 0 errors, 0 warnings, 0 checks, 32 lines checked

/tmp/index.html has no obvious style problems and is ready for
submission.

And CodingStyle presents a little bit different case
----
This does not apply if only one branch of a conditional statement is a
single statement; in the latter case use braces in both branches:

        if (condition) {
                do_this();
                do_that();
        } else {
                otherwise();
        }

and not

        if (condition)
                do_that();
        else {
                otherwise();
		otherwise();
        }

Thanks

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2016-09-20 13:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-20 11:39 [PATCH net-next V2 0/4] mlx4 misc cleanups and improvements Tariq Toukan
2016-09-20 11:39 ` [PATCH net-next V2 1/4] net/mlx4_en: Add branch prediction hints in RX data-path Tariq Toukan
2016-09-20 11:39 ` [PATCH net-next V2 2/4] net/mlx4_en: Fix wrong indentation Tariq Toukan
2016-09-20 11:39 ` [PATCH net-next V2 3/4] net/mlx4_core: Use RCU to perform radix tree lookup for SRQ Tariq Toukan
2016-09-20 12:47   ` Sergei Shtylyov
2016-09-20 13:05     ` Leon Romanovsky [this message]
2016-09-20 11:39 ` [PATCH net-next V2 4/4] net/mlx4_core: Fix deadlock when switching between polling and event fw commands Tariq Toukan
2016-09-22  1:53 ` [PATCH net-next V2 0/4] mlx4 misc cleanups and improvements David Miller

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=20160920130541.GN26673@leon.nu \
    --to=leonro@mellanox.com \
    --cc=davem@davemloft.net \
    --cc=eranbe@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=sergei.shtylyov@cogentembedded.com \
    --cc=tariqt@mellanox.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;
as well as URLs for NNTP newsgroup(s).