lkml.org 
[lkml]   [2023]   [Mar]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    SubjectRe: [RFC 2/4] media: videobuf2: Replace bufs array by a list
    From
    Hi David,

    On 3/14/23 11:11, David Laight wrote:
    > From: Hans Verkuil
    >> Sent: 14 March 2023 08:55
    > ...
    >> Why not start with a dynamically allocated array of 32 vb2_buffer pointers?
    >> And keep doubling the size (reallocing) whenever more buffers are needed,
    >> up to some maximum (1024 would be a good initial value for that, I think).
    >> This max could be even a module option.
    >
    > I don't know the typical uses (or the code at all).
    > But it might be worth having a small array in the structure itself.
    > Useful if there are typically always (say) less than 8 buffers.
    > For larger sizes use the (IIRC) kmalloc_size() to find the actual
    > size of the structure that will be allocate and set the array
    > size appropriately.

    The typical usage is that applications allocate N buffers with the
    VIDIOC_REQBUFS ioctl, and in most cases that's all they use. The
    current max is 32 buffers, so allocating that initially (usually
    during probe()) will cover all current cases with a single one-time
    kzalloc.

    Only if the application wants to allocate more than 32 buffers will
    there be a slight overhead.

    Regards,

    Hans

    >
    > David
    >
    > -
    > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
    > Registration No: 1397386 (Wales)

    \
     
     \ /
      Last update: 2023-03-27 00:59    [W:6.693 / U:0.396 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site