From: Eric Dumazet <dada1@cosmosbay.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: [PATCH] [NET] reduce sizeof(struct flow)
Date: Wed, 18 Oct 2006 07:08:07 +0200 [thread overview]
Message-ID: <4535B6B7.4070107@cosmosbay.com> (raw)
In-Reply-To: <452EA214.7080905@cosmosbay.com>
[-- Attachment #1: Type: text/plain, Size: 453 bytes --]
Hi David
Each route entry includes a 'struct flow'. This structure has a current size
of 80 bytes. This patch makes a size reduction depending on
CONFIG_IPV6/CONFIG_IPV6_MODULE/CONFIG_DECNET/CONFIG_IP_ROUTE_FWMARK
For a platform doing IPV4 only, the new size is 36 bytes (instead of 80)
As many routers are base on PIII (L1_CACHE_SIZE=32), this saves one cache line
per rtable entry.
Thank you
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
[-- Attachment #2: shrink_flow.patch --]
[-- Type: text/plain, Size: 4098 bytes --]
--- linux-2.6.19-rc2/include/net/flow.h 2006-10-18 06:03:08.000000000 +0200
+++ linux-2.6.19-rc2-ed/include/net/flow.h 2006-10-18 06:56:37.000000000 +0200
@@ -18,17 +18,21 @@
struct {
__be32 daddr;
__be32 saddr;
+#if defined(CONFIG_IP_ROUTE_FWMARK)
__u32 fwmark;
+#endif
__u8 tos;
__u8 scope;
} ip4_u;
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
struct {
struct in6_addr daddr;
struct in6_addr saddr;
__u32 fwmark;
__u32 flowlabel;
} ip6_u;
+#endif
struct {
__le16 daddr;
@@ -65,6 +69,7 @@
__u8 code;
} icmpt;
+#if defined(CONFIG_DECNET)
struct {
__le16 sport;
__le16 dport;
@@ -72,6 +77,7 @@
__u8 objnamel; /* Not 16 bits since max val is 16 */
__u8 objname[16]; /* Not zero terminated */
} dnports;
+#endif
__be32 spi;
--- linux-2.6.19-rc2/include/net/xfrm.h 2006-10-18 06:21:19.000000000 +0200
+++ linux-2.6.19-rc2-ed/include/net/xfrm.h 2006-10-18 06:53:41.000000000 +0200
@@ -517,6 +517,7 @@
(fl->oif == sel->ifindex || !sel->ifindex);
}
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
static inline int
__xfrm6_selector_match(struct xfrm_selector *sel, struct flowi *fl)
{
@@ -527,6 +528,7 @@
(fl->proto == sel->proto || !sel->proto) &&
(fl->oif == sel->ifindex || !sel->ifindex);
}
+#endif
static inline int
xfrm_selector_match(struct xfrm_selector *sel, struct flowi *fl,
@@ -535,8 +537,10 @@
switch (family) {
case AF_INET:
return __xfrm4_selector_match(sel, fl);
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
case AF_INET6:
return __xfrm6_selector_match(sel, fl);
+#endif
}
return 0;
}
@@ -577,7 +581,9 @@
struct xfrm_dst *next;
struct dst_entry dst;
struct rtable rt;
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
struct rt6_info rt6;
+#endif
} u;
struct dst_entry *route;
u32 genid;
@@ -650,12 +656,14 @@
tmpl->saddr.a4 != x->props.saddr.a4);
}
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
static inline int
__xfrm6_state_addr_cmp(struct xfrm_tmpl *tmpl, struct xfrm_state *x)
{
return (!ipv6_addr_any((struct in6_addr*)&tmpl->saddr) &&
ipv6_addr_cmp((struct in6_addr *)&tmpl->saddr, (struct in6_addr*)&x->props.saddr));
}
+#endif
static inline int
xfrm_state_addr_cmp(struct xfrm_tmpl *tmpl, struct xfrm_state *x, unsigned short family)
@@ -663,8 +671,10 @@
switch (family) {
case AF_INET:
return __xfrm4_state_addr_cmp(tmpl, x);
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
case AF_INET6:
return __xfrm6_state_addr_cmp(tmpl, x);
+#endif
}
return !0;
}
@@ -762,8 +772,10 @@
switch (family){
case AF_INET:
return (xfrm_address_t *)&fl->fl4_dst;
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
case AF_INET6:
return (xfrm_address_t *)&fl->fl6_dst;
+#endif
}
return NULL;
}
@@ -774,8 +786,10 @@
switch (family){
case AF_INET:
return (xfrm_address_t *)&fl->fl4_src;
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
case AF_INET6:
return (xfrm_address_t *)&fl->fl6_src;
+#endif
}
return NULL;
}
@@ -790,6 +804,7 @@
return 0;
}
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
static __inline__ int
__xfrm6_state_addr_check(struct xfrm_state *x,
xfrm_address_t *daddr, xfrm_address_t *saddr)
@@ -801,6 +816,7 @@
return 1;
return 0;
}
+#endif
static __inline__ int
xfrm_state_addr_check(struct xfrm_state *x,
@@ -810,8 +826,10 @@
switch (family) {
case AF_INET:
return __xfrm4_state_addr_check(x, daddr, saddr);
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
case AF_INET6:
return __xfrm6_state_addr_check(x, daddr, saddr);
+#endif
}
return 0;
}
@@ -825,10 +843,12 @@
return __xfrm4_state_addr_check(x,
(xfrm_address_t *)&fl->fl4_dst,
(xfrm_address_t *)&fl->fl4_src);
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
case AF_INET6:
return __xfrm6_state_addr_check(x,
(xfrm_address_t *)&fl->fl6_dst,
(xfrm_address_t *)&fl->fl6_src);
+#endif
}
return 0;
}
next prev parent reply other threads:[~2006-10-18 5:08 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20051217071029.GY23384@wotan.suse.de>
[not found] ` <20051216.231517.68922847.davem@davemloft.net>
[not found] ` <43A3EE8A.5020907@cosmosbay.com>
[not found] ` <43CCBF3D.2070900@cosmosbay.com>
[not found] ` <4415A4C1.1030906@cosmosbay.com>
2006-10-12 20:14 ` [PATCH] [NET] reduce sizeof(struct inet_peer), cleanup, change in peer_check_expire() Eric Dumazet
2006-10-12 22:15 ` David Miller
2006-10-13 3:56 ` Eric Dumazet
2006-10-13 4:18 ` David Miller
2006-10-13 4:24 ` Eric Dumazet
2006-10-18 5:08 ` Eric Dumazet [this message]
2006-10-18 5:17 ` [PATCH] [NET] reduce sizeof(struct flow) YOSHIFUJI Hideaki / 吉藤英明
2006-10-18 5:30 ` Eric Dumazet
2006-10-18 5:27 ` David Miller
2006-10-18 5:42 ` Eric Dumazet
2006-10-18 6:53 ` David Miller
2006-10-18 8:20 ` Steven Whitehouse
2006-10-18 8:55 ` Eric Dumazet
2006-10-18 12:42 ` Steven Whitehouse
2006-10-18 13:32 ` Eric Dumazet
2006-10-19 3:50 ` David Miller
2006-10-19 5:13 ` Eric Dumazet
2006-10-20 13:55 ` [PATCH] [NET] reduce sizeof(struct flowi) by 20 bytes Eric Dumazet
2006-10-22 3:25 ` David Miller
2006-10-18 11:33 ` [PATCH] [NET] reduce sizeof(struct flow) Ingo Oeser
2006-10-20 7:18 ` [PATCH] [NET] can use __get_cpu_var() instead of per_cpu() in loopback driver Eric Dumazet
2006-10-20 7:32 ` David Miller
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=4535B6B7.4070107@cosmosbay.com \
--to=dada1@cosmosbay.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.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).