Hard-IRQ time per interrupt grows with the number of timeline semaphores an application keeps alive (620.73.04)

未关闭
#1,590 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
12/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
c, linux

调研方向

Start in src/nvidia/src/kernel/rmapi/event_notification.c at _gpuEngineEventNotificationListNotify, which the ISR calls and which walks the per-engine listener list. Then read _semsurfRegisterCallback and _semsurfEventCallback in src/nvidia/src/kernel/gpu/mem_mgr/sem_surf.c to see how each semaphore adds a nonstall listener. Done means per-interrupt cost no longer grows with the number of live semaphores, which the reporter's measurements would need to confirm.

由索引模型根据 Issue 内容生成。

描述

Summary

While a Vulkan application that keeps one timeline semaphore alive per texture is running, a GPU interrupt costs 2.5 to 5 ms of hard-IRQ time, and the CPU that takes the interrupt is 84 to 96% busy in hard-IRQ context. With the same application changed to stop creating those semaphores, the same workload costs 0.09 ms per interrupt.

System
  • RTX 3080 (GA102), one MSI interrupt
  • NVIDIA open kernel module 620.73.04
  • Linux 7.3.5 (zen), x86-64, KDE Plasma on Wayland
What the application does

It is a Metal-to-Vulkan layer (Indium, used by Darling) running a game. It created one timeline semaphore for every texture, texture view and drawable, and each queue submission waited on and signalled the semaphore of every texture it used. The number of live semaphores therefore grows as the game loads textures.

Measurements

Hard-IRQ time is the irq column of /proc/stat for the CPU that takes the GPU interrupt, divided by that CPU's count on the nvidia line of /proc/interrupts, sampled once a second.

one semaphore per texture no per-texture semaphores
hard-IRQ time per GPU interrupt 2.5 to 5 ms 0.09 ms
CPU taking the interrupt 84 to 96% in hard-IRQ 9%
GPU interrupts handled per second about 250 about 1000
frame rate about 75 FPS median 169 FPS

At each of five starts of the application the cost per interrupt climbed steadily over about 40 seconds while it loaded textures, before it rendered a scene: 0.13 ms, then 0.4, 1.4, 2.4, and 3 to 5 ms. It returned to 0.1 ms the moment the process exited. Audio in unrelated applications dropped out while the handler was saturated and stopped doing so once the semaphores were gone.

Where the time goes in the source

In the 620.73.04 tree:

  • _gpuEngineEventNotificationListNotify in src/nvidia/src/kernel/rmapi/event_notification.c is called from the ISR on Linux. It takes the per-engine list spinlock, visits every node on the list, and then calls osNotifyEvent for each one.
  • semsurfCtrlCmdBindChannel_IMPL in src/nvidia/src/kernel/gpu/mem_mgr/sem_surf.c calls _semsurfRegisterCallback, which allocates an NV01_EVENT_KERNEL_CALLBACK_EX with NV01_EVENT_NONSTALL_INTR for each semaphore surface and notify index. Those events are inserted into the same per-engine list, and _semsurfEventCallback runs for each of them on every non-stall interrupt, including when it has no waiters.
  • _gpuEngineEventNotificationListLockPreemptible spins while a notify pass is active, so adding or removing a listener waits for the handler.

The per-interrupt work is linear in the length of that list. The measured cost followed the number of textures the application had loaded, each owning one timeline semaphore, and it went away when the application stopped creating them.

Workaround

The layer is being changed to create no per-texture semaphores on NVIDIA.

主要语言
C
星标
17.7k
派生
2k
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

NVIDIA/open-gpu-kernel-modules 的其他 Issue

查看 NVIDIA/open-gpu-kernel-modules 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。