Skip to contentSkip to conversation

ipv6: use DST_NOCOUNT in ip6_rt_pcpu_alloc()

PATCH Applied Eric Dumazet 5 participants 7 messages May 8, 2020 – May 9, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipv6: use DST_NOCOUNT in ip6_rt_pcpu_alloc()

We currently have to adjust ipv6 route gc_thresh/max_size depending on number of cpus on a server, this makes very little sense.

If the kernels sets /proc/sys/net/ipv6/route/gc_thresh to 1024 and /proc/sys/net/ipv6/route/max_size to 4096, then we better not track the percpu dst that our implementation uses.

Only routes not added (directly or indirectly) by the admin should be tracked and limited.

Cc Martin KaFai Lau <[email protected]>
Cc David Ahern <[email protected]>
Cc Wei Wang <[email protected]>
Cc Maciej Żenczykowski <[email protected]>
---
 net/ipv6/route.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/route.c +1 -1
index a9072dba00f4fb0b61bce1fc0f44a3a81ba702fa..4292653af533bb641ae8571fffe45b39327d0380 100644
@@ -1377,7 +1377,7 @@ static struct rt6_info *ip6_rt_pcpu_alloc(const struct fib6_result *res)
 
 	rcu_read_lock();
 	dev = ip6_rt_get_dev_rcu(res);
-	pcpu_rt = ip6_dst_alloc(dev_net(dev), dev, flags);
+	pcpu_rt = ip6_dst_alloc(dev_net(dev), dev, flags | DST_NOCOUNT);
 	rcu_read_unlock();
 	if (!pcpu_rt) {
 		fib6_info_release(f6i);
Signature · 1 line
2.26.2.645.ge9eca65c58-goog
#1 lore raw
Quoted 25 lines · Eric Dumazet

We currently have to adjust ipv6 route gc_thresh/max_size depending on number of cpus on a server, this makes very little sense.

If the kernels sets /proc/sys/net/ipv6/route/gc_thresh to 1024 and /proc/sys/net/ipv6/route/max_size to 4096, then we better not track the percpu dst that our implementation uses.

Only routes not added (directly or indirectly) by the admin should be tracked and limited.

Cc Martin KaFai Lau <[email protected]>
Cc David Ahern <[email protected]>
Cc Wei Wang <[email protected]>
Cc Maciej Żenczykowski <[email protected]>
---
 net/ipv6/route.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/route.c +0 -0
index a9072dba00f4fb0b61bce1fc0f44a3a81ba702fa..4292653af533bb641ae8571fffe45b39327d0380 100644

net/ipv6/route.c static struct rt6_info *ip6_rt_pcpu_alloc(const struct fib6_result *res) · line 1383

Quoted 8 lines
net/ipv6/route.c +1 -1
@@ -1377,7 +1377,7 @@ static struct rt6_info *ip6_rt_pcpu_alloc(const struct fib6_result *res)
 
 	rcu_read_lock();
 	dev = ip6_rt_get_dev_rcu(res);
-	pcpu_rt = ip6_dst_alloc(dev_net(dev), dev, flags);
+	pcpu_rt = ip6_dst_alloc(dev_net(dev), dev, flags | DST_NOCOUNT);
 	rcu_read_unlock();
 	if (!pcpu_rt) {
 		fib6_info_release(f6i);

At this point in IPv6's evolution it seems like it can align more with IPv4 and just get rid of the dst limits completely.

#2 lore raw
Quoted 26 lines · David Ahern
Quoted 25 lines · Eric Dumazet

We currently have to adjust ipv6 route gc_thresh/max_size depending on number of cpus on a server, this makes very little sense.

If the kernels sets /proc/sys/net/ipv6/route/gc_thresh to 1024 and /proc/sys/net/ipv6/route/max_size to 4096, then we better not track the percpu dst that our implementation uses.

Only routes not added (directly or indirectly) by the admin should be tracked and limited.

Cc Martin KaFai Lau <[email protected]>
Cc David Ahern <[email protected]>
Cc Wei Wang <[email protected]>
Cc Maciej Żenczykowski <[email protected]>
---
 net/ipv6/route.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/route.c +0 -0
index a9072dba00f4fb0b61bce1fc0f44a3a81ba702fa..4292653af533bb641ae8571fffe45b39327d0380 100644
@@ -1377,7 +1377,7 @@ static struct rt6_info *ip6_rt_pcpu_alloc(const struct fib6_result *res)
 
Quoted 12 lines

net/ipv6/route.c static struct rt6_info *ip6_rt_pcpu_alloc(const struct fib6_result *res) · line 1383

Quoted 8 lines
net/ipv6/route.c +1 -1
 	rcu_read_lock();
 	dev = ip6_rt_get_dev_rcu(res);
-	pcpu_rt = ip6_dst_alloc(dev_net(dev), dev, flags);
+	pcpu_rt = ip6_dst_alloc(dev_net(dev), dev, flags | DST_NOCOUNT);
 	rcu_read_unlock();
 	if (!pcpu_rt) {
 		fib6_info_release(f6i);

At this point in IPv6's evolution it seems like it can align more with IPv4 and just get rid of the dst limits completely.

This patch can be backported without any pains ;)

Getting rid of limits, even for exceptions ?

#3 lore raw
Quoted 1 line · Eric Dumazet

This patch can be backported without any pains ;)

sure, but you tagged it as net-next, not net.

Quoted 2 lines

Getting rid of limits, even for exceptions ?

Running through where dst entries are created in IPv6:
1. pcpu cache
2. uncached_list
3. exceptions like pmtu and redirect

All of those match IPv4 and as I recall IPv4 does not have any limits, even on exceptions and redirect. If IPv4 does not have limits, why should IPv6? And if the argument is uncontrolled memory consumption, is there an expectation that IPv6 generates more exceptions?

My argument really just boils down to consistency between them. IPv4 does not use DST_NOCOUNT, so why put that burden on v6?

#4 lore raw
Quoted 5 lines · David Ahern
Quoted 1 line · Eric Dumazet

This patch can be backported without any pains ;)

sure, but you tagged it as net-next, not net.

Because it is not a recent regression.
We are late in rc cycle.

I tend to push patches on net-next, then ask later for stable backports once we are sure no regression was added, even for patches that look 'very safe' ;)

Quoted 9 lines
Quoted 3 lines

Getting rid of limits, even for exceptions ?

Running through where dst entries are created in IPv6:
1. pcpu cache
2. uncached_list
3. exceptions like pmtu and redirect

Quoted 7 lines

All of those match IPv4 and as I recall IPv4 does not have any limits, even on exceptions and redirect. If IPv4 does not have limits, why should IPv6? And if the argument is uncontrolled memory consumption, is there an expectation that IPv6 generates more exceptions?

My argument really just boils down to consistency between them. IPv4 does not use DST_NOCOUNT, so why put that burden on v6?

That is something that needs further investigation. Too many fires at this moment on my plate.

My patch stops bleeding right now.

Thanks.

Acked-by on v1 1/1
#5 lore raw
In reply to Eric Dumazet
Quoted 11 lines · Eric Dumazet

We currently have to adjust ipv6 route gc_thresh/max_size depending on number of cpus on a server, this makes very little sense.

If the kernels sets /proc/sys/net/ipv6/route/gc_thresh to 1024 and /proc/sys/net/ipv6/route/max_size to 4096, then we better not track the percpu dst that our implementation uses.

Only routes not added (directly or indirectly) by the admin should be tracked and limited.

Quoted 6 lines
Cc Martin KaFai Lau <[email protected]>
Cc David Ahern <[email protected]>
Cc Wei Wang <[email protected]>
Cc Maciej Żenczykowski <[email protected]>

---

Quoted 20 lines
 net/ipv6/route.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/route.c +1 -2
index a9072dba00f4fb0b61bce1fc0f44a3a81ba702fa..4292653af533bb641ae8571fffe45b39327d0380 100644
@@ -1377,7 +1377,7 @@ static struct rt6_info *ip6_rt_pcpu_alloc(const struct fib6_result *res)
 
        rcu_read_lock();
        dev = ip6_rt_get_dev_rcu(res);
-       pcpu_rt = ip6_dst_alloc(dev_net(dev), dev, flags);
+       pcpu_rt = ip6_dst_alloc(dev_net(dev), dev, flags | DST_NOCOUNT);
        rcu_read_unlock();
        if (!pcpu_rt) {
                fib6_info_release(f6i);
--

2.26.2.645.ge9eca65c58-goog

maintainer Applied
#6 lore raw
In reply to Eric Dumazet
Quoted 11 lines · On Fri, 8 May 2020 07:34:14 -0700 Eric Dumazet wrote:

We currently have to adjust ipv6 route gc_thresh/max_size depending on number of cpus on a server, this makes very little sense.

If the kernels sets /proc/sys/net/ipv6/route/gc_thresh to 1024 and /proc/sys/net/ipv6/route/max_size to 4096, then we better not track the percpu dst that our implementation uses.

Only routes not added (directly or indirectly) by the admin should be tracked and limited.

Applied, thank you!