From: "Christian König" <christian.koenig@amd.com>
To: "Yu, Fei" <fei.yu@intel.com>
Cc: airlied@gmail.com, dri-devel@lists.freedesktop.org,
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 10:55:24 +0100 [thread overview]
Message-ID: <a37fc9d5-ebc6-4a31-b393-11a09a73eefe@amd.com> (raw)
In-Reply-To: <20261106053503.1437526-1-fei.yu@intel.com>
On 11/6/26 06:35, Yu, Fei wrote:
> 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.
Work for me and should really cover everything ever needed here.
>
> 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));
Looks good but I have no idea if that really works or not :)
> 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.
Yeah work for me as well.
Thanks,
Christian.
>
> Regards,
> Fei
prev parent reply other threads:[~2026-11-06 9:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 3:09 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
2026-11-06 9:55 ` Christian König [this message]
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=a37fc9d5-ebc6-4a31-b393-11a09a73eefe@amd.com \
--to=christian.koenig@amd.com \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=fei.yu@intel.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®