Rockchip · AI & Linux Hub

Linux & boot

Rockchip Linux DMA-BUF: Memory Leaks, IOVA and Peak Usage Debugging

Full RK3588 Linux 5.10 DMA-BUF debug macros, procfs and source video playback memory and peak examples.

· ArmSoM Editorial · Rockchip source documentation · 4 min read

ArmSoM applicability and source

Platform reference for adapting ArmSoM, translated from Chinese V1.0.0. Source scope: RK3588, Linux 5.10. No English PDF was supplied; English, Russian and German fully translate the Chinese source. German reuses the English article’s image URLs. No specific ArmSoM board, SDK/BSP or driver combination has been confirmed or hardware-tested. Check the actual SoC, board memory layout, SDK/BSP, kernel configuration and driver implementation. Code, addresses, logs and measurements are source examples, not ArmSoM test results.

Editorial notes · ArmSoM Docs · Rockchip Linux

This source describes DMA-BUF debugging for memory leaks, data-flow errors and memory mapping failures. The source has no technical figures; none are invented.

Source SoC Source kernel
RK3588 Linux 5.10

1. Introduction

DMABUF is a buffer structure for sharing memory between multimedia devices. Devices can share memory across processes through a DMABUF file descriptor, using zero-copy to improve performance and asynchronous access to reduce coupling between modules.

2. Linux changes for DMABUF debugging

2.1 DMABUF_DEBUG

The source BSP supports DMABUF debug from Linux-5.10. Enable it in arch/arm64/configs/rockchip_defconfig:

CONFIG_DMABUF_DEBUG=y

With this macro enabled, each DMABUF receives a default name formed from pid+taskname, limited to 16 characters. Example:

416-allocator@4.

2.2 DMABUF_PROCFS

The source BSP supports DMABUF procfs from Linux-5.10. Enable it in arch/arm64/configs/rockchip_defconfig:

CONFIG_RK_DMABUF_PROCFS=y

This creates an rk_dmabuf child node under /proc/, with the following debug nodes. The comments below are retained from the Chinese source:

dev # 显示所有DMABUF已经attach的device
sgt # 显示所有DMABUF的ScatterListTable,显示其IOVA
size # 显示所有DMABUF的total size
peak # 显示所有DMABUF的total size的峰值

Node meanings: dev lists attached devices; sgt shows ScatterListTable and IOVA; size reports total size; peak reports its maximum.

2.3 DMABUF_DEBUG_ADVANCED

This DMABUF procfs subfeature obtains the physical addresses of DMABUF memory. Enable it in arch/arm64/configs/rockchip_defconfig:

CONFIG_DMABUF_DEBUG_ADVANCED=y

With this macro enabled, all DMABUFs are attached/mapped through a fake device to obtain their sgt. This assists /proc/rk_dmabuf_sgt in displaying all DMABUF IOVAs. The path is retained literally from the source; verify it against the running BSP.

3. Questions and answers

3.1 RK3588 video playback: DMABUF memory leak?

Enable the debug macros and inspect memory on entering the main screen:

console:/ # cat /proc/rk_dmabuf/size
Total: 65552 KiB

Play a video, exit playback, clear the playback history and return to the main screen:

console:/ # cat /proc/rk_dmabuf/size
Total: 83948 KiB

3.2 Peak DMABUF memory during RK3588 video playback?

Use the mpp debug node to inspect the total DMABUF memory used for video playback:

console:/ # cat /proc/mpp_service/sessions-summary
fdc38100.rkvdec-core Total: 699760 KiB

Use the DMABUF debug node to inspect peak memory:

console:/ # cat /proc/rk_dmabuf/peak
Peak: 1544 MiB

Reset the peak to zero and observe again:

console:/ # echo 0 > /proc/rk_dmabuf/peak

Explore this topic → · Learning paths →