# kswapd0 and slowness

## plut0

I'm trying to understand why kswapd0 is constantly running and in a D state.  The hardware is a 2.0ghz AMD 64 with 3GB of RAM.

free -m:

```
             total       used       free     shared    buffers     cached

Mem:          2950       2708        241          0         67       2286

-/+ buffers/cache:        354       2596

Swap:         1960        740       1220
```

As you can see above, I still have 2596MB of free RAM.

emerge --info:

```
Portage 2.1.6.13 (default/linux/amd64/10.0/desktop, gcc-4.3.4, glibc-2.9_p20081201-r2, 2.6.31-gentoo-r6 x86_64)

=================================================================

System uname: Linux-2.6.31-gentoo-r6-x86_64-AMD_Athlon-tm-_64_Processor_3200+-with-gentoo-1.12.13

Timestamp of tree: Mon, 30 Nov 2009 08:55:01 +0000

distcc 3.1 x86_64-pc-linux-gnu [disabled]

ccache version 2.4 [enabled]

app-shells/bash:     4.0_p28

dev-java/java-config: 2.1.9-r1

dev-lang/python:     2.6.2-r1

dev-util/ccache:     2.4-r7

dev-util/cmake:      2.6.4-r3

sys-apps/baselayout: 1.12.13

sys-apps/sandbox:    1.6-r2

sys-devel/autoconf:  2.13, 2.63-r1

sys-devel/automake:  1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10.2

sys-devel/binutils:  2.18-r3

sys-devel/gcc-config: 1.4.1

sys-devel/libtool:   2.2.6a

virtual/os-headers:  2.6.27-r2

ACCEPT_KEYWORDS="amd64"

CBUILD="x86_64-pc-linux-gnu"

CFLAGS="-O2 -pipe -march=k8 -fomit-frame-pointer"

CHOST="x86_64-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/share/config"

CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/splash /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c /etc/udev/rules.d"

CXXFLAGS="-O2 -pipe -march=k8 -fomit-frame-pointer"

DISTDIR="/var/tmp/distfiles"

EMERGE_DEFAULT_OPTS="--alphabetical"

FEATURES="ccache distlocks dstlocks fixpackages parallel parallel-fetch protect-owned sandbox sfperms strict unmerge-orphans userfetch"

GENTOO_MIRRORS="http://gentoo.osuosl.org/ http://mirrors.acm.cs.rpi.edu/gentoo/ http://csociety-ftp.ecn.purdue.edu/pub/gentoo/ ftp://ftp.ussg.iu.edu/pub/linux/gentoo"

LDFLAGS="-Wl,-O1"

LINGUAS="en en_US"

MAKEOPTS="-j2"

PKGDIR="/var/tmp/packages"

PORTAGE_CONFIGROOT="/"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

PORTDIR_OVERLAY="/usr/local/portage/layman/timotheus25 /usr/local/portage/layman/vmware /usr/local/portage"

SYNC="rsync://rsync.gentoo.org/gentoo-portage"

USE="X a52 aac acl acpi alsa amd64 apache2 apm bash-completion berkdb bluetooth branding bzip2 bzlib cairo cdda cddb cdr cli consolekit cracklib crypt curl dba dbus dga dio divx4linux doc dri dts dvd dvdr eds emboss emul-linux-x86 encode evo fam ffmpeg fftw firefox flac gcj gdbm gif gnome gpm gsm gstreamer gtk hal iconv ieee1394 innodb javascript joystick jpeg jpeg2k ldap libnotify lirc mad matroska mikmod mmx modplug modules mp3 mp4 mpeg mplayer mtp mudflap multilib musepack nas ncurses network nls nptl nsplugin nvidia ogg oggvorbis openal opengl openmp oss pcre pdf perl png ppds pppd python qt3support qt4 quicktime readline reflection samba sdl session skey snmp speex spell spl sse sse2 ssl startup-notification svg sysfs tcpd theora threads thunar tiff truetype unicode usb v4l v4l2 vcd vhosts vorbis wavpack x264 xine xinerama xml xmlrpc xorg xulrunner xv xvid zlib" ALSA_CARDS="ice1724" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic auth_digest authn_anon authn_dbd authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock dbd deflate dir disk_cache env expires ext_filter file_cache filter headers ident imagemap include info log_config logio mem_cache mime mime_magic negotiation proxy proxy_ajp proxy_balancer proxy_connect proxy_http rewrite setenvif so speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="imon" LINGUAS="en en_US" LIRC_DEVICES="imon imon_pad imon_pad2keys" USERLAND="GNU" VIDEO_CARDS="nvidia"

Unset:  CPPFLAGS, CTARGET, FFLAGS, INSTALL_MASK, LANG, LC_ALL, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
```

----------

## ZeuZ_NG

You might want to decrease swappiness, you can check the current value in /proc/sys/vm/swappiness it'll range from zero to 100.

Where zero is never swap, and the higher the number becomes, it'll swap sooner when possible.

To tune-up swappiness, use sysctl, as for example:

```
sysctl vm.swappiness=10
```

Might, or might not, be related, but I'd give that a shot before anything else...

----------

