Public bug reported:

On Ubuntu 26.04 LTS (mesa 26.0.8-1ubuntu0.3), H.264 encoding through the d3d12 
VA-API driver (WSL /
Hyper-V GPU-PV) leaks one eventfd per encoded picture, so long-running encoders 
eventually hit
`RLIMIT_NOFILE`. Upstream fixed this in commit 9f4d3267c9c1 ("d3d12: Fix video 
fence leak and double
assign", MR !40756, in Mesa 26.1.0+); the 26.0 branch never received it. The 
commit is small and
self-contained (one file, `src/gallium/drivers/d3d12/d3d12_video_enc.cpp`): it 
releases
`last_slice_completion_fence` at the end of 
`d3d12_video_encoder_encode_bitstream()` and removes a
duplicate `m_CompletionFence.reset(...)` in 
`d3d12_video_encoder_create_command_objects()`. The code it changes
is present at the same places in 26.0.8 (lines 2438 and 3321); I have not 
test-built the cherry-pick.

Upstream: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40756
Request: please consider cherry-picking it into the 26.04 mesa package (SRU).

Reproduction (Hyper-V GPU-PV guest, AMD Radeon RX 6900 XT,
`libamdenc64.so` in the D3D12 driver dir):

    export GALLIUM_DRIVER=d3d12 LIBVA_DRIVER_NAME=d3d12
    ffmpeg -hide_banner -loglevel error -nostats -y -vaapi_device 
/dev/dri/renderD128 \
      -f lavfi -i testsrc2=size=1920x1080:rate=60 -frames:v 2000 -vf 
format=nv12,hwupload \
      -c:v h264_vaapi -bf 0 -g 300 -qp 22 -f h264 /dev/null &
    P=$!; while kill -0 $P 2>/dev/null; do ls /proc/$P/fd | wc -l; sleep 0.5; 
done

Measured: 2,000 pictures leave 1,244 open `anon_inode:[eventfd]` descriptors 
after ~6 s; with strace,
3 eventfds are created per `vaEndPicture` and one is never closed.

Context: found while building hardware AVC444v2 RDP encoding for GNOME Remote 
Desktop in Hyper-V Linux
VMs with AMD Radeon GPU-PV — 
https://github.com/tuolaji996/hyperv-linux-amd-gpu-pv (open source,
GPL-2.0). The project currently works around the leak by recycling its encoder 
process every 100,000
pictures; the full analysis is in its `encoder/README.md` and 
`docs/stability.md`.

** Affects: mesa (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2178352

Title:
  mesa 26.0.8: d3d12 VA-API encoder leaks one eventfd per encoded
  picture; please cherry-pick upstream 9f4d3267c9c1

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/mesa/+bug/2178352/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to