kswapd0 interupts media players

I use suse 11.2 86_64 on a comp with Nvidia Geforce 8300 on the motherboard using 512 Mb from main memory, AMD X2 Dual Core 4600+ RAM 8 GB DDR2 Dual channel and have following problem - from time to time when play a video (streaming or playing a file with any video player - vlc, smplayer, kaffeine etc.) the sound suddenly disappears short afterwards everything freezes even mouse, the hard disk work as wild and after 5 minutes or so the players quit and everything comes alive again. Long time I could not see the process responsible for that because even screen freezes, once I had the luck and noticed a process kswapd0 appearing in time of such an event. I googled and there were similar complying connected with that daemon. I read it will be a good idea to minimize the amount of swap, which in my case is 2 Gb , I unmounted the entire swap and restarted and the OS remains only on RAM 7,5 GB . The event appeared again and there were significant different, it obviously was shorter in time (about a minute) and mouse freezes for short period of time, but again the player quits on the end of the event.
Is there a way that the process could be managed in some way as it is very annoying appearing all of a sudden with no warning or something ? Of course if that memory shifting or cleaning is the main problem, again it happens only in case player works and not every time, it is random.

You have 8 GB of RAM and swap kicks in? It sounds like you need to start monitoring free RAM, because you may have a leaking process somewhere. I have noticed that sometimes the Xorg process runs away with RAM (>1.5 GB), so keep an eye out for that too.

If the issue is repeatable, keep a terminal open with a running “top” and monitor the Mem and Swap lines at the top.

A bad or weak disk sector can cause these symptoms also.

Well I checked for bad sectors the HDD with Herien Boot CD. It took long time but at the end there were no errors according test. I also check memory it gave that everything is oki.

If there is no problem with hardware and its function, what could cause that behavior of kswapd0 during playing video. I keep watching the memory status - on fresh restarts it gives 30-33% application usage and 5-6 % cache of the RAM , playing video cache goes up to 60-63% and the free memory is around 50 Mb. But that is the scenario if I do not play video, just the cache filled up slower in time.

In case the event occurs the cached from 63% become cleaned to 6-7% I suppose that is what kswapd0 does - cleaning cache in memory.But why sometimes it happens suddenly and literately stops any other activity on computer and sometimes the cache is full but that event does not happen.

Something doesn’t seem right with that. I don’t play video on this box here, but I have 8 GB of RAM and a typical view of my RAM is something like this (after the box has been running for a couple of days or so):


Mem:   7934848k total,  1786596k used,  6148252k free,   105256k buffers
Swap: 16771820k total,        0k used, 16771820k free,  1013540k cached

That’s 6 GB free, not 50 MB as you report.

Is there a setting on your video player to limit the amount of read-ahead it does in memory? If you have a reasonably fast hard drive, I would set that way lower and leave your swap space untouched.

Yes I feel that something is wrong but I do not know what exactly and how to control it. I had the luck to have an eye at the memory status at the moment sound disappeared on playing video file. The memory usage jumped from 33% to 99 % in a second for applications then everything freezed and when screen came alive back the application usage was back to 30 % and cache was 3 % all other was free . So the leak of memory is proven but circumstances leading to that are hidden and they happened random to me and I have no idea how to find them. I do not know how to limit the memory usage of video players to check if it works?

Which player do you use? Perhaps a multimedia guy will chip in with a tip or two.

I prefer vlc and smplayer but actually i have tried all famous - mplayer, gnome player, kaffeine, kmplayer, dragon,xine and some other less known by me as xfmedia, whaam, parole. Well I know all of them a based either on mplayer or xine.

I looked in vlc and smplayer preferences if there was a kind of memory settings but with no luck, perhaps the memory setting should be performed in some other way.

Maybe we’re barking up the wrong tree: could it be that your display driver freaks out when you’re streaming video? Are you running the nv driver?

I have checked in YAST but there are installed only nVIDIA drivers 190.xx . I rememeber there were “nv” rpm in previous OpenSuse versions - an opensource drivers for nvidia harware, but now there nothing neither installed nor existing in YAST software manager.

linux:/home/one # lsmod
Module Size Used by
joydev 14400 0
st 47916 0
ide_gd_mod 36592 0
ide_cd_mod 36080 0
snd_usb_audio 117472 3
snd_usb_lib 26024 1 snd_usb_audio
snd_rawmidi 32064 1 snd_usb_lib
snd_pcm_oss 60032 0
snd_mixer_oss 22728 1 snd_pcm_oss
snd_seq 78560 0
snd_seq_device 10460 2 snd_rawmidi,snd_seq
snd_hda_codec_nvhdmi 7432 1
snd_hda_codec_realtek 318124 1
snd_hda_intel 37280 4
snd_hda_codec 111112 3 snd_hda_codec_nvhdmi,snd_hda_codec_realtek,snd_hda_intel
snd_hwdep 11216 2 snd_usb_audio,snd_hda_codec
snd_pcm 117808 5 snd_usb_audio,snd_pcm_oss,snd_hda_intel,snd_hda_codec
snd_timer 32152 2 snd_seq,snd_pcm
snd 97608 26 snd_usb_audio,snd_usb_lib,snd_rawmidi,snd_pcm_oss,snd_mixer_oss,snd_seq,snd_seq_device,snd_hda_codec_realtek,snd_hda_intel,snd_hda_codec,snd_hwdep,snd_pcm,snd_timer
snd_page_alloc 12600 2 snd_hda_intel,snd_pcm
lp 13764 0
ir_kbd_i2c 9720 0
edd 13232 0
ip6t_LOG 7980 12
xt_tcpudp 4104 64
xt_pkttype 2248 3
ipt_LOG 7660 26
xt_limit 4076 38
vboxnetadp 8448 0
vboxnetflt 19184 0
nfsd 355840 5
nfs 405152 5
lockd 95636 2 nfsd,nfs
fscache 52048 1 nfs
nfs_acl 4072 2 nfsd,nfs
auth_rpcgss 56928 2 nfsd,nfs
sunrpc 267144 24 nfsd,nfs,lockd,nfs_acl,auth_rpcgss
exportfs 6120 1 nfsd
vboxdrv 1811500 2 vboxnetadp,vboxnetflt
af_packet 28680 0
cpufreq_conservative 10360 0
cpufreq_userspace 4364 0
cpufreq_powersave 2152 0
powernow_k8 19340 1
ip6t_REJECT 6856 3
nf_conntrack_ipv6 26632 4
ip6table_raw 3720 1
xt_NOTRACK 2248 4
ipt_REJECT 4136 3
xt_state 2920 22
iptable_raw 3560 1
iptable_filter 4520 1
ip6table_mangle 5000 0
nf_conntrack_netbios_ns 3400 0
nf_conntrack_ipv4 14232 18
nf_conntrack 101952 5 nf_conntrack_ipv6,xt_NOTRACK,xt_state,nf_conntrack_netbios_ns,nf_conntrack_ipv4
nf_defrag_ipv4 2856 1 nf_conntrack_ipv4
ip_tables 24536 2 iptable_raw,iptable_filter
ip6table_filter 4552 1
ip6_tables 26072 4 ip6t_LOG,ip6table_raw,ip6table_mangle,ip6table_filter
x_tables 30768 11 ip6t_LOG,xt_tcpudp,xt_pkttype,ipt_LOG,xt_limit,ip6t_REJECT,xt_NOTRACK,ipt_REJECT,xt_state,ip_tables,ip6_tables
fuse 87984 3
loop 22292 0
dm_mod 101544 0
tuner_simple 18420 1
tuner_types 18536 1 tuner_simple
tuner 27048 1
tvaudio 33952 0
tda7432 7228 0
nvidia 9647368 48
bttv 155732 0
ir_common 53772 2 ir_kbd_i2c,bttv
i2c_algo_bit 8396 1 bttv
v4l2_common 23400 4 tuner,tvaudio,tda7432,bttv
videobuf_dma_sg 17004 1 bttv
videobuf_core 24044 2 bttv,videobuf_dma_sg
btcx_risc 6416 1 bttv
gspca_spca561 14024 0
gspca_main 32072 1 gspca_spca561
videodev 46848 6 tuner,tvaudio,tda7432,bttv,v4l2_common,gspca_main
v4l1_compat 19020 1 videodev
amd64_edac_mod 39392 0
ohci1394 38340 0
tveeprom 15212 1 bttv
v4l2_compat_ioctl32 12776 1 videodev
i2c_nforce2 10256 0
forcedeth 68564 0
usblp 17608 0
edac_core 60788 1 amd64_edac_mod
k8temp 6440 0
shpchp 43620 0
pci_hotplug 39640 1 shpchp
ieee1394 121024 1 ohci1394
pcspkr 3720 0
sg 40128 0
ppdev 12368 0
parport_pc 46856 1
parport 46544 3 lp,ppdev,parport_pc
sr_mod 20964 0
wmi 9600 0
kvm_amd 51036 0
kvm 238864 1 kvm_amd
asus_atk0110 16264 0
cdrom 48232 2 ide_cd_mod,sr_mod
floppy 73576 0
thermal 25160 0
button 8360 0
fan 6352 0
processor 56932 1 powernow_k8
thermal_sys 21888 3 thermal,fan,processor
ext4 426040 2
crc16 2504 1 ext4
jbd2 115712 1 ext4
ide_pci_generic 5484 0
amd74xx 8080 0
ide_core 148064 4 ide_gd_mod,ide_cd_mod,ide_pci_generic,amd74xx
ata_generic 6508 0
pata_amd 16748 0
linux:/home/one #

I made some probes with mp4 720p video file using vlc to play it changing only video output drivers. In all cases it gave close results 28-30 % CPU 14-15% Xorg 12-14% Compiz and 17-20% Pulsevideo , only with OpenGL gave 75-80% CPU 5-6% Xorg 7-8 % Compiz and 5-6% Pulseaudio . In every case the free memory stayed in the range 45 - 120 Mb, application 35% and cache 64 %.

I run ATI myself, and I’m pretty sure it’s the same way as for the nVidia driver: the distro comes with the open-source version, which is / may be underpowered (for sure for the ATI fglrx driver). To install the AMD build, you have to download it from their website, or, maybe someone has a build service for it (I doubt it). Before you start, look at the Multimedia forum (a sub-forum to this one) and open the “sticky” message there, it contains the instructions on how to install the proprietary “nv” driver.

I’d say there is a good chance that your system performance will be much better with the nv driver, especially since you’re running Compiz.

I have read this post in KDE forum :

"This is due to a limitation in the Linux DRI infrastructure, which is not designed for multiple applications performing direct rendering at once. DRI2, its successor is designed for this, but it will take time for drivers and applications to migrate to it ( assuming that X ships with it )

Thus, applications cannot use the GPU when KWin is doing desktop effects."

http://forum.kde.org/viewtopic.php?f=111&t=38516

Do you think that could lead to the problem I have as well?