Re: [PATCH net-next V2 3/4] net/mlx4_core: Use RCU to perform radix tree lookup for SRQ
flat view
From: Leon Romanovsky <hidden>
Date: 2016-09-20 13:05:45
On Tue, Sep 20, 2016 at 03:47:49PM +0300, Sergei Shtylyov wrote:
Hello. On 9/20/2016 2:39 PM, Tariq Toukan wrote:quoted
From: Leon Romanovsky <redacted> Radix tree lookup can be performed without locking. Fixes: 225c7b1feef1 ("IB/mlx4: Add a driver Mellanox ConnectX InfiniBand adapters") Signed-off-by: Leon Romanovsky <redacted> Suggested-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Tariq Toukan <redacted> --- 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
Attachments
- signature.asc [application/pgp-signature] 819 bytes