diff options
| author | Eric Dumazet <eric.dumazet@gmail.com> | 2010-10-14 01:56:18 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2010-10-17 16:49:14 -0400 |
| commit | 8e602ce2980fd6941dc0d3dda12e5095e8206f34 (patch) | |
| tree | 1a0ea79a6db1b01660cc034c822d02c95e356388 /include/net | |
| parent | c60ce4e265404ca42ba860401f4b0f1e97332a67 (diff) | |
netns: reorder fields in struct net
In a network bench, I noticed an unfortunate false sharing between
'loopback_dev' and 'count' fields in "struct net".
'count' is written each time a socket is created or destroyed, while
loopback_dev might be often read in routing code.
Move loopback_dev in a read mostly section of "struct net"
Note: struct netns_xfrm is cache line aligned on SMP.
(It contains a "struct dst_ops")
Move it at the end to avoid holes, and reduce sizeof(struct net) by 128
bytes on ia32.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
| -rw-r--r-- | include/net/net_namespace.h | 17 | ||||
| -rw-r--r-- | include/net/netns/xfrm.h | 9 |
2 files changed, 15 insertions, 11 deletions
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index bd10a7908993..65af9a07cf76 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h | |||
| @@ -41,6 +41,8 @@ struct net { | |||
| 41 | * destroy on demand | 41 | * destroy on demand |
| 42 | */ | 42 | */ |
| 43 | #endif | 43 | #endif |
| 44 | spinlock_t rules_mod_lock; | ||
| 45 | |||
| 44 | struct list_head list; /* list of network namespaces */ | 46 | struct list_head list; /* list of network namespaces */ |
| 45 | struct list_head cleanup_list; /* namespaces on death row */ | 47 | struct list_head cleanup_list; /* namespaces on death row */ |
| 46 | struct list_head exit_list; /* Use only net_mutex */ | 48 | struct list_head exit_list; /* Use only net_mutex */ |
| @@ -52,7 +54,8 @@ struct net { | |||
| 52 | struct ctl_table_set sysctls; | 54 | struct ctl_table_set sysctls; |
| 53 | #endif | 55 | #endif |
| 54 | 56 | ||
| 55 | struct net_device *loopback_dev; /* The loopback */ | 57 | struct sock *rtnl; /* rtnetlink socket */ |
| 58 | struct sock *genl_sock; | ||
| 56 | 59 | ||
| 57 | struct list_head dev_base_head; | 60 | struct list_head dev_base_head; |
| 58 | struct hlist_head *dev_name_head; | 61 | struct hlist_head *dev_name_head; |
| @@ -60,11 +63,9 @@ struct net { | |||
| 60 | 63 | ||
| 61 | /* core fib_rules */ | 64 | /* core fib_rules */ |
| 62 | struct list_head rules_ops; | 65 | struct list_head rules_ops; |
| 63 | spinlock_t rules_mod_lock; | ||
| 64 | 66 | ||
| 65 | struct sock *rtnl; /* rtnetlink socket */ | ||
| 66 | struct sock *genl_sock; | ||
| 67 | 67 | ||
| 68 | struct net_device *loopback_dev; /* The loopback */ | ||
| 68 | struct netns_core core; | 69 | struct netns_core core; |
| 69 | struct netns_mib mib; | 70 | struct netns_mib mib; |
| 70 | struct netns_packet packet; | 71 | struct netns_packet packet; |
| @@ -84,13 +85,15 @@ struct net { | |||
| 84 | struct sock *nfnl; | 85 | struct sock *nfnl; |
| 85 | struct sock *nfnl_stash; | 86 | struct sock *nfnl_stash; |
| 86 | #endif | 87 | #endif |
| 87 | #ifdef CONFIG_XFRM | ||
| 88 | struct netns_xfrm xfrm; | ||
| 89 | #endif | ||
| 90 | #ifdef CONFIG_WEXT_CORE | 88 | #ifdef CONFIG_WEXT_CORE |
| 91 | struct sk_buff_head wext_nlevents; | 89 | struct sk_buff_head wext_nlevents; |
| 92 | #endif | 90 | #endif |
| 93 | struct net_generic *gen; | 91 | struct net_generic *gen; |
| 92 | |||
| 93 | /* Note : following structs are cache line aligned */ | ||
| 94 | #ifdef CONFIG_XFRM | ||
| 95 | struct netns_xfrm xfrm; | ||
| 96 | #endif | ||
| 94 | }; | 97 | }; |
| 95 | 98 | ||
| 96 | 99 | ||
diff --git a/include/net/netns/xfrm.h b/include/net/netns/xfrm.h index 74f119a2829a..748f91f87cd5 100644 --- a/include/net/netns/xfrm.h +++ b/include/net/netns/xfrm.h | |||
| @@ -43,10 +43,6 @@ struct netns_xfrm { | |||
| 43 | unsigned int policy_count[XFRM_POLICY_MAX * 2]; | 43 | unsigned int policy_count[XFRM_POLICY_MAX * 2]; |
| 44 | struct work_struct policy_hash_work; | 44 | struct work_struct policy_hash_work; |
| 45 | 45 | ||
| 46 | struct dst_ops xfrm4_dst_ops; | ||
| 47 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | ||
| 48 | struct dst_ops xfrm6_dst_ops; | ||
| 49 | #endif | ||
| 50 | 46 | ||
| 51 | struct sock *nlsk; | 47 | struct sock *nlsk; |
| 52 | struct sock *nlsk_stash; | 48 | struct sock *nlsk_stash; |
| @@ -58,6 +54,11 @@ struct netns_xfrm { | |||
| 58 | #ifdef CONFIG_SYSCTL | 54 | #ifdef CONFIG_SYSCTL |
| 59 | struct ctl_table_header *sysctl_hdr; | 55 | struct ctl_table_header *sysctl_hdr; |
| 60 | #endif | 56 | #endif |
| 57 | |||
| 58 | struct dst_ops xfrm4_dst_ops; | ||
| 59 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | ||
| 60 | struct dst_ops xfrm6_dst_ops; | ||
| 61 | #endif | ||
| 61 | }; | 62 | }; |
| 62 | 63 | ||
| 63 | #endif | 64 | #endif |
