Re: [PATCH v3 2/2] drm/virtio: Support sync objects

From: Dmitry Osipenko
Date: Thu Mar 23 2023 - 18:19:24 EST


On 3/24/23 00:51, Dmitry Osipenko wrote:
> On 3/24/23 00:18, Rob Clark wrote:
> ...
>>> +static int
>>> +virtio_gpu_parse_deps(struct virtio_gpu_submit *submit)
>>> +{
>>> + struct drm_virtgpu_execbuffer *exbuf = submit->exbuf;
>>> + struct drm_virtgpu_execbuffer_syncobj syncobj_desc;
>>> + size_t syncobj_stride = exbuf->syncobj_stride;
>>> + struct drm_syncobj **syncobjs;
>>> + int ret = 0, i;
>>> +
>>> + if (!submit->num_in_syncobjs)
>>> + return 0;
>>> +
>>> + syncobjs = kcalloc(submit->num_in_syncobjs, sizeof(*syncobjs),
>>> + GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY);
>> I *think*, assuming I'm reading where this is called correctly (kinda
>> wish git would show more lines of context by default) that these don't
>> need to be NOWARN|NORETRY (same for post_deps). I guess you inherited
>> this from drm/msm, where I appear to have forgotten to update the
>> syncobj path in commit f0de40a131d9 ("drm/msm: Reorder lock vs submit
>> alloc"). I don't see anything obvious that would require NORETRY, but
>> lockdep should be able to tell you otherwise if needed.
>
> The NORETRY should prevent waking up OOM killer, it shouldn't help with
> lockdep. Nothing prevents userspace from giving a big number of
> num_in_syncobjs. But perhaps indeed not very practical to care about
> this case, given that other similar memalloc paces of execbuffer_ioctl()
> aren't using NORETRY. Alright, let's drop it in v4.
>

Although no, there is only a kvmalloc_array() in the code and vmalloc
uses NOWARN and NORETRY flags implicitly. May be better switch to use
kvmalloc everywhere, for consistency. Technically, vmalloc shouldn't
ever be needed for a submit code path and kmalloc should be enough. On
the other hand, vmalloc acts like kmalloc until there is no enough
contig memory.

--
Best regards,
Dmitry