* [PATCH 2/2] nfnetlink_queue: provide rcu enabled callbacks
@ 2011-07-01 15:29 Eric Dumazet
2011-07-18 14:09 ` Patrick McHardy
0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2011-07-01 15:29 UTC (permalink / raw)
To: Patrick McHardy, Florian Westphal
Cc: sclark46, Eric Leblond, Kuzin Andrey, Anders Nilsson Plymoth,
netfilter-devel, netdev
nenetlink_queue operations on SMP are not efficent if several queues are
used, because of nfnl_mutex contention when applications give packet
verdict.
Use new call_rcu field in struct nfnl_callback to advertize a callback
that is called under rcu_read_lock instead of nfnl_mutex.
On my 2x4x2 machine, I was able to reach 2.000.000 pps going through
user land returning NF_ACCEPT verdicts without losses, instead of less
than 500.000 pps before patch.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Florian Westphal <fw@strlen.de>
CC: Eric Leblond <eric@regit.org>
CC: Patrick McHardy <kaber@trash.net>
---
net/netfilter/nfnetlink_queue.c | 41 ++++++++----------------------
1 files changed, 12 insertions(+), 29 deletions(-)
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
index fdd2faf..d3692fc 100644
--- a/net/netfilter/nfnetlink_queue.c
+++ b/net/netfilter/nfnetlink_queue.c
@@ -620,39 +620,26 @@ nfqnl_recv_verdict(struct sock *ctnl, struct sk_buff *skb,
struct nfqnl_instance *queue;
unsigned int verdict;
struct nf_queue_entry *entry;
- int err;
- rcu_read_lock();
queue = instance_lookup(queue_num);
- if (!queue) {
- err = -ENODEV;
- goto err_out_unlock;
- }
+ if (!queue)
+ return -ENODEV;
- if (queue->peer_pid != NETLINK_CB(skb).pid) {
- err = -EPERM;
- goto err_out_unlock;
- }
+ if (queue->peer_pid != NETLINK_CB(skb).pid)
+ return -EPERM;
- if (!nfqa[NFQA_VERDICT_HDR]) {
- err = -EINVAL;
- goto err_out_unlock;
- }
+ if (!nfqa[NFQA_VERDICT_HDR])
+ return -EINVAL;
vhdr = nla_data(nfqa[NFQA_VERDICT_HDR]);
verdict = ntohl(vhdr->verdict);
- if ((verdict & NF_VERDICT_MASK) > NF_MAX_VERDICT) {
- err = -EINVAL;
- goto err_out_unlock;
- }
+ if ((verdict & NF_VERDICT_MASK) > NF_MAX_VERDICT)
+ return -EINVAL;
entry = find_dequeue_entry(queue, ntohl(vhdr->id));
- if (entry == NULL) {
- err = -ENOENT;
- goto err_out_unlock;
- }
- rcu_read_unlock();
+ if (entry == NULL)
+ return -ENOENT;
if (nfqa[NFQA_PAYLOAD]) {
if (nfqnl_mangle(nla_data(nfqa[NFQA_PAYLOAD]),
@@ -665,10 +652,6 @@ nfqnl_recv_verdict(struct sock *ctnl, struct sk_buff *skb,
nf_reinject(entry, verdict);
return 0;
-
-err_out_unlock:
- rcu_read_unlock();
- return err;
}
static int
@@ -781,9 +764,9 @@ err_out_unlock:
}
static const struct nfnl_callback nfqnl_cb[NFQNL_MSG_MAX] = {
- [NFQNL_MSG_PACKET] = { .call = nfqnl_recv_unsupp,
+ [NFQNL_MSG_PACKET] = { .call_rcu = nfqnl_recv_unsupp,
.attr_count = NFQA_MAX, },
- [NFQNL_MSG_VERDICT] = { .call = nfqnl_recv_verdict,
+ [NFQNL_MSG_VERDICT] = { .call_rcu = nfqnl_recv_verdict,
.attr_count = NFQA_MAX,
.policy = nfqa_verdict_policy },
[NFQNL_MSG_CONFIG] = { .call = nfqnl_recv_config,
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 2/2] nfnetlink_queue: provide rcu enabled callbacks
2011-07-01 15:29 [PATCH 2/2] nfnetlink_queue: provide rcu enabled callbacks Eric Dumazet
@ 2011-07-18 14:09 ` Patrick McHardy
0 siblings, 0 replies; 2+ messages in thread
From: Patrick McHardy @ 2011-07-18 14:09 UTC (permalink / raw)
To: Eric Dumazet
Cc: Florian Westphal, sclark46, Eric Leblond, Kuzin Andrey,
Anders Nilsson Plymoth, netfilter-devel, netdev
On 01.07.2011 17:29, Eric Dumazet wrote:
> nenetlink_queue operations on SMP are not efficent if several queues are
> used, because of nfnl_mutex contention when applications give packet
> verdict.
>
> Use new call_rcu field in struct nfnl_callback to advertize a callback
> that is called under rcu_read_lock instead of nfnl_mutex.
>
> On my 2x4x2 machine, I was able to reach 2.000.000 pps going through
> user land returning NF_ACCEPT verdicts without losses, instead of less
> than 500.000 pps before patch.
Applied, nice work.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-07-18 14:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-01 15:29 [PATCH 2/2] nfnetlink_queue: provide rcu enabled callbacks Eric Dumazet
2011-07-18 14:09 ` Patrick McHardy
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).