Skip to contentSkip to conversation

Strange CPU load when flushing route cache (kernel 2.6.31.6)

DISCUSSION Jesper Dangaard Brouer 4 participants 9 messages Nov 23, 2009 – Nov 26, 2009

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

Hi Eric and netdev,

I have observed a strange route cache behaviour when I upgraded some of my production Linux routers (1Gbit/s tg3) to kernel 2.6.31.6 (from kernel 2.6.25.7).

Every time the route cache is flushed I get a CPU spike (in softirq) with a tail. I have attached some graphs that illustrate the issue (hope vger.kernel.org will allow these attachments...)

I have done some tuning of the route cache:

# From /etc/sysctl.conf
#
# Adjusting the route cache flush interval
net/ipv4/route/secret_interval = 1200

# Limiting the route cache size

 # ip_dst_cache slab objects is 256 bytes.
 # 2000000 * 256 bytes = 512 MB
 net/ipv4/route/max_size = 2000000

Boot parameters: "rhash_entries=262143 vmalloc=256M"

The rhash_entries is for the route cache hash size. The vmalloc is needed because I have _very_ large iptables rulesets (and is running on a 32-bit kernel, due to old hardware).

Any thoughs on how to avoid these CPU spikes?
Or where the issue occurs in the code?

Signature · 7 lines
Med venlig hilsen / Best regards
  Jesper Brouer
  ComX Networks A/S
  Linux Network Kernel Developer
  Cand. Scient Datalog / MSc.CS
  Author of http://adsl-optimizer.dk
  LinkedIn: http://www.linkedin.com/in/brouer
#1 lore raw
Quoted 23 lines · Jesper Dangaard Brouer

Hi Eric and netdev,

I have observed a strange route cache behaviour when I upgraded some of my production Linux routers (1Gbit/s tg3) to kernel 2.6.31.6 (from kernel 2.6.25.7).

Every time the route cache is flushed I get a CPU spike (in softirq) with a tail. I have attached some graphs that illustrate the issue (hope vger.kernel.org will allow these attachments...)

I have done some tuning of the route cache:

# From /etc/sysctl.conf
#
# Adjusting the route cache flush interval
net/ipv4/route/secret_interval = 1200

# Limiting the route cache size

 # ip_dst_cache slab objects is 256 bytes.
 # 2000000 * 256 bytes = 512 MB
 net/ipv4/route/max_size = 2000000
Quoted 9 lines

Boot parameters: "rhash_entries=262143 vmalloc=256M"

The rhash_entries is for the route cache hash size. The vmalloc is needed because I have _very_ large iptables rulesets (and is running on a 32-bit kernel, due to old hardware).

Any thoughs on how to avoid these CPU spikes?
Or where the issue occurs in the code?

Sure, after a flush, we have to rebuild the cache, so extra work is expected.

(We receive a packet, notice the cached entry is obsolete, free it, allocate a new one and inert it into cache)

If you dont want these spikes, just dont flush cache :)

Do you run a 2G/2G User/Kernel split kernel ?

#2 lore raw
Quoted 30 lines · Eric Dumazet
Quoted 29 lines · Jesper Dangaard Brouer

Hi Eric and netdev,

I have observed a strange route cache behaviour when I upgraded some of my production Linux routers (1Gbit/s tg3) to kernel 2.6.31.6 (from kernel 2.6.25.7).

Every time the route cache is flushed I get a CPU spike (in softirq) with a tail. I have attached some graphs that illustrate the issue (hope vger.kernel.org will allow these attachments...)

I have done some tuning of the route cache:

# From /etc/sysctl.conf
#
# Adjusting the route cache flush interval
net/ipv4/route/secret_interval = 1200

# Limiting the route cache size

 # ip_dst_cache slab objects is 256 bytes.
 # 2000000 * 256 bytes = 512 MB
 net/ipv4/route/max_size = 2000000

Boot parameters: "rhash_entries=262143 vmalloc=256M"

The rhash_entries is for the route cache hash size. The vmalloc is needed because I have _very_ large iptables rulesets (and is running on a 32-bit kernel, due to old hardware).

Quoted 5 lines
Quoted 3 lines

Any thoughs on how to avoid these CPU spikes?
Or where the issue occurs in the code?

Sure, after a flush, we have to rebuild the cache, so extra work is expected.

But the old 2.6.25.7 do NOT show this behavior... That is the real issue...

Quoted 4 lines

(We receive a packet, notice the cached entry is obsolete, free it, allocate a new one and inert it into cache)

If you dont want these spikes, just dont flush cache :)

I did the cache flushing due to some historical issues, that I think you did a fix for... Guess I can drop the flushing and see if the garbage collection can keep up...

Quoted 1 line

Do you run a 2G/2G User/Kernel split kernel ?

Not sure, how do I check?

I do use a 32-bit kernel (due to the production machines runs an old 32-bit Slackware OS install and some of the machines cannot run 64-bit).

Signature · 7 lines
Med venlig hilsen / Best regards
  Jesper Brouer
  ComX Networks A/S
  Linux Network Kernel Developer
  Cand. Scient Datalog / MSc.CS
  Author of http://adsl-optimizer.dk
  LinkedIn: http://www.linkedin.com/in/brouer
#3 lore raw
Quoted 6 lines · Jesper Dangaard Brouer
Quoted 1 line · Eric Dumazet

Sure, after a flush, we have to rebuild the cache, so extra work is expected.

But the old 2.6.25.7 do NOT show this behavior... That is the real issue...

Previous kernels were crashing, because flush was immediate and not deferred as today.

During flush, we were dropping enormous amounts of packets.

Now, its possible to have setups with equilibrium and no packet loss, because we smoothtly invalidate cache entries.

Quoted 3 lines

I did the cache flushing due to some historical issues, that I think you did a fix for... Guess I can drop the flushing and see if the garbage collection can keep up...

Yes it can. Unless your route cache settings are not optimal.

Quoted 4 lines
Quoted 2 lines

Do you run a 2G/2G User/Kernel split kernel ?

Not sure, how do I check?

grep LowTotal /proc/meminfo

or

dmesg | grep LOWMEM
913MB LOWMEM available. (standard 3G/1G User/Kernel split)

#4 lore raw
Quoted 5 lines · Eric Dumazet
Quoted 4 lines · Jesper Dangaard Brouer
Quoted 1 line · Eric Dumazet

Sure, after a flush, we have to rebuild the cache, so extra work is expected.

Quoted 7 lines
Quoted 2 lines

But the old 2.6.25.7 do NOT show this behavior... That is the real issue...

Previous kernels were crashing, because flush was immediate and not deferred as today.

During flush, we were dropping enormous amounts of packets.

Ahh... Now I remember that was why I was flushing the cache so often. If I flushed the route cache before it got too big then it was not a problem with packet drops occuring.

Quoted 2 lines

Now, its possible to have setups with equilibrium and no packet loss, because we smoothtly invalidate cache entries.

Which is a good thing :-)

Quoted 5 lines
Quoted 3 lines

I did the cache flushing due to some historical issues, that I think you did a fix for... Guess I can drop the flushing and see if the garbage collection can keep up...

Yes it can. Unless your route cache settings are not optimal.

I'll adjust my flushing interval, or disable it and monitor it.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Do you run a 2G/2G User/Kernel split kernel ?

Not sure, how do I check?

grep LowTotal /proc/meminfo

Yes, guess I'm using User/Kernel split.

grep LowTotal /proc/meminfo
LowTotal: 747080 kB

What does that mean? Is it bad? What should I run on a 32-bit system/kernel?

Can you recommend any other /proc/sys/ tuning options?

Does my kernel boot option rhash_entries=262143 make sense anymore? Or do we adjust the hash bucket size dynamically these days?

Cheers,
Jesper Brouer

--
-------------------------------------------------------------------
MSc. Master of Computer Science
Dept. of Computer Science, University of Copenhagen Author of http://www.adsl-optimizer.dk
-------------------------------------------------------------------

#5 lore raw
Quoted 6 lines

grep LowTotal /proc/meminfo
LowTotal: 747080 kB

What does that mean? Is it bad? What should I run on a 32-bit system/kernel?

If you have more than 1GB of physical ram, and use your machine as a router, you might compile a 2GB/2GB User/Kernel kernel, to get twice available RAM for kernel and more IP route entries (if needed)

make menuconfig
--> Processor type and features
--> Memory split

    --> 2G/2G
Quoted 1 line

Can you recommend any other /proc/sys/ tuning options?

Really hard to say without exact context of use :)

Quoted 4 lines

Does my kernel boot option rhash_entries=262143 make sense anymore? Or do we adjust the hash bucket size dynamically these days?

Its not dynamic yet.

#6 lore raw
Quoted 9 lines · Eric Dumazet
Quoted 5 lines

grep LowTotal /proc/meminfo
LowTotal: 747080 kB

What does that mean? Is it bad? What should I run on a 32-bit system/kernel?

If you have more than 1GB of physical ram, and use your machine as a router, you might compile a 2GB/2GB User/Kernel kernel, to get twice available RAM for kernel and more IP route entries (if needed)

Can I still use this option if the machine "only" have 2G of physical RAM? Most of my production machines have 2G RAM.

Just to verify: This is not an issue on 64-bit kernels right?

Quoted 4 lines

make menuconfig
--> Processor type and features
--> Memory split

    --> 2G/2G

For completeness sake, Memory split depends on "if EMBEDDED"

So I also needed to enable:

make menuconfig
--> General setup

     --> Configure standard kernel features (for small systems) 
Quoted 3 lines
Quoted 1 line

Can you recommend any other /proc/sys/ tuning options?

Really hard to say without exact context of use :)

The machines does Internet traffic routing, but with a VERY large iptables rulesets, e.g. on one production machine I have 18409 chains and 62916 iptables rules. (I did most of the scalability patches to iptables userspace to make this work...). And the machines also uses a very large HTB tree. Basically I do, per customer, Access Control, Bandwidth limiting and Personal firewall.

Also note that I'm reserving extra vmalloc memory as iptables uses vmalloc'ed memory...

Quoted 5 lines
Quoted 3 lines

Does my kernel boot option rhash_entries=262143 make sense anymore? Or do we adjust the hash bucket size dynamically these days?

Its not dynamic yet.

Okay I'll keep boot parameter then... or is it possible to resize the hash runtime?

Signature · 7 lines
Med venlig hilsen / Best regards
  Jesper Brouer
  ComX Networks A/S
  Linux Network Kernel Developer
  Cand. Scient Datalog / MSc.CS
  Author of http://adsl-optimizer.dk
  LinkedIn: http://www.linkedin.com/in/brouer
#7 lore raw
Quoted 6 lines · Jesper Dangaard Brouer
Quoted 5 lines · Eric Dumazet
Quoted 5 lines

grep LowTotal /proc/meminfo
LowTotal: 747080 kB

What does that mean? Is it bad? What should I run on a 32-bit system/kernel?

Quoted 8 lines
Quoted 3 lines

If you have more than 1GB of physical ram, and use your machine as a router, you might compile a 2GB/2GB User/Kernel kernel, to get twice available RAM for kernel and more IP route entries (if needed)

Can I still use this option if the machine "only" have 2G of physical RAM? Most of my production machines have 2G RAM.

Just to verify: This is not an issue on 64-bit kernels right?

If your kernel is 32bit, and you have 2GB of ram, then selecting a 2G/2G split allows your kernel to use more ram (This is called LOWMEM.

Yes, this not an issue on 64bits kernels : All RAM is LOWMEM :)

Quoted 25 lines
Quoted 5 lines

make menuconfig
--> Processor type and features
--> Memory split

    --> 2G/2G

For completeness sake, Memory split depends on "if EMBEDDED"

So I also needed to enable:

make menuconfig
--> General setup

     --> Configure standard kernel features (for small systems) 
Quoted 2 lines
Quoted 1 line

Can you recommend any other /proc/sys/ tuning options?

Really hard to say without exact context of use :)

The machines does Internet traffic routing, but with a VERY large iptables rulesets, e.g. on one production machine I have 18409 chains and 62916 iptables rules. (I did most of the scalability patches to iptables userspace to make this work...). And the machines also uses a very large HTB tree. Basically I do, per customer, Access Control, Bandwidth limiting and Personal firewall.

Quoted 7 lines

Also note that I'm reserving extra vmalloc memory as iptables uses vmalloc'ed memory...

Okay I'll keep boot parameter then... or is it possible to resize the hash runtime?

Nope, we use RCU lookups, so a resize would be complex.

#8 lore raw
In reply to Jesper Dangaard Brouer
Quoted 7 lines · Jesper Dangaard Brouer

I have observed a strange route cache behaviour when I upgraded some of my production Linux routers (1Gbit/s tg3) to kernel 2.6.31.6 (from kernel 2.6.25.7).

Every time the route cache is flushed I get a CPU spike (in softirq) with a tail. I have attached some graphs that illustrate the issue (hope vger.kernel.org will allow these attachments...)

Nice plots. Yes had the same problem long time. Packets were dropped on even moderately loaded machines and the network managers were complaining.

Also the are some router benchmarks (RFC??) that estimates the forwarding performance to the level when the first packet drop occurs. One can of course discuss such test but it's there...

IMO is best to have he GC "inlined" with the creation of new flows and avoid periodic tasks in this aspect.

Also I tried with something I called "active" garbage collection. The idea was to get hints from TCP-FIN etc when to remove stale entries to take a more pro-active approach. I think this was mentioned in the TRASH-paper.

If you only do routing you might try to disable the route cache.

Cheers

					--ro