Commit f0a2d8f
committed
drm/amdgpu: bounded mman.gtt_window_lock acquisition via gtt_lock_timeout_ms
Add a new module parameter `gtt_lock_timeout_ms` (default 0 =
unbounded, byte-identical to the current mutex_lock() behaviour) that
caps the wait time for `adev->mman.gtt_window_lock` in the three
amdgpu_ttm.c paths that take it:
- amdgpu_ttm_copy_mem_to_mem() (SDMA buffer<->buffer copy)
- amdgpu_ttm_clear_buffer() (SDMA buffer clear/wipe)
- amdgpu_fill_buffer() (SDMA buffer fill)
When `gtt_lock_timeout_ms > 0`, the helper `amdgpu_ttm_lock_gtt_window()`
replaces the unbounded `mutex_lock()` with a trylock-and-sleep loop
bounded by a wall-clock deadline. On timeout the helper returns
-ETIME so the caller fails fast instead of parking on a wedged SDMA
ring. Values below 100 ms are clamped up to 100 ms to avoid
mis-configurations turning the lock-acquisition path into a fail-only
path. Pending signals are propagated as -ERESTARTSYS.
The default of 0 preserves stock behaviour byte-identically: the
helper degrades to a plain `mutex_lock()` and returns 0. This avoids
any behaviour change for users who do not opt in.
## Motivation
In multi-tenant HIP/AMDGPU serving workloads, a single wedged SDMA
ring can park every caller of amdgpu_ttm_copy_mem_to_mem() /
amdgpu_ttm_clear_buffer() / amdgpu_fill_buffer() on the global
`gtt_window_lock` mutex for minutes-plus while a single in-flight
copy waits for the ring. The hold time is bounded only by the
SDMA recovery path (which itself may need on the order of tens of
seconds). The legacy unbounded mutex_lock() then converts the SDMA
hang into a system-wide GTT-window stall affecting all VRAM-touching
ioctls from every tenant on the device.
`gtt_lock_timeout_ms` lets operators opt the GTT window contention
path into a bounded-wait failure mode (return -ETIME) so the higher-
level survival policy can choose whether to retry, re-queue, or
surface the error to the application.
## Test plan
- gtt_lock_timeout_ms unset / 0: stock behaviour, all existing tests
pass byte-identically.
- gtt_lock_timeout_ms=4000: under multi-tenant SDMA load, observed
~4 second worst-case wait on the lock (matching the configured
deadline), with -ETIME propagated back to the caller cleanly.
Reviewers may suggest using mutex_lock_killable_timeout() if
preferred over the explicit trylock-and-sleep loop; the current form
keeps the dependency surface minimal (no API additions).
Signed-off-by: chun-wan <chun-wan@users.noreply.github.com>1 parent d2762fd commit f0a2d8f
3 files changed
Lines changed: 84 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
| 278 | + | |
278 | 279 | | |
279 | 280 | | |
280 | 281 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1157 | 1157 | | |
1158 | 1158 | | |
1159 | 1159 | | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
1160 | 1186 | | |
1161 | 1187 | | |
1162 | 1188 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
307 | 307 | | |
308 | 308 | | |
309 | 309 | | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
310 | 355 | | |
311 | 356 | | |
312 | 357 | | |
| |||
331 | 376 | | |
332 | 377 | | |
333 | 378 | | |
334 | | - | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
335 | 383 | | |
336 | 384 | | |
337 | 385 | | |
| |||
2838 | 2886 | | |
2839 | 2887 | | |
2840 | 2888 | | |
2841 | | - | |
| 2889 | + | |
| 2890 | + | |
| 2891 | + | |
| 2892 | + | |
2842 | 2893 | | |
2843 | 2894 | | |
2844 | 2895 | | |
| |||
2892 | 2943 | | |
2893 | 2944 | | |
2894 | 2945 | | |
2895 | | - | |
| 2946 | + | |
| 2947 | + | |
| 2948 | + | |
| 2949 | + | |
2896 | 2950 | | |
2897 | 2951 | | |
2898 | 2952 | | |
| |||
0 commit comments