From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: Dave Airlie <airlied@gmail.com>, dri-devel@lists.freedesktop.org
Cc: Dave Airlie <airlied@redhat.com>,
Christian Koenig <christian.koenig@amd.com>,
Simona Vetter <simona.vetter@ffwll.ch>
Subject: Re: [PATCH 1/4] ttm/bo: add an API to populate a bo before exporting.
Date: Thu, 04 Sep 2025 09:20:21 +0200 [thread overview]
Message-ID: <65a9380b4d791fb4ec1f25c3bf3df2175da6fca7.camel@linux.intel.com> (raw)
In-Reply-To: <20250904021643.2050497-1-airlied@gmail.com>
On Thu, 2025-09-04 at 12:16 +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
>
> While discussing cgroups we noticed a problem where you could export
> a BO to a dma-buf without having it ever being backed or accounted
> for.
>
> This meant in low memory situations or eventually with cgroups, a
> lower privledged process might cause the compositor to try and
> allocate
> a lot of memory on it's behalf and this could fail. At least make
> sure the exporter has managed to allocate the RAM at least once
> before exporting the object.
>
> This only applies currently to TTM_PL_SYSTEM objects, because
> GTT objects get populated on first validate, and VRAM doesn't
> use TT.
>
> Reviewed-by: Christian Koenig <christian.koenig@amd.com>
> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> Cc: Simona Vetter <simona.vetter@ffwll.ch>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> ---
> drivers/gpu/drm/ttm/ttm_bo.c | 15 +++++++++++++++
> include/drm/ttm/ttm_bo.h | 2 ++
> 2 files changed, 17 insertions(+)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c
> b/drivers/gpu/drm/ttm/ttm_bo.c
> index 273757974b9f..a815c7478d3f 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -1284,3 +1284,18 @@ int ttm_bo_populate(struct ttm_buffer_object
> *bo,
> return 0;
> }
> EXPORT_SYMBOL(ttm_bo_populate);
> +
> +int ttm_bo_setup_export(struct ttm_buffer_object *bo,
> + struct ttm_operation_ctx *ctx)
> +{
> + int ret;
> +
> + ret = ttm_bo_reserve(bo, false, false, NULL);
> + if (ret != 0)
> + return ret;
> +
> + ret = ttm_bo_populate(bo, bo->resource->placement &
> TTM_PL_FLAG_MEMCG, ctx);
> + ttm_bo_unreserve(bo);
> + return ret;
> +}
> +EXPORT_SYMBOL(ttm_bo_setup_export);
> diff --git a/include/drm/ttm/ttm_bo.h b/include/drm/ttm/ttm_bo.h
> index c33b3667ae76..cdc9f5d1b420 100644
> --- a/include/drm/ttm/ttm_bo.h
> +++ b/include/drm/ttm/ttm_bo.h
> @@ -473,6 +473,8 @@ void ttm_bo_tt_destroy(struct ttm_buffer_object
> *bo);
> int ttm_bo_populate(struct ttm_buffer_object *bo,
> bool memcg_account,
> struct ttm_operation_ctx *ctx);
> +int ttm_bo_setup_export(struct ttm_buffer_object *bo,
> + struct ttm_operation_ctx *ctx);
>
> /* Driver LRU walk helpers initially targeted for shrinking. */
>
next prev parent reply other threads:[~2025-09-04 7:20 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-04 2:16 [PATCH 1/4] ttm/bo: add an API to populate a bo before exporting Dave Airlie
2025-09-04 2:16 ` [PATCH 2/4] amdgpu: populate buffers before exporting them Dave Airlie
2025-09-04 2:16 ` [PATCH 3/4] nouveau: " Dave Airlie
2025-09-09 7:33 ` Danilo Krummrich
2025-09-04 2:16 ` [PATCH 4/4] xe: " Dave Airlie
2025-09-04 7:26 ` Thomas Hellström
2025-09-04 7:20 ` Thomas Hellström [this message]
2025-09-04 11:13 ` [PATCH 1/4] ttm/bo: add an API to populate a bo before exporting Christian König
2025-09-09 7:31 ` Danilo Krummrich
2025-09-09 7:39 ` David Airlie
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=65a9380b4d791fb4ec1f25c3bf3df2175da6fca7.camel@linux.intel.com \
--to=thomas.hellstrom@linux.intel.com \
--cc=airlied@gmail.com \
--cc=airlied@redhat.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=simona.vetter@ffwll.ch \
/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.