qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] virtio-gpu: handle partial maps properly


From: Gerd Hoffmann
Subject: Re: [PATCH] virtio-gpu: handle partial maps properly
Date: Thu, 6 May 2021 14:21:50 +0200

  Hi,

> > +            if (!(v % 16)) {
> > +                *iov = g_realloc(*iov, sizeof(struct iovec) * (v + 16));
> > +                if (addr) {
> > +                    *addr = g_realloc(*addr, sizeof(uint64_t) * (v + 16));
> nit: just wondering why you chose to do the alloc by slice of 16 instead
> of doing the usual allocation at the beginning and re-allocating the iov
> when l != len.

It's unknown in advance how many iov entries I'll need.  So I'll go
allocate them on demand.  To avoid one (or two) realloc calls on each
single loop run allocate in chunks.

Chunk size is 16 entries, it would also work with smaller or larger
chunks.  It's a tradeoff between realloc overhead (smaller chunks) and
wasted memory (larger chunks).

take care,
  Gerd




reply via email to

[Prev in Thread] Current Thread [Next in Thread]