netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jesper Dangaard Brouer <brouer@redhat.com>
To: Eric Dumazet <eric.dumazet@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Florian Westphal <fw@strlen.de>
Cc: Jesper Dangaard Brouer <brouer@redhat.com>,
	netdev@vger.kernel.org, Pablo Neira Ayuso <pablo@netfilter.org>,
	Cong Wang <amwang@redhat.com>,
	"Patrick McHardy" <kaber@trash.net>,
	Herbert Xu <herbert@gondor.hengli.com.au>,
	Daniel Borkmann <dborkman@redhat.com>
Subject: [net-next PATCH 2/6] net: cacheline adjust struct inet_frags for better frag performance
Date: Thu, 24 Jan 2013 15:04:20 +0100	[thread overview]
Message-ID: <20130124140417.14119.32738.stgit@dragon> (raw)
In-Reply-To: <20130124140343.14119.77712.stgit@dragon>

The globally shared rwlock, of struct inet_frags, shares
cacheline with the 'rnd' number, which is used by the hash
calculations.  Fix this, as this obviously is a bad idea, as
unnecessary cache-misses will occur when accessing the 'rnd'
number.

Also small note that, moving function ptr (*match) up in struct,
is to avoid it lands on the next cacheline (on 64-bit).

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
---

 include/net/inet_frag.h |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h
index 91e7797..99eb4e0 100644
--- a/include/net/inet_frag.h
+++ b/include/net/inet_frag.h
@@ -40,18 +40,22 @@ struct inet_frag_queue {
 
 struct inet_frags {
 	struct hlist_head	hash[INETFRAGS_HASHSZ];
-	rwlock_t		lock;
-	u32			rnd;
-	int			qsize;
+	/* This rwlock is a global lock (seperate per IPv4, IPv6 and
+	 * netfilter). Important to keep this on a seperate cacheline.
+	 */
+	rwlock_t		lock ____cacheline_aligned_in_smp;
 	int			secret_interval;
 	struct timer_list	secret_timer;
+	/* --- read-mostly cacheline boundary (was 24 bytes ago) --- */
+	u32			rnd;
+	int			qsize;
 
 	unsigned int		(*hashfn)(struct inet_frag_queue *);
+	bool			(*match)(struct inet_frag_queue *q, void *arg);
 	void			(*constructor)(struct inet_frag_queue *q,
 						void *arg);
 	void			(*destructor)(struct inet_frag_queue *);
 	void			(*skb_free)(struct sk_buff *);
-	bool			(*match)(struct inet_frag_queue *q, void *arg);
 	void			(*frag_expire)(unsigned long data);
 };
 

  parent reply	other threads:[~2013-01-24 14:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-24 14:04 [net-next PATCH 0/6] net: frag performance tuning cachelines for NUMA/SMP systems Jesper Dangaard Brouer
2013-01-24 14:04 ` [net-next PATCH 1/6] net: cacheline adjust struct netns_frags for better frag performance Jesper Dangaard Brouer
2013-01-24 14:04 ` Jesper Dangaard Brouer [this message]
2013-01-29  4:23   ` [net-next PATCH 2/6] net: cacheline adjust struct inet_frags " David Miller
2013-01-29  7:30     ` Jesper Dangaard Brouer
2013-01-24 14:04 ` [net-next PATCH 3/6] net: cacheline adjust struct inet_frag_queue Jesper Dangaard Brouer
2013-01-24 14:04 ` [net-next PATCH 4/6] net: frag helper functions for mem limit tracking Jesper Dangaard Brouer
2013-01-24 14:04 ` [net-next PATCH 5/6] net: use lib/percpu_counter API for fragmentation mem accounting Jesper Dangaard Brouer
2013-01-29  4:24   ` David Miller
2013-01-29  7:31     ` Jesper Dangaard Brouer
2013-01-24 14:05 ` [net-next PATCH 6/6] net: frag, move LRU list maintenance outside of rwlock Jesper Dangaard Brouer

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=20130124140417.14119.32738.stgit@dragon \
    --to=brouer@redhat.com \
    --cc=amwang@redhat.com \
    --cc=davem@davemloft.net \
    --cc=dborkman@redhat.com \
    --cc=eric.dumazet@gmail.com \
    --cc=fw@strlen.de \
    --cc=herbert@gondor.hengli.com.au \
    --cc=kaber@trash.net \
    --cc=netdev@vger.kernel.org \
    --cc=pablo@netfilter.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).