From: "Yu, Fei" <fei.yu@intel.com>
To: christian.koenig@amd.com
Cc: airlied@gmail.com, dri-devel@lists.freedesktop.org,
fei.yu@intel.com, linux-kernel@vger.kernel.org,
maarten.lankhorst@linux.intel.com, madhurkumar004@gmail.com,
mripard@kernel.org, simona@ffwll.ch,
syzbot+95416f957d84e858b377@syzkaller.appspotmail.com,
tursulin@ursulin.net, tzimmermann@suse.de
Subject: Re: [PATCH v2] drm/syncobj: Limit the number of handles and use kvmalloc for user-sized arrays
Date: Fri, 6 Nov 2026 13:35:03 +0800 [thread overview]
Message-ID: <20261106053503.1437526-1-fei.yu@intel.com> (raw)
In-Reply-To: <a6a2ca76-94dc-4616-8160-d756713e22b9@amd.com>
From: Fei Yu <fei.yu@intel.com>
On 11/5/26, Christian König wrote:
> On 11/5/26 10:12, Tvrtko Ursulin wrote:
>> On 05/11/2026 08:18, Yu, Fei wrote:
>>> - The value is derived from the size of a kernel internal struct and
>>> from the kvmalloc() size limit, so it is not the same on 32-bit and
>>> 64-bit.
>
> Oh that is a really good point, but most certainly a bad idea.
>
> This means that code working on 32bit then suddenly fails on 64bit, not
> something we should do.
Agreed, a fixed number is better.
> I think I prefer a fixed number here. Something reasonable large enough,
> like 64k or similar, should do for backporting.
One concern with 64K: today only wait and timeline_wait break above
~64K handles, because of the 64-byte wait entries. The other ioctls
only allocate 4-8 bytes per handle, so on x86_64 reset, signal, query
and timeline_signal currently work up to ~512K handles. In my v2
testing, reset, signal and timeline_signal on 200000 handles succeed on
the base kernel. With a 64K limit they would start returning -EINVAL
after this fix, which I would rather avoid in a stable backport.
So I would suggest SZ_1M instead:
- it is above what any of these ioctls can handle today, so nothing
that works now starts failing;
- 1M wait entries are 64 MiB, far below the kvmalloc() INT_MAX limit;
- it is the same on 32-bit and 64-bit.
If you still prefer 64K, I'll go with that.
> But I would still use a fixed number and maybe a static assert that we
> don't hit the kvmalloc limit when we allocate that fixed number of
> structures.
Will do. Something like:
#define DRM_SYNCOBJ_MAX_HANDLES SZ_1M
static_assert(DRM_SYNCOBJ_MAX_HANDLES <=
INT_MAX / sizeof(struct syncobj_wait_entry));
Plan for v3, for -fixes:
- fixed DRM_SYNCOBJ_MAX_HANDLES plus the static_assert, define kept in
drm_syncobj.c;
- keep the kvmalloc() conversion;
- update the commit message accordingly.
The uAPI documentation of the limit will be a separate patch for -next
once this has landed.
Regards,
Fei
next prev parent reply other threads:[~2026-11-06 5:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 3:09 [PATCH v2] drm/syncobj: Limit the number of handles and use kvmalloc for user-sized arrays Yu, Fei
2026-11-04 9:44 ` Christian König
2026-11-04 10:27 ` Tvrtko Ursulin
2026-11-05 8:18 ` Yu, Fei
2026-11-05 9:12 ` Tvrtko Ursulin
2026-11-05 12:25 ` Christian König
2026-11-06 5:35 ` Yu, Fei [this message]
2026-11-06 9:55 ` Christian König
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=20261106053503.1437526-1-fei.yu@intel.com \
--to=fei.yu@intel.com \
--cc=airlied@gmail.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=madhurkumar004@gmail.com \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=syzbot+95416f957d84e858b377@syzkaller.appspotmail.com \
--cc=tursulin@ursulin.net \
--cc=tzimmermann@suse.de \
/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.