Commit d07418a
ipv4: avoid quadratic behavior in netns dismantle
net/ipv4/fib_semantics.c uses an hash table of 256 slots,
keyed by device ifindexes: fib_info_devhash[DEVINDEX_HASHSIZE]
Problem is that with network namespaces, devices tend
to use the same ifindex.
lo device for instance has a fixed ifindex of one,
for all network namespaces.
This means that hosts with thousands of netns spend
a lot of time looking at some hash buckets with thousands
of elements, notably at netns dismantle.
Simply add a per netns perturbation (net_hash_mix())
to spread elements more uniformely.
Also change fib_devindex_hashfn() to use more entropy.
Fixes: aa79e66 ("net: Make ifindex generation per-net namespace")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>1 parent 8eb896a commit d07418a
1 file changed
Lines changed: 17 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
319 | 320 | | |
320 | 321 | | |
321 | 322 | | |
322 | | - | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
323 | 330 | | |
324 | | - | |
325 | | - | |
326 | | - | |
| 331 | + | |
327 | 332 | | |
328 | 333 | | |
329 | 334 | | |
| |||
433 | 438 | | |
434 | 439 | | |
435 | 440 | | |
436 | | - | |
437 | 441 | | |
438 | 442 | | |
439 | 443 | | |
440 | | - | |
441 | | - | |
| 444 | + | |
| 445 | + | |
442 | 446 | | |
443 | 447 | | |
444 | 448 | | |
| |||
1609 | 1613 | | |
1610 | 1614 | | |
1611 | 1615 | | |
1612 | | - | |
1613 | 1616 | | |
1614 | 1617 | | |
1615 | 1618 | | |
1616 | | - | |
1617 | | - | |
| 1619 | + | |
1618 | 1620 | | |
1619 | 1621 | | |
1620 | 1622 | | |
| |||
1966 | 1968 | | |
1967 | 1969 | | |
1968 | 1970 | | |
1969 | | - | |
1970 | | - | |
| 1971 | + | |
1971 | 1972 | | |
1972 | 1973 | | |
1973 | 1974 | | |
| |||
1986 | 1987 | | |
1987 | 1988 | | |
1988 | 1989 | | |
1989 | | - | |
1990 | | - | |
| 1990 | + | |
1991 | 1991 | | |
1992 | | - | |
1993 | | - | |
| 1992 | + | |
1994 | 1993 | | |
| 1994 | + | |
1995 | 1995 | | |
1996 | 1996 | | |
1997 | 1997 | | |
| |||
2136 | 2136 | | |
2137 | 2137 | | |
2138 | 2138 | | |
2139 | | - | |
2140 | 2139 | | |
2141 | 2140 | | |
2142 | 2141 | | |
| |||
2152 | 2151 | | |
2153 | 2152 | | |
2154 | 2153 | | |
2155 | | - | |
2156 | | - | |
| 2154 | + | |
2157 | 2155 | | |
2158 | 2156 | | |
2159 | 2157 | | |
| |||
0 commit comments