Subject: TSW202 (TSW2_R_00.01.10): kernel memory leak with hardware-timestamped PTP (ptp4l), device reboots every ~5h20m
Hello,
We are seeing a reproducible kernel memory leak on the TSW202 when it runs ptp4l as a hardware-timestamped PTP boundary clock. The leak runs the device out of memory, and it reboots about every 5h20m, taking all connected devices offline for about a minute. With ptp4l stopped, the leak stops.
Device
- Model: TSW202
- Firmware:
TSW2_R_00.01.10(OpenWrt 22.03.3, kernel 5.10.245, SoC RTL8380) - PTP: linuxptp 4.4 from the package repository; PHC
/dev/ptp0(clock namertl838x), shared by all ports - RAM: 124 MB
PTP setup. ptp4l runs from a custom procd init script (ptp4l -f /etc/ptp4l-bc.conf), not from the WebUI. Config:
[global]
time_stamping hardware
network_transport L2
delay_mechanism E2E
twoStepFlag 1
[port1]
[port2]
[port5]
[port6]
[port7]
[port8]
[sfp1]
[sfp2]
One port connects to a Linux grandmaster (linuxptp, L2, hardware timestamping, PTPv2.0). The other ports serve downstream devices. port3/port4 are excluded because they report no hardware timestamping. There are no VLANs or other non-default switch settings.
Symptom
- Memory. Kernel unreclaimable slab (
SUnreclaimin/proc/meminfo) grows linearly whileptp4lruns. At 3 h uptime it was 51.9 MB, withMemAvailableabout 19 MB. User processes total about 8 MB (AnonPages);ptp4lRSS is 696 kB. - Timeline. About 5h05m after boot,
ptp4lstarts missing received PTP messages. The device reboots 5–35 minutes later. This repeats on a fixed cycle (5h08m–5h38m), day and night, regardless of traffic load. We have seen it over 15+ consecutive cycles. - Freed only by reboot. Leaked memory is not freed when
ptp4lis stopped. - Log messages. The log also shows occasional
timed out while polling for tx timestamp/send sync failedport faults.
Measurements. SUnreclaim sampled every 20 s for 4 minutes per run, same device and uptime range:
ptp4l mode |
PTP frames via CPU (RX / TX per s) | SUnreclaim growth |
|---|---|---|
| Boundary clock, all ports above | ~4 / ~9 | 4.24 kB/s |
Single port only ([port5], slave) |
~3.7 / ~1.2 | 1.31 kB/s |
ptp4l stopped |
0 (other CPU traffic ~7/s) | 0.05 kB/s |
The leak scales with the number of hardware-timestamped PTP frames, roughly 0.3–0.6 kB per frame. Ordinary traffic to the CPU does not leak, so we believe the leak is in the RTL838x PTP/DSA timestamping path, for example a timestamped skb or a timestamp slot that is never released. The kernel has no /proc/slabinfo (SLUB debug is off), so we could not identify the cache.
Steps to reproduce (about 5 minutes)
-
On a TSW202 running
TSW2_R_00.01.10, installlinuxptpand startptp4l -f <config above>. -
Connect a PTP grandmaster (e.g. Linux
ptp4l -2 -H) to one listed port. -
On the TSW202, run:
while true; do echo $(cut -d' ' -f1 /proc/uptime) $(grep SUnreclaim /proc/meminfo); sleep 20; done -
SUnreclaimrises by about 1–4 kB/s, depending on the number of active PTP ports. -
Stop
ptp4l: the growth stops, but the memory is not freed.
Questions
- Is this a known issue, and is it fixed in a firmware release newer than
TSW2_R_00.01.10? - If not, can it be fixed?
- Is there a supported PTP configuration on the TSW202 (e.g. the WebUI PTP feature, if any) that avoids this path?
As a workaround we run the switch in plain passthrough (ptp4l stopped), which avoids the leak.
A Troubleshoot file captured while ptp4l was running is attached.
Thanks
Aidan