I'm facing performance problems lately. And i noticed that kernel is swapping a lot although half of the memory is being used as buffer cache. I would expect the system to reduce the size of the buffer in favor of other running processes. In this case mysql and apache.

Code:
Output Atop:


CPU | sys 3% | user 13% | irq 0% | idle 95% | wait 690% |
cpu | sys 1% | user 4% | irq 0% | idle 35% | cpu002 w 60% |
cpu | sys 0% | user 1% | irq 0% | idle 0% | cpu003 w 99% |
cpu | sys 0% | user 2% | irq 0% | idle 0% | cpu000 w 98% |
cpu | sys 1% | user 1% | irq 0% | idle 33% | cpu004 w 64% |
cpu | sys 0% | user 2% | irq 0% | idle 17% | cpu001 w 81% |
cpu | sys 0% | user 1% | irq 0% | idle 0% | cpu005 w 99% |
cpu | sys 0% | user 2% | irq 0% | idle 0% | cpu006 w 98% |
cpu | sys 0% | user 1% | irq 0% | idle 10% | cpu007 w 89% |
CPL | avg1 9.50 | avg5 8.55 | avg15 6.11 | csw 2424 | intr 2654 |
MEM | tot 7.8G | free 50.0M | cache 5.8G | buff 0.8M | slab 67.5M |
SWP | tot 7.4G | free 6.0G | | vmcom 12.8G | vmlim 11.4G |
PAG | scan 7968 | stall 0 | | swin 4679 | swout 562 |
DSK | sda | busy 96% | read 804 | write 14 | avio 4 ms |
DSK | sdb | busy 0% | read 3 | write 7 | avio 2 ms |
NET | transport | tcpi 122 | tcpo 91 | udpi 0 | udpo 0 |
NET | network | ipi 122 | ipo 94 | ipfrw 0 | deliv 122 |
NET | eth0 0% | pcki 122 | pcko 135 | si 33 Kbps | so 214 Kbps |

PID SYSCPU USRCPU VGROW RGROW RDDSK WRDSK ST EXC S CPU CMD 1/3
1864 0.00s 0.10s -1280K -748K 28K 0K -- - S 2% apache2
2628 0.06s 0.00s 416K 416K 32K 0K -- - R 1% atop
2548 0.01s 0.03s 0K 2208K 1672K 0K -- - S 1% apache2
1954 0.00s 0.03s 0K 0K 0K 0K -- - S 1% apache2
2545 0.01s 0.02s 768K 448K 0K 0K -- - S 1% apache2
1940 0.00s 0.03s 0K 2868K 2824K 0K -- - S 1% apache2
75 0.03s 0.00s 0K 0K 0K 0K -- - S 1% kswapd0
1853 0.00s 0.02s 0K 0K 0K 0K -- - S 0% apache2
2096 0.00s 0.02s 0K 0K 0K 0K -- - S 0% apache2
1851 0.00s 0.02s 0K 8K 32K 0K -- - S 0% apache2
2344 0.00s 0.02s 0K 4K 0K 0K -- - S 0% apache2
1870 0.00s 0.02s 0K 0K 0K 0K -- - S 0% apache2
1924 0.00s 0.02s 1024K 692K 0K 0K -- - S 0% apache2
1992 0.00s 0.02s 0K 0K 0K 0K -- - S 0% apache2
1963 0.00s 0.02s 0K 340K 572K 0K -- - S 0% apache2
1922 0.00s 0.02s 0K 0K 0K 0K -- - S 0% ap
How come the kernel is keeping on swapping while their is so much cache memorye available(cache 5.8G)?

MEM | tot 7.8G | free 50.0M | cache 5.8G | buff 0.8M | slab 67.5M |
SWP | tot 7.4G | free 6.0G | | vmcom 12.8G | vmlim 11.4G |
PAG | scan 7968 | stall 0 | | swin 4679 | swout 562 |