Hey, Den 2026-03-18 kl. 20:34, skrev Thadeu Lima de Souza Cascardo: > page_counter_set_max may return -EBUSY in case the current usage is above > the new max. When writing to dmem.max, this error is ignored and the new > max is not set. > > Return as soon as setting one of the regions max limit fails. This keeps > with the current behavior of returning when one of the region names is not > valid. > > After this fix, setting a max value below the current value returns -EBUSY. > > # cat dmem.current > drm/0000:04:00.0/vram 1060864 > # echo drm/0000:04:00.0/vram 0 > dmem.max > -bash: echo: write error: Device or resource busy > # > > Signed-off-by: Thadeu Lima de Souza Cascardo <[email protected]> The semantics of dmemcg should not substantially differ from the memory cgroup controller. I believe the memory cgroup controller does allow setting a lower max, and will evict until below the new max.
See mm/memcontrol.c:memory_max_write We should probably do the same in dmemcg instead, although we currently have no mechanism to evict, setting a new lower max at least prevents future allocations from failing. I believe we should have a similar loop in dmemcg, and allow ttm to evict until the new max is reached. Kind regards, ~Maarten Lankhorst
