summaryrefslogtreecommitdiffstats
path: root/include/net/dst.h
diff options
context:
space:
mode:
authorDavid Miller <davem@davemloft.net>2017-11-28 15:40:53 -0500
committerDavid S. Miller <davem@davemloft.net>2017-11-30 09:54:27 -0500
commit8b207e7374c244484d6cb0f0e80ae400ce0ec0cf (patch)
tree94c0053f39bcf2acf74b43fdf1a16c3defe8e6ca /include/net/dst.h
parent0f6c480f23f49b53644b383c5554e579498347f3 (diff)
net: Rearrange dst_entry layout to avoid useless padding.
We have padding to try and align the refcount on a separate cache line. But after several simplifications the padding has increased substantially. So now it's easy to change the layout to get rid of the padding entirely. We group the write-heavy __refcnt and __use with less often used items such as the rcu_head and the error code. Signed-off-by: David S. Miller <davem@davemloft.net> Reviewed-by: Eric Dumazet <edumazet@google.com>
Diffstat (limited to 'include/net/dst.h')
-rw-r--r--include/net/dst.h31
1 files changed, 12 insertions, 19 deletions
diff --git a/include/net/dst.h b/include/net/dst.h
index 424bff66f16d..2270513d0790 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -34,7 +34,6 @@ struct sk_buff;
34 34
35struct dst_entry { 35struct dst_entry {
36 struct net_device *dev; 36 struct net_device *dev;
37 struct rcu_head rcu_head;
38 struct dst_ops *ops; 37 struct dst_ops *ops;
39 unsigned long _metrics; 38 unsigned long _metrics;
40 unsigned long expires; 39 unsigned long expires;
@@ -56,8 +55,6 @@ struct dst_entry {
56#define DST_XFRM_QUEUE 0x0040 55#define DST_XFRM_QUEUE 0x0040
57#define DST_METADATA 0x0080 56#define DST_METADATA 0x0080
58 57
59 short error;
60
61 /* A non-zero value of dst->obsolete forces by-hand validation 58 /* A non-zero value of dst->obsolete forces by-hand validation
62 * of the route entry. Positive values are set by the generic 59 * of the route entry. Positive values are set by the generic
63 * dst layer to indicate that the entry has been forcefully 60 * dst layer to indicate that the entry has been forcefully
@@ -73,29 +70,25 @@ struct dst_entry {
73#define DST_OBSOLETE_KILL -2 70#define DST_OBSOLETE_KILL -2
74 unsigned short header_len; /* more space at head required */ 71 unsigned short header_len; /* more space at head required */
75 unsigned short trailer_len; /* space to reserve at tail */ 72 unsigned short trailer_len; /* space to reserve at tail */
76 unsigned short __pad3;
77
78#ifdef CONFIG_IP_ROUTE_CLASSID
79 __u32 tclassid;
80#else
81 __u32 __pad2;
82#endif
83 73
84#ifdef CONFIG_64BIT
85 /*
86 * Align __refcnt to a 64 bytes alignment
87 * (L1_CACHE_SIZE would be too much)
88 */
89 long __pad_to_align_refcnt[5];
90#endif
91 /* 74 /*
92 * __refcnt wants to be on a different cache line from 75 * __refcnt wants to be on a different cache line from
93 * input/output/ops or performance tanks badly 76 * input/output/ops or performance tanks badly
94 */ 77 */
95 atomic_t __refcnt; /* client references */ 78#ifdef CONFIG_64BIT
79 atomic_t __refcnt; /* 64-bit offset 64 */
80#endif
96 int __use; 81 int __use;
97 unsigned long lastuse; 82 unsigned long lastuse;
98 struct lwtunnel_state *lwtstate; 83 struct lwtunnel_state *lwtstate;
84 struct rcu_head rcu_head;
85 short error;
86 short __pad;
87 __u32 tclassid;
88#ifndef CONFIG_64BIT
89 atomic_t __refcnt; /* 32-bit offset 64 */
90#endif
91
99 union { 92 union {
100 struct dst_entry *next; 93 struct dst_entry *next;
101 }; 94 };
@@ -244,7 +237,7 @@ static inline void dst_hold(struct dst_entry *dst)
244{ 237{
245 /* 238 /*
246 * If your kernel compilation stops here, please check 239 * If your kernel compilation stops here, please check
247 * __pad_to_align_refcnt declaration in struct dst_entry 240 * the placement of __refcnt in struct dst_entry
248 */ 241 */
249 BUILD_BUG_ON(offsetof(struct dst_entry, __refcnt) & 63); 242 BUILD_BUG_ON(offsetof(struct dst_entry, __refcnt) & 63);
250 WARN_ON(atomic_inc_not_zero(&dst->__refcnt) == 0); 243 WARN_ON(atomic_inc_not_zero(&dst->__refcnt) == 0);