From: sashiko-bot@kernel.org
To: "Natalie Vock" <natalie.vock@gmx.de>
Cc: tj@kernel.org, mkoutny@suse.com, dri-devel@lists.freedesktop.org,
hannes@cmpxchg.org
Subject: Re: [PATCH v8 3/6] drm/ttm: Extract code for attempting allocation in a place
Date: Tue, 04 Aug 2026 08:41:22 +0000 [thread overview]
Message-ID: <20260804084126.179841F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260804-dmemcg-aggressive-protect-v8-3-07af96681bf8@gmx.de>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The synthetic `-EBUSY` signal collides with the native `-EBUSY` error code, causing unintended evictions and silent API contract changes.
--
--- Patch [3]: [PATCH v8 3/6] drm/ttm: Extract code for attempting allocation in a place ---
commit 8416fd662f16adcc69fd20180c1e3da4cb94ac03
Author: Natalie Vock <nat@pixelcluster.dev>
drm/ttm: Extract code for attempting allocation in a place
This commit moves the logic for attempting buffer allocation for a specific
place into a separate ttm_bo_alloc_at_place() function. It uses a synthetic
-EBUSY return code to signal that eviction should be attempted.
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 3980f376e3ba4..1cdb2172d5924 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
[ ... ]
> @@ -488,6 +488,51 @@ int ttm_bo_evict_first(struct ttm_device *bdev, struct ttm_resource_manager *man
> +static int ttm_bo_alloc_at_place(struct ttm_buffer_object *bo,
> + const struct ttm_place *place,
> + bool force_space,
> + struct ttm_resource **res,
> + struct ttm_bo_alloc_state *alloc_state)
> +{
> + bool may_evict;
> + int ret;
> +
> + may_evict = force_space && place->mem_type != TTM_PL_SYSTEM;
> +
> + ret = ttm_resource_alloc(bo, place, res,
> + force_space ? &alloc_state->limit_pool : NULL);
> +
> + if (ret) {
> + if (ret == -ENOSPC && may_evict)
> + return -EBUSY;
> +
> + return ret;
[Severity: Medium]
If ttm_resource_alloc() organically returns -EBUSY, will this native error be
passed up unmodified and collide with the synthetic -EBUSY eviction signal?
> + }
> +
> + return 0;
> +}
[ ... ]
> @@ -736,25 +782,25 @@ 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) {
> - dmem_cgroup_pool_state_put(limit_pool);
> - return ret;
> - }
> - if (!may_evict) {
> - dmem_cgroup_pool_state_put(limit_pool);
> - continue;
> - }
> + ret = ttm_bo_alloc_at_place(bo, place, force_space, res,
> + &alloc_state);
>
> + if (ret == -ENOSPC) {
> + dmem_cgroup_pool_state_put(alloc_state.limit_pool);
> + continue;
> + } else if (ret == -EBUSY) {
> ret = ttm_bo_evict_alloc(bdev, man, place, bo, ctx,
> - ticket, res, limit_pool);
> - dmem_cgroup_pool_state_put(limit_pool);
> + ticket, res, &alloc_state);
[Severity: Medium]
Before this patch, if ttm_resource_alloc() returned a native -EBUSY, it was
directly returned to the caller since it was not -ENOSPC.
By treating any -EBUSY returned from ttm_bo_alloc_at_place() as a signal to evict,
does this inadvertently cause an organic -EBUSY to trigger an unnecessary eviction
walk rather than propagating the error?
> +
> + dmem_cgroup_pool_state_put(alloc_state.limit_pool);
> +
> if (ret == -EBUSY)
> continue;
> - if (ret)
> + else if (ret)
> return ret;
> + } else if (ret) {
> + dmem_cgroup_pool_state_put(alloc_state.limit_pool);
> + return ret;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260804-dmemcg-aggressive-protect-v8-0-07af96681bf8@gmx.de?part=3
next prev parent reply other threads:[~2026-08-04 8:41 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-04 8:25 [PATCH v8 0/6] cgroup/dmem,drm/ttm: Improve protection in contended cases Natalie Vock
2026-08-04 8:25 ` [PATCH v8 1/6] cgroup/dmem: Add queries for protection values Natalie Vock
2026-08-04 8:41 ` sashiko-bot
2026-08-04 8:25 ` [PATCH v8 2/6] cgroup,cgroup/dmem: Add (dmem_)cgroup_common_ancestor helper Natalie Vock
2026-08-04 20:18 ` Maarten Lankhorst
2026-08-04 20:26 ` Natalie Vock
2026-08-04 20:41 ` Maarten Lankhorst
2026-08-04 20:56 ` Thadeu Lima de Souza Cascardo
2026-08-04 21:08 ` Natalie Vock
2026-08-04 22:06 ` Thadeu Lima de Souza Cascardo
2026-08-05 2:08 ` Thadeu Lima de Souza Cascardo
2026-08-05 6:30 ` Maarten Lankhorst
2026-08-04 8:25 ` [PATCH v8 3/6] drm/ttm: Extract code for attempting allocation in a place Natalie Vock
2026-08-04 8:41 ` sashiko-bot [this message]
2026-08-04 8:25 ` [PATCH v8 4/6] drm/ttm: Split cgroup charge and resource allocation Natalie Vock
2026-08-04 8:44 ` sashiko-bot
2026-08-04 8:25 ` [PATCH v8 5/6] drm/ttm: Be more aggressive when allocating below protection limit Natalie Vock
2026-08-04 8:40 ` sashiko-bot
2026-08-04 8:25 ` [PATCH v8 6/6] drm/ttm: Use common ancestor of evictor and evictee as limit pool Natalie Vock
2026-08-04 8:53 ` sashiko-bot
2026-08-04 15:36 ` [PATCH v8 0/6] cgroup/dmem, drm/ttm: Improve protection in contended cases Timur Kristóf
2026-08-04 15:36 ` [PATCH v8 0/6] cgroup/dmem,drm/ttm: " Timur Kristóf
2026-08-05 8:42 ` Natalie Vock
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=20260804084126.179841F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=hannes@cmpxchg.org \
--cc=mkoutny@suse.com \
--cc=natalie.vock@gmx.de \
--cc=sashiko-reviews@lists.linux.dev \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.