From: sashiko-bot@kernel.org
To: "Tvrtko Ursulin" <tvrtko.ursulin@igalia.com>,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 7/7] drm/syncobj: Add temporary array allocation fast paths
Date: Thu, 26 Nov 2026 11:22:07 +0000 [thread overview]
Message-ID: <sashiko-outbox-235371@kernel.org> (raw)
In-Reply-To: <20261126111117.67342-8-tvrtko.ursulin@igalia.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/syncobj: unconverted handles allocation in
drm_syncobj_array_find()
--
commit 9cfbb7c668583619e7699957c17e9063e116a22e
Author: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
drm/syncobj: Add temporary array allocation fast paths
This commit adds stack-backed fast-path macros for temporary syncobj array
allocations up to four elements and converts the syncobj wait, reset,
signal, and query paths to use them.
> diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
> index 6b4df322b12a8..cde7835744177 100644
> --- a/drivers/gpu/drm/drm_syncobj.c
> +++ b/drivers/gpu/drm/drm_syncobj.c
> @@ -214,6 +214,53 @@
>
> #include "drm_internal.h"
>
> +/*
> + * Empirically vast majority of ioctls pass in a single syncobj (96%) and never
> + * more than three points. Therefore implement a fast path with a small stack
> + * array to avoid going into the allocator sometimes several times per
> + * userspace rendered frame.
> + */
> +#define DRM_SYNCOBJ_FAST_PATH_ENTRIES 4
> +
> +#define DRM_SYNCOBJ_DECLARE_FASTPATH_ARRAY(_type, _name) \
> + _type _name##_stack[DRM_SYNCOBJ_FAST_PATH_ENTRIES]; \
> + _type * _name##_heap __free(kvfree) = NULL; \
> + _type * _name
> +
> +#define DRM_SYNCOBJ_INIT_FASTPATH_ARRAY(_name, _src, _count) ({ \
> + int __ret = 0; \
> + \
> + if ((_count) > ARRAY_SIZE(_name##_stack)) { \
> + if (_src) { \
> + _name##_heap = vmemdup_array_user((_src), \
> + (_count), \
> + sizeof(*(_name))); \
> + if (IS_ERR(_name##_heap)) { \
> + __ret = PTR_ERR(no_free_ptr(_name##_heap)); \
> + } else { \
> + _name = _name##_heap; \
> + } \
> + } else { \
> + _name##_heap = kvzalloc_objs(*(_name), (_count)); \
> + if (!_name##_heap) \
> + __ret = -ENOMEM; \
> + else \
> + _name = _name##_heap; \
> + } \
> + } else { \
> + size_t __size = (_count) * sizeof(*(_name)); \
> + \
> + _name = _name##_stack; \
> + if (_src) { \
> + if (copy_from_user(_name, (_src), __size)) \
> + __ret = -EFAULT; \
> + } else { \
> + memset(_name, 0, __size); \
> + } \
> + } \
> + __ret; \
> +})
[Severity: Medium]
Was drm_syncobj_array_find() meant to be converted to use the fast-path
array macros for its temporary handles array as well?
The commit message notes that drm_syncobj_array_find() is called with one
to three objects in almost all calls, and commit "drm/syncobj: Use scoped
cleanup in drm_syncobj_array_find and callers" converted handles to scoped
cleanup, but drm_syncobj_array_find() still unconditionally allocates and
frees handles on the heap on every syncobj array ioctl:
drivers/gpu/drm/drm_syncobj.c:drm_syncobj_array_find() {
u32 *handles __free(kvfree) = NULL;
unsigned int i;
handles = vmemdup_array_user(user_handles, count, sizeof(*handles));
if (IS_ERR(handles))
return PTR_ERR(no_free_ptr(handles));
...
}
Note that if drm_syncobj_array_find() is converted to
DRM_SYNCOBJ_INIT_FASTPATH_ARRAY(), a runtime NULL user_handles pointer
(args->handles == 0) must still return -EFAULT rather than taking the
!_src zero-initialization branch and looking up handle 0 (-ENOENT).
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126111117.67342-1-tvrtko.ursulin@igalia.com?part=7
next prev parent reply other threads:[~2026-11-26 11:22 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 11:11 [PATCH 0/7] DRM syncobj scoped cleanup and fast path Tvrtko Ursulin
2026-11-26 11:11 ` [PATCH 1/7] drm/syncobj: Use vmemdup_array_user in drm_syncobj_array_find Tvrtko Ursulin
2026-11-26 11:59 ` Christian König
2026-11-26 11:11 ` [PATCH 2/7] drm/syncobj: Use scoped cleanup for drm_syncobj_array_wait_timeout points Tvrtko Ursulin
2026-11-26 12:09 ` Christian König
2026-11-26 14:22 ` Tvrtko Ursulin
2026-11-26 11:11 ` [PATCH 3/7] drm/syncobj: Use scoped cleanup for drm_syncobj_array_wait_timeout syncobjs Tvrtko Ursulin
2026-11-26 11:17 ` sashiko-bot
2026-11-26 12:11 ` Christian König
2026-11-26 14:33 ` Tvrtko Ursulin
2026-11-26 11:11 ` [PATCH 4/7] drm/syncobj: Use scoped cleanup for drm_syncobj_timeline_signal_ioctl points Tvrtko Ursulin
2026-11-26 12:15 ` Christian König
2026-11-26 11:11 ` [PATCH 5/7] drm/syncobj: Use scoped cleanup for drm_syncobj_timeline_signal_ioctl chains Tvrtko Ursulin
2026-11-26 11:21 ` sashiko-bot
2026-11-26 12:19 ` Christian König
2026-11-26 11:11 ` [PATCH 6/7] drm/syncobj: Use scoped cleanup in drm_syncobj_array_find and callers Tvrtko Ursulin
2026-11-26 11:19 ` sashiko-bot
2026-11-26 11:11 ` [PATCH 7/7] drm/syncobj: Add temporary array allocation fast paths Tvrtko Ursulin
2026-11-26 11:22 ` sashiko-bot [this message]
2026-11-26 11:49 ` [PATCH v2 " Tvrtko Ursulin
2026-11-27 7:59 ` Fei Yu
2026-11-27 7:58 ` [PATCH 0/7] DRM syncobj scoped cleanup and fast path Fei Yu
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=sashiko-outbox-235371@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tvrtko.ursulin@igalia.com \
/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.