Skip to content

RFC: drm/xe: Dynamic Xe Memory Monitor

S Sebinraj intel-xe 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4RFC: ANDROID: drm/xe: add adaptive GPU memory growth monitor xe_mem_monitordrivers/gpu/drm/BUILD.bazel drivers/gpu/drm/defconfig_xe drivers/gpu/drm/xe/Kconfig +8 more+655 -00 replies
2/4RFC: ANDROID: drm/xe: register ttm page alloc vendor hooks internallydrivers/gpu/drm/BUILD.bazel drivers/gpu/drm/xe/xe_device.c drivers/gpu/drm/xe/xe_mem_monitor.c +3 more+178 -40 replies
3/4RFC: ANDROID: drm/xe: provide safe mem_monitor enable toggle via debugfsdrivers/gpu/drm/xe/xe_device.c drivers/gpu/drm/xe/xe_device_types.h drivers/gpu/drm/xe/xe_mem_monitor.c +2 more+166 -10 replies
4/4RFC: ANDROID: drm/xe: Gate mem_monitor wake ups on order 9 external fragmentationdrivers/gpu/drm/xe/xe_mem_monitor.c drivers/gpu/drm/xe/xe_mem_monitor.h drivers/gpu/drm/xe/xe_module.c +1 more+137 -40 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/4] RFC: drm/xe: Dynamic Xe Memory Monitor

Introduce xe_mem_monitor, a periodic worker that samples xe->global_total_pages (the same counter that feeds the gpu_mem/gpu_mem_total tracepoint) and tracks GPU memory growth using an exponential moving average (EMA) over per-interval deltas:

delta(t) = max(0, mem(t) - mem(t-1))
EMA(t) = alpha * delta(t) + (1 - alpha) * EMA(t-1)

where alpha = 0.8, applied to every real sample regardless of mode.

A single alpha and a single polling cadence (mem_monitor_poll_ms) are used in both LATENCY and HIGH_THROUGHPUT mode, once HIGH_THROUGHPUT mode is entered there is little benefit to re-checking any faster, since mem_monitor_debounce_count consecutive below-threshold samples are already required before switching back, which itself provides the desired minimum dwell time (debounce_count * poll_ms) at this single cadence.

When the EMA of growth exceeds a threshold, xe->gpu_mem_mode is switched from XE_GPU_MEM_MODE_LATENCY to XE_GPU_MEM_MODE_HIGH_THROUGHPUT, and back once mem_monitor_debounce_count consecutive below-threshold samples are seen.

xe->gpu_mem_mode is intended to be read by the TTM page allocation path to trade allocation latency for throughput during GPU memory growth bursts; the GFP flag adjustment itself is added in a follow-up change.

For power, the worker sleeps after mem_monitor_idle_timeout_ms of no significant activity in LATENCY mode. The worker is re-armed on activity.

The worker is suspended/resumed across system and runtime PM transitions with notify_activity() also disabled while suspended.

All tuning is exposed as module parameters (mem_monitor_*) under /sys/module/xe/parameters/. Defaults:

mem_monitor_enabled false
mem_monitor_growth_threshold_mb 250
mem_monitor_poll_ms 2000
mem_monitor_debounce_count 5
mem_monitor_idle_timeout_ms 10000

S Sebinraj (3):
RFC: ANDROID: drm/xe: add adaptive GPU memory growth monitor
xe_mem_monitor
RFC: ANDROID: drm/xe: register ttm page alloc vendor hooks internally
RFC: ANDROID: drm/xe: Gate mem_monitor wake ups on order 9 external
fragmentation

Ryan Neph (1):
RFC: ANDROID: drm/xe: provide safe mem_monitor enable toggle via
debugfs

 drivers/gpu/drm/BUILD.bazel              |   4 +
 drivers/gpu/drm/defconfig_xe             |   1 +
 drivers/gpu/drm/xe/Kconfig               |  14 +
 drivers/gpu/drm/xe/xe_bo.c               |   3 +
 drivers/gpu/drm/xe/xe_device.c           |  12 +
 drivers/gpu/drm/xe/xe_device_types.h     |  13 +
 drivers/gpu/drm/xe/xe_mem_monitor.c      | 727 +++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_mem_monitor.h      |  95 +++
 drivers/gpu/drm/xe/xe_module.c           |  78 +++
 drivers/gpu/drm/xe/xe_module.h           |  15 +
 drivers/gpu/drm/xe/xe_pm.c               |   5 +
 drivers/gpu/drm/xe/xe_trace.h            |  16 +
 drivers/gpu/drm/xe/xe_ttm_vendor_hooks.c | 135 +++++
 drivers/gpu/drm/xe/xe_ttm_vendor_hooks.h |   9 +
 14 files changed, 1127 insertions(+)
 create mode 100644 drivers/gpu/drm/xe/xe_mem_monitor.c
 create mode 100644 drivers/gpu/drm/xe/xe_mem_monitor.h
 create mode 100644 drivers/gpu/drm/xe/xe_ttm_vendor_hooks.c
 create mode 100644 drivers/gpu/drm/xe/xe_ttm_vendor_hooks.h
Signature · 1 line
2.34.1