From: Feng King <kinwin2008@gmail.com>
To: netfilter-devel@vger.kernel.org
Cc: kaber@trash.net, netdev@vger.kernel.org, davem@davemloft.net,
Feng King <kinwin2008@gmail.com>, Feng Jin <ronyjin@tencent.com>
Subject: [PATCH] conntrack: avoid unnecessary lock in tcp_packet
Date: Tue, 6 Dec 2011 20:35:07 +0800 [thread overview]
Message-ID: <1323174907-2670-1-git-send-email-kinwin2008@gmail.com> (raw)
when IPS_SEQ_ADJUST_BIT is not set, there are no need to obtain
net_offset in tcp_in_window from tcp_packet.
nat_offset will acquire global nf_nat_seqofs_lock spinlock,
and on heavy load, there will be big contention. After 30 secs webbench
stress testing, we can see from lockstat:
nf_nat_seqofs_lock: 798200 798213
1.01 57.37 216229.42 9943722
10055712 0.61 60.70
1909636.49
and from perf report, nf_nat_get_offset contributes 18.49% of our
overall spin_lock_bh cost, It's unnecessary.
Signed-off-by: Feng Jin <ronyjin@tencent.com>
---
net/netfilter/nf_conntrack_proto_tcp.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
index 8235b86..88c70f1 100644
--- a/net/netfilter/nf_conntrack_proto_tcp.c
+++ b/net/netfilter/nf_conntrack_proto_tcp.c
@@ -502,7 +502,8 @@ static inline s16 nat_offset(const struct nf_conn *ct,
return get_offset != NULL ? get_offset(ct, dir, seq) : 0;
}
#define NAT_OFFSET(pf, ct, dir, seq) \
- (pf == NFPROTO_IPV4 ? nat_offset(ct, dir, seq) : 0)
+ ((pf == NFPROTO_IPV4) && test_bit(IPS_SEQ_ADJUST_BIT, &ct->status) \
+ ? nat_offset(ct, dir, seq) : 0)
#else
#define NAT_OFFSET(pf, ct, dir, seq) 0
#endif
--
1.7.7.3
reply other threads:[~2011-12-06 12:35 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1323174907-2670-1-git-send-email-kinwin2008@gmail.com \
--to=kinwin2008@gmail.com \
--cc=davem@davemloft.net \
--cc=kaber@trash.net \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=ronyjin@tencent.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).