When writing to dmem.max, it was noticed that some writes did not take effect, even though the write was successful.
It turns out that page_counter_set_max checks if the new max value is above the current usage and returns -EBUSY in case it is, which was being ignored by dmemcg_limit_write. It was also noticed that when setting limits for multiple regions in a single write, while setting one region's limit may fail, others might have succeeded before. Tejun Heo brought up that this breaks atomicity. Maarten Lankhorst and Michal Koutný have brought up that instead of failing, setting max below the current usage should behave like memcg and start eviction until usage goes below the new max. However, since there is no current mechanism to evict a given region, they suggest that setting the new max will at least prevent further allocations. v1 kept the multiple region support when writing to limit files, while returning -EBUSY as soon as setting a region's max was above the usage. This version (v2) only allows setting a single region limit per write, while allowing any new max to be set. Signed-off-by: Thadeu Lima de Souza Cascardo <[email protected]> --- Changes in v2: - Remove support for setting multiple regions' limits. - Allow any new max limit to be set. - Link to v1: https://lore.kernel.org/r/[email protected] --- Thadeu Lima de Souza Cascardo (3): cgroup/dmem: remove region parameter from dmemcg_parse_limit cgroup/dmem: accept a single region when writing to attributes cgroup/dmem: allow max to be set below current usage kernel/cgroup/dmem.c | 74 +++++++++++++++++++++++----------------------------- 1 file changed, 32 insertions(+), 42 deletions(-) --- base-commit: f338e77383789c0cae23ca3d48adcc5e9e137e3c change-id: 20260318-dmem_max_ebusy-bfd33564f2c3 Best regards, -- Thadeu Lima de Souza Cascardo <[email protected]>
