You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Pi becomes sluggish/unresponsive using wired Ethernet port with Bravia TV #343
I'm using a Raspberry Pi as a NAT router between a wired/wireless networks, and I'm experiencing some serious performance problems with the Model B rev 2.0 on-board Ethernet. This is running the latest version of Raspbian downloaded direct from the main downloads page.
The setup is to allow a remote internet-enabled Sony TV without wireless adapter support to stream internet video from a local wireless router. The wireless adapter is an EdiMax WiFi dongle which works really well on its own; the problem is that when the TV is streaming video through the wired interface, the Pi becomes very unresponsive with ping times on the wireless side rising from around 15ms to 500-600ms. This causes the video stream to freeze every 10-20s when trying to watch streaming video.
Things I've checked:
Power problems - I've confirmed with a multimeter that the Pi is getting enough power when both wired and wireless network adapters are running; i've even temporarily replaced FS3 with a wire just to be sure. The power adapter is capable of supplying 1500mA and maintains good voltage, even when the Pi is apparently under load.
Latest updates - I've run rpi-update with BRANCH=fiq_split and that doesn't seem to make any difference.
From reading around the forums, my general feeling is that there are still several issues with the USB drivers which are likely to be related to this problem - can anyone confirm the current status of the USB drivers?
Note I should just add that "top" shows no processes hogging the CPU, which would indicate to me that the excess time is being spent in kernel space rather than user space.
I did another test whereby I connected my laptop to the Pi instead of the TV, and did a wget on a large file. This showed a sustained transfer speed of around 600K/s and the Pi remained responsive to pings on the wired port.
My thoughts are:
Does the wired Ethernet take priority over the wireless ethernet? This may explain why it was the wireless interface that was showing the higher ping times. I'd need another laptop to test the wireless interface though.
Could the Bravia IP stack be doing something that causes excessive traffic on the Ethernet port? I don't see how 600K/s should bring a Pi to its knees :/
Thanks for the reply. I didn't realise fiq_split is deprecated - it might be worth someone adding a sticky page for USB to the Pi forums as there is so much out-of-date information related to USB problems and fiq_split on there.
dmesg doesn't show any related error messages at all. Another quick test shows that if I disconnect the cable from the wired interface then the ping times on the wireless interface immediately drop back to normal. I can post the complete dmesg output if required.
Also what speed does the Pi wired ethernet run at? mii-tool on Raspbian reports that it's running at 1000baseTx whereas other posts suggest that the port is only a 10/100baseTx?
The ethernet is 10/100. You should see a line in dmesg showing the speed. e.g. [ 4.921464] smsc95xx 1-1.1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
Ah I see - I think my mistake is that the Broadcom drivers supports the new ethtool rather than the older mii-tool ioctl interface. I'll head over to the Pi and double-check in a bit.
Based on this I have another couple of questions:
Is 600K/s USB transfer enough to make a Pi completely unresponsive?
Is there a way to measure the impact/performance of USB transfers?
I've seen some posts mentioning that it is possible to count interrupts/sec from /proc, but I'm wondering if there are any further counters specific to the USB/ethernet hub, e.g. no. of retries that would indicate that the Pi is being overloaded.
FWIW if there are monitoring patches like this available, I could probably cross-compile a custom kernel and report back the values if that helps?
I can replicate this. The problem is likely due to memory allocation thrash. In the extreme case we see stuff like #153 where we end up with actual failures, but in the cases that normally provoke this I assume that the kernel allocator has to do a lot of work to find a contiguous free block of the size requested.
I have yet to profile this and understand it fully - not strictly related to USB, but more likely to happen in conjunction with a USB device plus "bad" driver because most of the bytes in/out of a Pi are usually going to be through networks.
One thing to try: Can you repeat your test with a kernel compiled with the memory allocator set to SLUB?
@popcornmix : i've just installed vnstat on the pi itself, and while it is sluggish, it seems to be reporting ~1.1Mbps data rate on eth0 and wlan0 when streaming video, so that should be well within the parameters above.
Before streaming starts, top reports idle as being around 96% which drops to around 90-92% when trying to stream video.
@P33M : glad that you can reproduce. as mentioned above, the incoming data rate from eth0 is about 1.1Mbps. Since most people report that they can use a Pi with no problems as an WiFi hotspot, I wonder if it is something in the smsc95xx driver which produces too many USB interrupts?
From the link you gave above, I tried increasing vm.min_free_kbytes to around 128Kb but that actually seemed to make the ping response times worse during streaming - the times went from around 400-500ms to 700-800ms.
In terms of a kernel to try, I've installed an ARM cross-compiler so if you can point me towards a github repository/branch to try (along with a suitable kernel .config), I'll have a go at trying the different allocator.
Another interesting thing: I've just tried switching the Bravia down to "Normal" resolution (down from its default of high), and the data rate stays at ~1.1Mbps - BUT now I get about 10s of 400-500ms ping times followed by about 10s of normal (~20ms) ping times which seems to be enough to keep the TV from buffering constantly. However the Pi still remains unresponsive during the periods of slow ping response. Does that information help at all?
@mcayland as has been stated in similar threads, vm.min_free_kbytes is a hint to the virtual memory system to try to keep that much memory free if at all possible; in effect, it's the limit below which the kernel starts swapping pages out to disk to try to free up more memory without a pending allocation. Increasing it above about 16348 (16MiB, because the value is in kiB) will actually decrease preformance for almost all workloads on the Pi because the system will usually spend more time swapping to disk than is really necessary, which is probably why you were seeing such bad latency with it at 131072 (which is what i assume you mean by 128Kb, since it can't be less than 4096 on the Pi).
@P33M okay i'm just setting up the build environment now. I see there have been some recent USB commits, so should I try a standard kernel (without SLUB) first to use as a baseline?
@Ferroin thanks for the clarification. I saw the hint about raising vm.min_free_kbytes in one of the Pi Forums which is why I tried it, but as you correctly point out increasing it is not going to help here. There is a lot of out of date/conflicting information around on the forums :/
@P33M one other thought: has anyone got oprofile to work on the Pi yet? if so, I could try and grab a kernel profile when the Pi is being unresponsive.
It appears that the Pi isn't cpu-bound - idle time is at 98%. I would expect much higher times if there were memory allocation stress or even simple network I/O processing.
Can you substitute the wlan dongle for another? I have one where the radio is nearly fried and as such has terrible performance with not much showing for it.
@P33M okay some progress - I borrowed a wireless USB dongle based on the zd1211rw driver, tried it and it seems to work! Ping times seem to hover around 10-30ms when streaming which is exactly what I expect. Now my first suspicion is the 8192cu driver: firstly there are quite a few options that can be potentially tweaked:
@P33M : after spending some time on this, I've confirmed that it's definitely a problem with the particular wireless driver/hardware combination - both the Realtek vendor driver and the kernel rtlwifi drivers have different issues which cause poor performance. On the plus side, I've been working with Larry Finger (the kernel rtlwifi/rtl8192cu maintainer) and we've gone a long way to improving the reliability of the kernel driver so hopefully it will be possible to switch at some point in the future.
In the meantime, given that I can happily stream ~1.3MB/s through the Pi with a properly working wireless driver without any issue then I am happy that this is not a Pi USB driver issue I am seeing - so thanks once again for your help, and feel free to close.
In the end, I spent a lot of time working with Larry Finger to improve rtlwifi (rather than Realtek's awful 8192cu) and have fixed a few bugs to the point where on recent kernels I now see the same performance between the rtlwifi and 8192cu drivers.
In my case we determined that the hardware rate-control algorithm struggles in my particular environment, and Larry was unable to reproduce the failure at his end so it came to a halt. My eventual fix was to switch wireless dongles and during testing I found that both rt2800usb and ath9k_htc both worked much better for me.
Activity
mcayland commentedon Jul 27, 2013
I did another test whereby I connected my laptop to the Pi instead of the TV, and did a wget on a large file. This showed a sustained transfer speed of around 600K/s and the Pi remained responsive to pings on the wired port.
My thoughts are:
Does the wired Ethernet take priority over the wireless ethernet? This may explain why it was the wireless interface that was showing the higher ping times. I'd need another laptop to test the wireless interface though.
Could the Bravia IP stack be doing something that causes excessive traffic on the Ethernet port? I don't see how 600K/s should bring a Pi to its knees :/
popcornmix commentedon Jul 27, 2013
fiq_split branch is now deprecated. The fiq_split code (and additional improvements) are now on the master branch.
Any complaints in dmesg log?
mcayland commentedon Jul 27, 2013
Thanks for the reply. I didn't realise fiq_split is deprecated - it might be worth someone adding a sticky page for USB to the Pi forums as there is so much out-of-date information related to USB problems and fiq_split on there.
dmesg doesn't show any related error messages at all. Another quick test shows that if I disconnect the cable from the wired interface then the ping times on the wireless interface immediately drop back to normal. I can post the complete dmesg output if required.
Also what speed does the Pi wired ethernet run at? mii-tool on Raspbian reports that it's running at 1000baseTx whereas other posts suggest that the port is only a 10/100baseTx?
popcornmix commentedon Jul 27, 2013
The ethernet is 10/100. You should see a line in dmesg showing the speed. e.g.
[ 4.921464] smsc95xx 1-1.1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0x45E1mcayland commentedon Jul 27, 2013
Ah I see - I think my mistake is that the Broadcom drivers supports the new ethtool rather than the older mii-tool ioctl interface. I'll head over to the Pi and double-check in a bit.
Based on this I have another couple of questions:
I've seen some posts mentioning that it is possible to count interrupts/sec from /proc, but I'm wondering if there are any further counters specific to the USB/ethernet hub, e.g. no. of retries that would indicate that the Pi is being overloaded.
FWIW if there are monitoring patches like this available, I could probably cross-compile a custom kernel and report back the values if that helps?
popcornmix commentedon Jul 27, 2013
P33M commentedon Jul 29, 2013
I can replicate this. The problem is likely due to memory allocation thrash. In the extreme case we see stuff like #153 where we end up with actual failures, but in the cases that normally provoke this I assume that the kernel allocator has to do a lot of work to find a contiguous free block of the size requested.
I have yet to profile this and understand it fully - not strictly related to USB, but more likely to happen in conjunction with a USB device plus "bad" driver because most of the bytes in/out of a Pi are usually going to be through networks.
One thing to try: Can you repeat your test with a kernel compiled with the memory allocator set to SLUB?
mcayland commentedon Jul 29, 2013
@popcornmix : i've just installed vnstat on the pi itself, and while it is sluggish, it seems to be reporting ~1.1Mbps data rate on eth0 and wlan0 when streaming video, so that should be well within the parameters above.
Before streaming starts, top reports idle as being around 96% which drops to around 90-92% when trying to stream video.
mcayland commentedon Jul 29, 2013
@P33M : glad that you can reproduce. as mentioned above, the incoming data rate from eth0 is about 1.1Mbps. Since most people report that they can use a Pi with no problems as an WiFi hotspot, I wonder if it is something in the smsc95xx driver which produces too many USB interrupts?
From the link you gave above, I tried increasing vm.min_free_kbytes to around 128Kb but that actually seemed to make the ping response times worse during streaming - the times went from around 400-500ms to 700-800ms.
In terms of a kernel to try, I've installed an ARM cross-compiler so if you can point me towards a github repository/branch to try (along with a suitable kernel .config), I'll have a go at trying the different allocator.
Another interesting thing: I've just tried switching the Bravia down to "Normal" resolution (down from its default of high), and the data rate stays at ~1.1Mbps - BUT now I get about 10s of 400-500ms ping times followed by about 10s of normal (~20ms) ping times which seems to be enough to keep the TV from buffering constantly. However the Pi still remains unresponsive during the periods of slow ping response. Does that information help at all?
P33M commentedon Jul 29, 2013
Use this repo (rpi-3.6.y branch). Config is in arch/arm/configs/bcmrpi_defconfig.
Copy that to .config, then
make ARCH=arm menuconfigand under General Setup, scroll down to Choose Slab Allocator -> SLUB.Build in the normal way - plenty of guides floating around - copy both the modules and the kernel across.
Ferroin commentedon Jul 30, 2013
@mcayland as has been stated in similar threads, vm.min_free_kbytes is a hint to the virtual memory system to try to keep that much memory free if at all possible; in effect, it's the limit below which the kernel starts swapping pages out to disk to try to free up more memory without a pending allocation. Increasing it above about 16348 (16MiB, because the value is in kiB) will actually decrease preformance for almost all workloads on the Pi because the system will usually spend more time swapping to disk than is really necessary, which is probably why you were seeing such bad latency with it at 131072 (which is what i assume you mean by 128Kb, since it can't be less than 4096 on the Pi).
mcayland commentedon Jul 30, 2013
@P33M okay i'm just setting up the build environment now. I see there have been some recent USB commits, so should I try a standard kernel (without SLUB) first to use as a baseline?
mcayland commentedon Jul 30, 2013
@Ferroin thanks for the clarification. I saw the hint about raising vm.min_free_kbytes in one of the Pi Forums which is why I tried it, but as you correctly point out increasing it is not going to help here. There is a lot of out of date/conflicting information around on the forums :/
mcayland commentedon Jul 30, 2013
@P33M one other thought: has anyone got oprofile to work on the Pi yet? if so, I could try and grab a kernel profile when the Pi is being unresponsive.
14 remaining items
P33M commentedon Aug 20, 2013
It appears that the Pi isn't cpu-bound - idle time is at 98%. I would expect much higher times if there were memory allocation stress or even simple network I/O processing.
Can you substitute the wlan dongle for another? I have one where the radio is nearly fried and as such has terrible performance with not much showing for it.
mcayland commentedon Aug 21, 2013
@P33M okay some progress - I borrowed a wireless USB dongle based on the zd1211rw driver, tried it and it seems to work! Ping times seem to hover around 10-30ms when streaming which is exactly what I expect. Now my first suspicion is the 8192cu driver: firstly there are quite a few options that can be potentially tweaked:
root@raspberrypi:/home/pi# modinfo -p 8192cu
rtw_ips_mode:The default IPS mode (int)
ifname: (charp)
rtw_initmac: (charp)
rtw_channel_plan: (int)
rtw_chip_version: (int)
rtw_rfintfs: (int)
rtw_lbkmode: (int)
rtw_network_mode: (int)
rtw_channel: (int)
rtw_mp_mode: (int)
rtw_wmm_enable: (int)
rtw_vrtl_carrier_sense: (int)
rtw_vcs_type: (int)
rtw_busy_thresh: (int)
rtw_ht_enable: (int)
rtw_cbw40_enable: (int)
rtw_ampdu_enable: (int)
rtw_rx_stbc: (int)
rtw_ampdu_amsdu: (int)
rtw_lowrate_two_xmit: (int)
rtw_rf_config: (int)
rtw_power_mgnt: (int)
rtw_low_power: (int)
rtw_wifi_spec: (int)
rtw_antdiv_cfg: (int)
rtw_enusbss: (int)
rtw_hwpdn_mode: (int)
rtw_hwpwrp_detect: (int)
rtw_max_roaming_times:The max roaming times to try (uint)
rtw_force_iol:Force to enable IOL (bool)
rtw_intel_class_mode:The intel class mode 0: off, 1: on
rtw_mc2u_disable: (int)
Secondly it looks as if the kernel team's rtl8192cu driver is starting to look more stable (see http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/log/drivers/net/wireless/rtlwifi?id=fd3930f70c8d14008f3377d51ce039806dfc542e). How easy would it be to try and port the USB dwc_otg driver from the rpi-3.10y branch to a reasonably current git kernel as a test?
mcayland commentedon Sep 29, 2013
@P33M : after spending some time on this, I've confirmed that it's definitely a problem with the particular wireless driver/hardware combination - both the Realtek vendor driver and the kernel rtlwifi drivers have different issues which cause poor performance. On the plus side, I've been working with Larry Finger (the kernel rtlwifi/rtl8192cu maintainer) and we've gone a long way to improving the reliability of the kernel driver so hopefully it will be possible to switch at some point in the future.
In the meantime, given that I can happily stream ~1.3MB/s through the Pi with a properly working wireless driver without any issue then I am happy that this is not a Pi USB driver issue I am seeing - so thanks once again for your help, and feel free to close.
hydn79 commentedon Jan 27, 2014
I have these exact issues. With rtl871xdrv driver. Where can I find a better or modified driver that would resolve the high ping latency?
Thanks.
mcayland commentedon Feb 7, 2014
In the end, I spent a lot of time working with Larry Finger to improve rtlwifi (rather than Realtek's awful 8192cu) and have fixed a few bugs to the point where on recent kernels I now see the same performance between the rtlwifi and 8192cu drivers.
In my case we determined that the hardware rate-control algorithm struggles in my particular environment, and Larry was unable to reproduce the failure at his end so it came to a halt. My eventual fix was to switch wireless dongles and during testing I found that both rt2800usb and ath9k_htc both worked much better for me.
mm/sparsemem: pfn_to_page is not valid yet on SPARSEMEM
mm/sparsemem: pfn_to_page is not valid yet on SPARSEMEM
mm/sparsemem: pfn_to_page is not valid yet on SPARSEMEM
selftests/bpf: Extend tcx tests to cover late tcx_entry release
selftests/bpf: Extend tcx tests to cover late tcx_entry release
selftests/bpf: Extend tcx tests to cover late tcx_entry release
sched: Fix sched_numa_find_nth_cpu() if mask offline
sched: Fix sched_numa_find_nth_cpu() if mask offline
sched: Fix sched_numa_find_nth_cpu() if mask offline