net: compute a more reasonable default ip6_rt_max_size (v2)
Subsystems (3)
PATCH 1/1 net: compute a more reasonable default ip6_rt_max_size (v2)
The algorithm is based on ipv4 and alloc_large_system_hash().
The following data is from a x86_64 box I tested:
128MB
$ cat /proc/sys/net/ipv{4,6}/route/max_size
16384
22444512MB
$ cat /proc/sys/net/ipv{4,6}/route/max_size
65536
998561GB
$ cat /proc/sys/net/ipv{4,6}/route/max_size
524288
2030682GB
$ cat /proc/sys/net/ipv{4,6}/route/max_size
1048576
5242884GB
$ cat /proc/sys/net/ipv{4,6}/route/max_size
2097152
524288Signed-off-by Arun Sharma <[email protected]>
Cc David Miller <[email protected]>
--- net/ipv6/route.c | 21 ++++++++++++++++++++- 1 files changed, 20 insertions(+), 1 deletions(-)
net/ipv6/route.c +20 -1
@@ -2827,6 +2827,16 @@ struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net) }#endif +static __initdata unsigned long ip6_rt_entries; +static int __init set_rt_entries (char *str) +{ +if (!str) +return 0 ; + ip6_rt_entries =simple_strtoul (str, &str,0 ); +return 1 ; +} +__setup ("ip6_rt_entries=" , set_rt_entries); +static int __net_init ip6_route_net_init (struct net *net) {int ret = -ENOMEM ;
@@ -2872,8 +2882,17 @@ static int __net_init ip6_route_net_init(struct net *net) ip6_template_metrics, true);#endif +/* Compute a reasonable default based on what we do for ipv4 +* total size = 1/16th of total RAM +* No more than 512k entries unless overridden on kernel cmdline */ +if (ip6_rt_entries ==0 ) { + ip6_rt_entries = (totalram_pages <<PAGE_SHIFT ) >>4 ; + ip6_rt_entries /=sizeof (struct rt6_info ); + ip6_rt_entries =min (512 *1024UL , ip6_rt_entries); + } + net->ipv6.sysctl.flush_delay =0 ; - net->ipv6.sysctl.ip6_rt_max_size =4096 ; + net->ipv6.sysctl.ip6_rt_max_size = ip6_rt_entries; net->ipv6.sysctl.ip6_rt_gc_min_interval =HZ /2 ; net->ipv6.sysctl.ip6_rt_gc_timeout =60 *HZ ; net->ipv6.sysctl.ip6_rt_gc_interval =30 *HZ ;
Signature · 1 line
1.7.8.4