Fix page allocation failure on Raspberry Pi running rtorrent

For some time now I am running Xbian as my preferred distro of choice for my multimedia player on my Raspberry Pi 2.

Xbian works flawlessly and it is always on bleeding edge with Kodi, but since it is Debian Jessie based it is perfect for customization by adding additional packages.

So far I have installed  MySQL database for Kodi database sharing, rtorrent, rutorrent with lighttpd, dnsmasq and few other packages.

Only one small issue I have noticed when downloading torrents to my external USB drive often I am presented with errors similar like these in dmesg log:

kernel: [267609.763694] kswapd0: page allocation failure: order:3, mode:0x20
.....
kernel: 1-1.1:1.0: eth0: kevent 2 may have been dropped
kernel: [267610.093783] smsc95xx 1-1.1:1.0: eth0: kevent 2 may have been dropped
kernel: [267610.093798] smsc95xx 1-1.1:1.0: eth0: kevent 2 may have been dropped

I’ve googled about this issue and there seems that there is no unique solution for this issue. In my case combination of several solutions worked, so I will share them:

First of all in your /boot/cmdline.txt append following;

smsc95xx.turbo_mode=N

This parameter should decrease slightly network performance since Ethernet on Raspberry Pi is connected on USB hub, but in my tests with iperf I could not see any difference.

Check following sysctl parameters with following commands:

#sysctl vm.min_free_kbytes
vm.min_free_kbytes = 16384
#sysctl vm.vfs_cache_pressure
vm.vfs_cache_pressure = 150

Edit your /etc/sysctl.conf file and append to the end of the file:

vm.min_free_kbytes = 32768
vm.vfs_cache_pressure = 300

Use “sysctl -p” to activate changes, or if you are doing this on already kernel that has reported errors please reboot.

I hope this will be enough, but I would like to mention that in rtorrent configuration file “~/.rtorrent.rc” I have changed following values:

pieces.memory.max.set = 512M

to

pieces.memory.max.set = 256M

So far it is running stable without any messages in dmesg log, so I am pretty satisfied.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.