Repository navigation
atbm: RX copies from kmalloc, so unread replies cannot pin 32 KiB each - #2790
Conversation
The AltoBeam drivers copied every received frame with dev_alloc_skb(), which carves it out of a 32 KiB page-frag block; one frame left queued keeps the whole block, and a socket charges it only a few hundred bytes. Segments an application has not read, such as an RTMP server's acknowledgements, then drain a ~27 MiB camera until OOM, in memory no /proc/meminfo field shows: #2455. - atbm-wifi: fetched from OpenIPC's fork of gtxaspec/atbm-wifi, pinned at 5a0a920 instead of HEAD. That carries the fix (OpenIPC/atbm-wifi#1) and a Makefile that builds on 4.9 kernels under GNU make 4.4, which the upstream one does not. - atbm60xx, atbm603x-comb-openipc: OpenIPC/atbm_60xx 70d6dec, the same fix (OpenIPC/atbm_60xx#8).
PR Summary by QodoPin AltoBeam drivers with the RX buffer allocation fix
AI Description
Diagram
High-Level Assessment
Files changed (4)
|
Code Review by Qodo
1. Driver fix ships with no on-camera test evidence
|
|
On qodo's "no on-camera test evidence": correct, and the description says so. This lands on the qemu-bench evidence, and hardware confirmation goes to the reporter in #2455. One correction: the emulation does exercise the path the bug depends on. The failing case is an upload whose application never reads the server's replies, and that is exactly what both A/B arms ran: stock OOM within 30 s, this change flat. Ethernet isn't part of the bug, since its driver does not carve received frames out of 32 KiB page-frag blocks. |
Problem
#2455: a GK7205V210 camera with an AltoBeam ATBM6012B USB adapter and
mem=32Mloses memory while it streams RTMP over Wi-Fi. No/proc/meminfofield accounts for it, and the camera ends in OOM and watchdog resets. Over Ethernet it doesn't happen, andrmmodof the driver gives the memory back.The root cause has two parts:
master+88fb005, so each small reply stayed queued on the socket.atbm_get_skb()copies every received frame withdev_alloc_skb(), which carves it out of an order-3 (32 KiB) page-frag block. One frame left queued keeps the whole block alive, but the socket is charged only the frame's truesize, a few hundred bytes. Sorcvbufandtcp_memnever limit it, and nothing in/proc/meminfoshows it.This PR fixes the driver half: received frames are copied with
alloc_skb()(kmalloc), so a queued frame costs what it is charged, shows up inSlab, and the socket limits hold.atbm-wifi5a0a920instead ofHEAD: the fix (OpenIPC/atbm-wifi#1), plus a Makefile that builds on 4.9 kernels under GNU make 4.4 (the upstream one stops withMakefile.lib:402: prerequisites cannot be defined in recipes).Config.innames the URL.atbm60xx,atbm603x-comb-openipc70d6dec(OpenIPC/atbm_60xx#8): the same fix, in the root drop and inatbm603x_comb/.Hardware tested on
Not run on a camera with an AltoBeam adapter. The evidence is a reproduction in qemu-bench. It uses the emulated ATBM6012B (
007a:888b, AresLite) on thegk7205v200andgk7201v200machines, which have a USB host since OpenIPC/qemu-bench#238. The test is an upload over Wi-Fi only, with no Ethernet, that never reads the 16-byte replies its server sends every 64 KiB.Evidence
Reporter's configuration (gk7205v210 kernel,
atbm6012b_wifi_usbfrom atbm-wifi,mem=32M), 3 minutes:upd invoked oom-killer)/proc/meminfofieldTCP: mem(pages)Slabgk7201v200,
atbm603x_comb_wifi_usbas #2729 ships it: stock 6 OOM kills, upload dead at 63 MB. This change: no OOM, 1.36 GB sent,TCP: mem123 pages and flat,Slab+328 KiB and flat.With no replies, neither build drains. The reporter's own log shows
TCP: mem 116during the drain, the same plateau the fixed build settles at.Builds:
gk7201v200_litefrom this branch (firmware.bin: uImage 1837K + squashfs 5352K = 7232Kof 7616K). No in-tree defconfig selectsatbm-wifi(only builder profiles do), so CI never builds it. I built it locally ongk7205v210_lite, selecting it in that build only: it fetchedopenipc/atbm-wifiat5a0a920, applied0001-casting.patch, andatbm6012b_wifi_usb.kobuilt under make 4.4.1. The image then overflowed the fixed rootfs slot by 364 KB, which comes from adding a 900 KB driver to that image and not from this change. WithSOURCE_DATE_EPOCHandATBM_BUILD_TIMEpinned, atbm-wifi's Makefile change gives a byte-identical module under make 4.3 before and after.Scope
general/package/all-patches/linux/(those go to OpenIPC/linux)general/overlay/or in a sharedload_<vendor>script hardcodes a value specific to my boardLD_PRELOAD, and no binaries that cannot be rebuilt from source