On Thu, Nov 26, 2026 at 11:49:45AM +0000, Tvrtko Ursulin wrote:
> Running the Cyberpunk 2077 benchmark we can observe that waiting on DRM
> sycobjs (drm_syncobj_array_wait_timeout) is relatively hot, but that the

Nit: "sycobjs" -> "syncobjs".

> v2:
>  * Use fast path in drm_syncobj_array_find itself!

Thanks, that drops the handles allocation from every array ioctl
(and covers the sashiko comment on v1).

> +#define DRM_SYNCOBJ_INIT_FASTPATH_ARRAY(_name, _src, _count) ({              
> \
[...]
> +     } 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;                                                          \
> +})

A NULL _src means "zero-fill" here. That is the right thing for the
points arrays, but it is also why array_find needs its own check:

> +     if (!user_handles)
> +             return -EFAULT; /* Preserve ABI error code */

A future caller that forgets this check would silently get zeroes
instead of -EFAULT for a NULL user pointer. Maybe split the init into
a copy variant and a zero variant (a NULL user pointer then fails in
copy_from_user() / vmemdup_array_user() as before, and this check can
go), or at least say in a comment above the macro that NULL means
zero-fill?

Reviewed-by: Fei Yu <[email protected]>

Thanks,
Fei

Reply via email to