mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 21:38:32 +08:00
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>
This commit is contained in:
parent
c60ce4e265
commit
8e602ce298
@ -41,6 +41,8 @@ struct net {
|
|||||||
* destroy on demand
|
* destroy on demand
|
||||||
*/
|
*/
|
||||||
#endif
|
#endif
|
||||||
|
spinlock_t rules_mod_lock;
|
||||||
|
|
||||||
struct list_head list; /* list of network namespaces */
|
struct list_head list; /* list of network namespaces */
|
||||||
struct list_head cleanup_list; /* namespaces on death row */
|
struct list_head cleanup_list; /* namespaces on death row */
|
||||||
struct list_head exit_list; /* Use only net_mutex */
|
struct list_head exit_list; /* Use only net_mutex */
|
||||||
@ -52,7 +54,8 @@ struct net {
|
|||||||
struct ctl_table_set sysctls;
|
struct ctl_table_set sysctls;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct net_device *loopback_dev; /* The loopback */
|
struct sock *rtnl; /* rtnetlink socket */
|
||||||
|
struct sock *genl_sock;
|
||||||
|
|
||||||
struct list_head dev_base_head;
|
struct list_head dev_base_head;
|
||||||
struct hlist_head *dev_name_head;
|
struct hlist_head *dev_name_head;
|
||||||
@ -60,11 +63,9 @@ struct net {
|
|||||||
|
|
||||||
/* core fib_rules */
|
/* core fib_rules */
|
||||||
struct list_head rules_ops;
|
struct list_head rules_ops;
|
||||||
spinlock_t rules_mod_lock;
|
|
||||||
|
|
||||||
struct sock *rtnl; /* rtnetlink socket */
|
|
||||||
struct sock *genl_sock;
|
|
||||||
|
|
||||||
|
struct net_device *loopback_dev; /* The loopback */
|
||||||
struct netns_core core;
|
struct netns_core core;
|
||||||
struct netns_mib mib;
|
struct netns_mib mib;
|
||||||
struct netns_packet packet;
|
struct netns_packet packet;
|
||||||
@ -84,13 +85,15 @@ struct net {
|
|||||||
struct sock *nfnl;
|
struct sock *nfnl;
|
||||||
struct sock *nfnl_stash;
|
struct sock *nfnl_stash;
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_XFRM
|
|
||||||
struct netns_xfrm xfrm;
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_WEXT_CORE
|
#ifdef CONFIG_WEXT_CORE
|
||||||
struct sk_buff_head wext_nlevents;
|
struct sk_buff_head wext_nlevents;
|
||||||
#endif
|
#endif
|
||||||
struct net_generic *gen;
|
struct net_generic *gen;
|
||||||
|
|
||||||
|
/* Note : following structs are cache line aligned */
|
||||||
|
#ifdef CONFIG_XFRM
|
||||||
|
struct netns_xfrm xfrm;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,10 +43,6 @@ struct netns_xfrm {
|
|||||||
unsigned int policy_count[XFRM_POLICY_MAX * 2];
|
unsigned int policy_count[XFRM_POLICY_MAX * 2];
|
||||||
struct work_struct policy_hash_work;
|
struct work_struct policy_hash_work;
|
||||||
|
|
||||||
struct dst_ops xfrm4_dst_ops;
|
|
||||||
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
|
|
||||||
struct dst_ops xfrm6_dst_ops;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct sock *nlsk;
|
struct sock *nlsk;
|
||||||
struct sock *nlsk_stash;
|
struct sock *nlsk_stash;
|
||||||
@ -58,6 +54,11 @@ struct netns_xfrm {
|
|||||||
#ifdef CONFIG_SYSCTL
|
#ifdef CONFIG_SYSCTL
|
||||||
struct ctl_table_header *sysctl_hdr;
|
struct ctl_table_header *sysctl_hdr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct dst_ops xfrm4_dst_ops;
|
||||||
|
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
|
||||||
|
struct dst_ops xfrm6_dst_ops;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user