netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next-2.6] ipv6 fib: Make rt6_info{} more cache-line aware.
@ 2010-04-01  8:24 YOSHIFUJI Hideaki
  2010-04-02  1:45 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: YOSHIFUJI Hideaki @ 2010-04-01  8:24 UTC (permalink / raw)
  To: davem; +Cc: yoshfuji, netdev

The head element of rt6_info{} is dst_entry{}, and
IPv6 specific elements follow.

Because elements at the end of dst_entry{} are frequently
updated, it is not good to put frequently-used static
elements, such as rt6i_idev, rt6i_dst or rt6i_flags in the
same cache line.

On the other hand, fib6_table, rt6i_node or rt6i_gateway are
rarely used, so it is okay to stay in the same cache line.

Let's rearrange rt6_info{}.

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
---
 include/net/ip6_fib.h |   29 ++++++++++++++++-------------
 1 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index 86f46c4..4b1dc11 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -88,34 +88,37 @@ struct rt6_info {
 		struct dst_entry	dst;
 	} u;
 
-	struct inet6_dev		*rt6i_idev;
-
 #define rt6i_dev			u.dst.dev
 #define rt6i_nexthop			u.dst.neighbour
 #define rt6i_expires			u.dst.expires
 
+	/*
+	 * Tail elements of dst_entry (__refcnt etc.)
+	 * and these elements (rarely used in hot path) are in
+	 * the same cache line.
+	 */
+	struct fib6_table		*rt6i_table;
 	struct fib6_node		*rt6i_node;
 
 	struct in6_addr			rt6i_gateway;
-	
-	u32				rt6i_flags;
-	u32				rt6i_metric;
-	atomic_t			rt6i_ref;
 
-	/* more non-fragment space at head required */
-	unsigned short			rt6i_nfheader_len;
-
-	u8				rt6i_protocol;
+	atomic_t			rt6i_ref;
 
-	struct fib6_table		*rt6i_table;
+	/* These are in a separate cache line. */
+	struct rt6key			rt6i_dst ____cacheline_aligned_in_smp;
+	u32				rt6i_flags;
+	struct rt6key			rt6i_src;
+	u32				rt6i_metric;
 
-	struct rt6key			rt6i_dst;
+	struct inet6_dev		*rt6i_idev;
 
 #ifdef CONFIG_XFRM
 	u32				rt6i_flow_cache_genid;
 #endif
+	/* more non-fragment space at head required */
+	unsigned short			rt6i_nfheader_len;
 
-	struct rt6key			rt6i_src;
+	u8				rt6i_protocol;
 };
 
 static inline struct inet6_dev *ip6_dst_idev(struct dst_entry *dst)
-- 
1.5.6.5

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next-2.6] ipv6 fib: Make rt6_info{} more cache-line aware.
  2010-04-01  8:24 [PATCH net-next-2.6] ipv6 fib: Make rt6_info{} more cache-line aware YOSHIFUJI Hideaki
@ 2010-04-02  1:45 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2010-04-02  1:45 UTC (permalink / raw)
  To: yoshfuji; +Cc: netdev

From: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Date: Thu, 01 Apr 2010 17:24:22 +0900

> The head element of rt6_info{} is dst_entry{}, and
> IPv6 specific elements follow.
> 
> Because elements at the end of dst_entry{} are frequently
> updated, it is not good to put frequently-used static
> elements, such as rt6i_idev, rt6i_dst or rt6i_flags in the
> same cache line.
> 
> On the other hand, fib6_table, rt6i_node or rt6i_gateway are
> rarely used, so it is okay to stay in the same cache line.
> 
> Let's rearrange rt6_info{}.
> 
> Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>

Applied.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-04-02  1:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-01  8:24 [PATCH net-next-2.6] ipv6 fib: Make rt6_info{} more cache-line aware YOSHIFUJI Hideaki
2010-04-02  1:45 ` David Miller

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).