From: David Miller <davem@davemloft.net>
To: roland@kernel.org
Cc: netdev@vger.kernel.org
Subject: [PATCH] infiniband: addr: Avoid unnecessary neigh lookup.
Date: Fri, 02 Dec 2011 14:55:25 -0500 (EST) [thread overview]
Message-ID: <20111202.145525.1679807360238725746.davem@davemloft.net> (raw)
The explicit neigh_lookup() in addr4_resolve() is unnecessary because this
is the exact same calculation the routing code already made to attach the
neigh to the route.
Therefore, just use dst_get_neighbour().
Signed-off-by: David S. Miller <davem@davemloft.net>
---
Roland, I'm auditing all of the uses of dst_get_neighbour() with the
end result being that a dst_put_neighbour() interface will be added
and all access will be reduced to quick:
rcu_read_lock();
n = dst_get_neighbour();
...
dst_put_neighbour();
rcu_read_unlock();
sequences. And then, at the next step, things will be further
whittled down into a refcount-less variant:
rcu_read_lock();
n = dst_get_neighbour_noref();
...
rcu_read_unlock();
Another key difference is that we are making the code able to handle
dst_get_neighbour() returning NULL.
So if it's OK with you I'd like to merge this stuff directly in the
net-next tree after getting your ACK on each patch.
In the case here, the neigh_lookup() call is spurious and is exactly
mimicking the neigh lookup that the ipv4 routing code does to attach
the neighbour to the route. There is no need to duplicate that
operation, and we can thus use the route attached neigh directly.
drivers/infiniband/core/addr.c | 21 ++++++++++-----------
1 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index a20c3c8..83d88e1 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -214,20 +214,19 @@ static int addr4_resolve(struct sockaddr_in *src_in,
goto put;
}
- neigh = neigh_lookup(&arp_tbl, &rt->rt_gateway, rt->dst.dev);
- if (!neigh || !(neigh->nud_state & NUD_VALID)) {
- rcu_read_lock();
- neigh_event_send(dst_get_neighbour(&rt->dst), NULL);
- rcu_read_unlock();
- ret = -ENODATA;
- if (neigh)
- goto release;
- goto put;
+ rcu_read_lock();
+ neigh = dst_get_neighbour(&rt->dst);
+ ret = -ENODATA;
+ if (!neigh)
+ goto unlock_put;
+ if (!(neigh->nud_state & NUD_VALID)) {
+ neigh_event_send(neigh, NULL);
+ goto unlock_put;
}
ret = rdma_copy_addr(addr, neigh->dev, neigh->ha);
-release:
- neigh_release(neigh);
+unlock_put:
+ rcu_read_unlock();
put:
ip_rt_put(rt);
out:
--
1.7.7.3
next reply other threads:[~2011-12-02 19:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-02 19:55 David Miller [this message]
2011-12-02 23:18 ` [PATCH] infiniband: addr: Avoid unnecessary neigh lookup Roland Dreier
2011-12-03 2:48 ` 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=20111202.145525.1679807360238725746.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=roland@kernel.org \
/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).