public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: Natalie Vock <natalie.vock@gmx.de>
To: Qiliang Yuan <realwujing@gmail.com>,
	Maarten Lankhorst <dev@lankhorst.se>,
	Maxime Ripard <mripard@kernel.org>, Tejun Heo <tj@kernel.org>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Michal Koutný <mkoutny@suse.com>
Cc: cgroups@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] cgroup/dmem: implement dmem.high soft limit and throttling
Date: Thu, 21 May 2026 12:52:53 +0200	[thread overview]
Message-ID: <c9eeee76-25a8-482e-9ef4-74971537457f@gmx.de> (raw)
In-Reply-To: <20260520-feature-dmem-high-v1-1-97ca0cb7f95a@gmail.com>

On 5/20/26 08:07, Qiliang Yuan wrote:
> Introduce the "high" soft limit for the dmem cgroup v2 controller.
> When a cgroup's device memory usage exceeds its high limit, tasks
> belonging to that cgroup are throttled by being forced into a sleep
> before returning to user space, instead of being failed outright
> as with the "max" limit.
> 
> Key changes:
> - Add high counter configuration to dmem_cgroup_pool.
> - Add over-high check in the try_charge path and set TIF_NOTIFY_RESUME.
> - Inject the dmem throttling handler into resume_user_mode_work.
> - Implement the handler to perform a 100ms interruptible sleep for
>    over-limit tasks.


Interesting proposal, but inserting sleeps on allocation is never a good 
idea and doesn't work like you might think it does. In graphics driver 
land, lots of random things may result in buffer allocation functions 
being called. Whenever TTM determines some buffer needs to be physically 
moved (most often during VRAM contention, but also as a result of 
pinning buffers for scanout, etc etc), dmem cgroup pools are 
charged/uncharged in accordance with the change in buffer residency. 
Sleeping in a charge/uncharge path means that in the worst case, a task 
will be put to sleep over and over again for exceeding its high limit 
just once.

Most critically, submit ioctls typically go over the task's entire 
working set and call ttm_bo_validate() to make sure the buffer is 
accessible by the GPU, since paging things in on fault is not available 
in many consumer GPUs. Your approach could lead to every single 
submission sleeping for at least 100ms, thus permanently destroying 
performance.

Maarten's suggestion of preferentially evicting memory that is over the 
high limit sounds like a better approach.

(Also, did you use AI for this? Please disclose your AI usage as per 
kernel guidelines if so.)

Best,
Natalie

  parent reply	other threads:[~2026-05-21 10:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-20  6:07 [PATCH] cgroup/dmem: implement dmem.high soft limit and throttling Qiliang Yuan
2026-05-20  9:52 ` Tejun Heo
2026-05-21 11:28   ` Qiliang Yuan
2026-05-21  9:45 ` Maarten Lankhorst
2026-05-21 11:28   ` Qiliang Yuan
2026-05-21 10:52 ` Natalie Vock [this message]
2026-05-21 11:28   ` Qiliang Yuan
2026-05-25 12:14 ` Claude review: " Claude Code Review Bot
2026-05-25 12:14 ` Claude Code Review Bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c9eeee76-25a8-482e-9ef4-74971537457f@gmx.de \
    --to=natalie.vock@gmx.de \
    --cc=cgroups@vger.kernel.org \
    --cc=dev@lankhorst.se \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkoutny@suse.com \
    --cc=mripard@kernel.org \
    --cc=realwujing@gmail.com \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox