* [PATCH] drm/ttm: Convert -EAGAIN from dmem_cgroup_try_charge to -ENOSPC
@ 2026-05-08 16:09 Thomas Hellström
2026-05-08 17:03 ` Maarten Lankhorst
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Hellström @ 2026-05-08 16:09 UTC (permalink / raw)
To: intel-xe
Cc: Thomas Hellström, Friedrich Vock, Maarten Lankhorst,
Tejun Heo, Maxime Ripard, Christian Koenig, dri-devel, stable
dmem_cgroup_try_charge() returns -EAGAIN when the cgroup limit is
hit and the charge fails. TTM has no concept of -EAGAIN from resource
allocation; -ENOSPC is the canonical error meaning "no space, try
eviction". Convert at the source in ttm_resource_alloc() so no caller
needs to handle an unexpected error code, and clean up the now-redundant
-EAGAIN check in ttm_bo_alloc_resource().
Without this, -EAGAIN escaping ttm_resource_alloc() during an eviction
walk causes the walk to terminate early instead of continuing to the
next candidate.
Cc: Friedrich Vock <friedrich.vock@gmx.de>
Cc: Maarten Lankhorst <dev@lankhorst.se>
Cc: Tejun Heo <tj@kernel.org>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Christian Koenig <christian.koenig@amd.com>
Cc: dri-devel@lists.freedesktop.org
Cc: <stable@vger.kernel.org> # v6.14+
Fixes: 2b624a2c1865 ("drm/ttm: Handle cgroup based eviction in TTM")
Assisted-by: GitHub_Copilot:claude-sonnet-4.6
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
---
drivers/gpu/drm/ttm/ttm_bo.c | 2 +-
drivers/gpu/drm/ttm/ttm_resource.c | 5 ++++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index d85f0a37ac35..cee3828df655 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -739,7 +739,7 @@ static int ttm_bo_alloc_resource(struct ttm_buffer_object *bo,
may_evict = (force_space && place->mem_type != TTM_PL_SYSTEM);
ret = ttm_resource_alloc(bo, place, res, force_space ? &limit_pool : NULL);
if (ret) {
- if (ret != -ENOSPC && ret != -EAGAIN) {
+ if (ret != -ENOSPC) {
dmem_cgroup_pool_state_put(limit_pool);
return ret;
}
diff --git a/drivers/gpu/drm/ttm/ttm_resource.c b/drivers/gpu/drm/ttm/ttm_resource.c
index 9f36631d48b6..b0efffe5a526 100644
--- a/drivers/gpu/drm/ttm/ttm_resource.c
+++ b/drivers/gpu/drm/ttm/ttm_resource.c
@@ -385,8 +385,11 @@ int ttm_resource_alloc(struct ttm_buffer_object *bo,
if (man->cg) {
ret = dmem_cgroup_try_charge(man->cg, bo->base.size, &pool, ret_limit_pool);
- if (ret)
+ if (ret) {
+ if (ret == -EAGAIN)
+ ret = -ENOSPC;
return ret;
+ }
}
ret = man->func->alloc(man, bo, place, res_ptr);
--
2.54.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/ttm: Convert -EAGAIN from dmem_cgroup_try_charge to -ENOSPC
2026-05-08 16:09 [PATCH] drm/ttm: Convert -EAGAIN from dmem_cgroup_try_charge to -ENOSPC Thomas Hellström
@ 2026-05-08 17:03 ` Maarten Lankhorst
2026-05-11 8:02 ` Thomas Hellström
0 siblings, 1 reply; 3+ messages in thread
From: Maarten Lankhorst @ 2026-05-08 17:03 UTC (permalink / raw)
To: Thomas Hellström, intel-xe
Cc: Friedrich Vock, Tejun Heo, Maxime Ripard, Christian Koenig,
dri-devel, stable
Hey,
Den 2026-05-08 kl. 18:09, skrev Thomas Hellström:
> dmem_cgroup_try_charge() returns -EAGAIN when the cgroup limit is
> hit and the charge fails. TTM has no concept of -EAGAIN from resource
> allocation; -ENOSPC is the canonical error meaning "no space, try
> eviction". Convert at the source in ttm_resource_alloc() so no caller
> needs to handle an unexpected error code, and clean up the now-redundant
> -EAGAIN check in ttm_bo_alloc_resource().
>
> Without this, -EAGAIN escaping ttm_resource_alloc() during an eviction
> walk causes the walk to terminate early instead of continuing to the
> next candidate.
>
> Cc: Friedrich Vock <friedrich.vock@gmx.de>
> Cc: Maarten Lankhorst <dev@lankhorst.se>
> Cc: Tejun Heo <tj@kernel.org>
> Cc: Maxime Ripard <mripard@kernel.org>
> Cc: Christian Koenig <christian.koenig@amd.com>
> Cc: dri-devel@lists.freedesktop.org
> Cc: <stable@vger.kernel.org> # v6.14+
> Fixes: 2b624a2c1865 ("drm/ttm: Handle cgroup based eviction in TTM")
> Assisted-by: GitHub_Copilot:claude-sonnet-4.6
> Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> ---
> drivers/gpu/drm/ttm/ttm_bo.c | 2 +-
> drivers/gpu/drm/ttm/ttm_resource.c | 5 ++++-
> 2 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index d85f0a37ac35..cee3828df655 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -739,7 +739,7 @@ static int ttm_bo_alloc_resource(struct ttm_buffer_object *bo,
> may_evict = (force_space && place->mem_type != TTM_PL_SYSTEM);
> ret = ttm_resource_alloc(bo, place, res, force_space ? &limit_pool : NULL);
> if (ret) {
> - if (ret != -ENOSPC && ret != -EAGAIN) {
> + if (ret != -ENOSPC) {
> dmem_cgroup_pool_state_put(limit_pool);
> return ret;
> }
> diff --git a/drivers/gpu/drm/ttm/ttm_resource.c b/drivers/gpu/drm/ttm/ttm_resource.c
> index 9f36631d48b6..b0efffe5a526 100644
> --- a/drivers/gpu/drm/ttm/ttm_resource.c
> +++ b/drivers/gpu/drm/ttm/ttm_resource.c
> @@ -385,8 +385,11 @@ int ttm_resource_alloc(struct ttm_buffer_object *bo,
>
> if (man->cg) {
> ret = dmem_cgroup_try_charge(man->cg, bo->base.size, &pool, ret_limit_pool);
> - if (ret)
> + if (ret) {
> + if (ret == -EAGAIN)
> + ret = -ENOSPC;
> return ret;
> + }
> }
>
> ret = man->func->alloc(man, bo, place, res_ptr);
Yeah looks reasonable with the conversion to callbacks.
Reviewed-by: Maarten Lankhorst <dev@lankhrost.se>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/ttm: Convert -EAGAIN from dmem_cgroup_try_charge to -ENOSPC
2026-05-08 17:03 ` Maarten Lankhorst
@ 2026-05-11 8:02 ` Thomas Hellström
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Hellström @ 2026-05-11 8:02 UTC (permalink / raw)
To: Maarten Lankhorst, intel-xe
Cc: Friedrich Vock, Tejun Heo, Maxime Ripard, Christian Koenig,
dri-devel, stable
On Fri, 2026-05-08 at 19:03 +0200, Maarten Lankhorst wrote:
> Hey,
>
> Den 2026-05-08 kl. 18:09, skrev Thomas Hellström:
> > dmem_cgroup_try_charge() returns -EAGAIN when the cgroup limit is
> > hit and the charge fails. TTM has no concept of -EAGAIN from
> > resource
> > allocation; -ENOSPC is the canonical error meaning "no space, try
> > eviction". Convert at the source in ttm_resource_alloc() so no
> > caller
> > needs to handle an unexpected error code, and clean up the now-
> > redundant
> > -EAGAIN check in ttm_bo_alloc_resource().
> >
> > Without this, -EAGAIN escaping ttm_resource_alloc() during an
> > eviction
> > walk causes the walk to terminate early instead of continuing to
> > the
> > next candidate.
> >
> > Cc: Friedrich Vock <friedrich.vock@gmx.de>
> > Cc: Maarten Lankhorst <dev@lankhorst.se>
> > Cc: Tejun Heo <tj@kernel.org>
> > Cc: Maxime Ripard <mripard@kernel.org>
> > Cc: Christian Koenig <christian.koenig@amd.com>
> > Cc: dri-devel@lists.freedesktop.org
> > Cc: <stable@vger.kernel.org> # v6.14+
> > Fixes: 2b624a2c1865 ("drm/ttm: Handle cgroup based eviction in
> > TTM")
> > Assisted-by: GitHub_Copilot:claude-sonnet-4.6
> > Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> > ---
> > drivers/gpu/drm/ttm/ttm_bo.c | 2 +-
> > drivers/gpu/drm/ttm/ttm_resource.c | 5 ++++-
> > 2 files changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo.c
> > b/drivers/gpu/drm/ttm/ttm_bo.c
> > index d85f0a37ac35..cee3828df655 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo.c
> > +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> > @@ -739,7 +739,7 @@ static int ttm_bo_alloc_resource(struct
> > ttm_buffer_object *bo,
> > may_evict = (force_space && place->mem_type !=
> > TTM_PL_SYSTEM);
> > ret = ttm_resource_alloc(bo, place, res,
> > force_space ? &limit_pool : NULL);
> > if (ret) {
> > - if (ret != -ENOSPC && ret != -EAGAIN) {
> > + if (ret != -ENOSPC) {
> > dmem_cgroup_pool_state_put(limit_p
> > ool);
> > return ret;
> > }
> > diff --git a/drivers/gpu/drm/ttm/ttm_resource.c
> > b/drivers/gpu/drm/ttm/ttm_resource.c
> > index 9f36631d48b6..b0efffe5a526 100644
> > --- a/drivers/gpu/drm/ttm/ttm_resource.c
> > +++ b/drivers/gpu/drm/ttm/ttm_resource.c
> > @@ -385,8 +385,11 @@ int ttm_resource_alloc(struct
> > ttm_buffer_object *bo,
> >
> > if (man->cg) {
> > ret = dmem_cgroup_try_charge(man->cg, bo-
> > >base.size, &pool, ret_limit_pool);
> > - if (ret)
> > + if (ret) {
> > + if (ret == -EAGAIN)
> > + ret = -ENOSPC;
> > return ret;
> > + }
> > }
> >
> > ret = man->func->alloc(man, bo, place, res_ptr);
>
> Yeah looks reasonable with the conversion to callbacks.
>
> Reviewed-by: Maarten Lankhorst <dev@lankhrost.se>
Thanks for reviewing, Maarten!
@Christian, any concerns?
/Thomas
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-11 8:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-08 16:09 [PATCH] drm/ttm: Convert -EAGAIN from dmem_cgroup_try_charge to -ENOSPC Thomas Hellström
2026-05-08 17:03 ` Maarten Lankhorst
2026-05-11 8:02 ` Thomas Hellström
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox