Skip to content

Commit

Permalink
[IPV4] route cache: Introduce rt_genid for smooth cache invalidation
Browse files Browse the repository at this point in the history
Current ip route cache implementation is not suited to large caches.

We can consume a lot of CPU when cache must be invalidated, since we
currently need to evict all cache entries, and this eviction is
sometimes asynchronous. min_delay & max_delay can somewhat control this
asynchronism behavior, but whole thing is a kludge, regularly triggering
infamous soft lockup messages. When entries are still in use, this also
consumes a lot of ram, filling dst_garbage.list.

A better scheme is to use a generation identifier on each entry,
so that cache invalidation can be performed by changing the table
identifier, without having to scan all entries.
No more delayed flushing, no more stalling when secret_interval expires.

Invalidated entries will then be freed at GC time (controled by
ip_rt_gc_timeout or stress), or when an invalidated entry is found
in a chain when an insert is done.
Thus we keep a normal equilibrium.

This patch :
- renames rt_hash_rnd to rt_genid (and makes it an atomic_t)
- Adds a new rt_genid field to 'struct rtable' (filling a hole on 64bit)
- Checks entry->rt_genid at appropriate places :
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Feb 1, 2008
1 parent 174ce04 commit 29e7525
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 127 deletions.
5 changes: 0 additions & 5 deletions Documentation/filesystems/proc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1919,11 +1919,6 @@ max_size
Maximum size of the routing cache. Old entries will be purged once the cache
reached has this size.

max_delay, min_delay
--------------------

Delays for flushing the routing cache.

redirect_load, redirect_number
------------------------------

Expand Down
4 changes: 2 additions & 2 deletions include/linux/sysctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,8 @@ enum

enum {
NET_IPV4_ROUTE_FLUSH=1,
NET_IPV4_ROUTE_MIN_DELAY=2,
NET_IPV4_ROUTE_MAX_DELAY=3,
NET_IPV4_ROUTE_MIN_DELAY=2, /* obsolete since 2.6.25 */
NET_IPV4_ROUTE_MAX_DELAY=3, /* obsolete since 2.6.25 */
NET_IPV4_ROUTE_GC_THRESH=4,
NET_IPV4_ROUTE_MAX_SIZE=5,
NET_IPV4_ROUTE_GC_MIN_INTERVAL=6,
Expand Down
1 change: 1 addition & 0 deletions include/net/route.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ struct rtable

struct in_device *idev;

int rt_genid;
unsigned rt_flags;
__u16 rt_type;

Expand Down
Loading

0 comments on commit 29e7525

Please sign in to comment.