Commit 69a73829dbb10e7c8554e66a80cb4fde57347fff

Authored by Eric Dumazet
Committed by David S. Miller
1 parent 81566e8322

[DST]: shrinks sizeof(struct rtable) by 64 bytes on x86_64

On x86_64, sizeof(struct rtable) is 0x148, which is rounded up to
0x180 bytes by SLAB allocator.

We can reduce this to exactly 0x140 bytes, without alignment overhead,
and store 12 struct rtable per PAGE instead of 10.

rate_tokens is currently defined as an "unsigned long", while its
content should not exceed 6*HZ. It can safely be converted to an
unsigned int.

Moving tclassid right after rate_tokens to fill the 4 bytes hole
permits to save 8 bytes on 'struct dst_entry', which finally permits
to save 8 bytes on 'struct rtable'

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 2 changed files with 12 additions and 11 deletions Side-by-side Diff

... ... @@ -56,18 +56,18 @@
56 56 struct dst_entry *path;
57 57  
58 58 unsigned long rate_last; /* rate limiting for ICMP */
59   - unsigned long rate_tokens;
  59 + unsigned int rate_tokens;
60 60  
  61 +#ifdef CONFIG_NET_CLS_ROUTE
  62 + __u32 tclassid;
  63 +#endif
  64 +
61 65 struct neighbour *neighbour;
62 66 struct hh_cache *hh;
63 67 struct xfrm_state *xfrm;
64 68  
65 69 int (*input)(struct sk_buff*);
66 70 int (*output)(struct sk_buff*);
67   -
68   -#ifdef CONFIG_NET_CLS_ROUTE
69   - __u32 tclassid;
70   -#endif
71 71  
72 72 struct dst_ops *ops;
73 73  
... ... @@ -275,18 +275,19 @@
275 275 #define XRLIM_BURST_FACTOR 6
276 276 int xrlim_allow(struct dst_entry *dst, int timeout)
277 277 {
278   - unsigned long now;
  278 + unsigned long now, token = dst->rate_tokens;
279 279 int rc = 0;
280 280  
281 281 now = jiffies;
282   - dst->rate_tokens += now - dst->rate_last;
  282 + token += now - dst->rate_last;
283 283 dst->rate_last = now;
284   - if (dst->rate_tokens > XRLIM_BURST_FACTOR * timeout)
285   - dst->rate_tokens = XRLIM_BURST_FACTOR * timeout;
286   - if (dst->rate_tokens >= timeout) {
287   - dst->rate_tokens -= timeout;
  284 + if (token > XRLIM_BURST_FACTOR * timeout)
  285 + token = XRLIM_BURST_FACTOR * timeout;
  286 + if (token >= timeout) {
  287 + token -= timeout;
288 288 rc = 1;
289 289 }
  290 + dst->rate_tokens = token;
290 291 return rc;
291 292 }
292 293