qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: Auger Eric <eric.auger@redhat.com>
Cc: qemu-devel@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH] virtio-gpu: handle partial maps properly
Date: Thu, 6 May 2021 14:21:50 +0200	[thread overview]
Message-ID: <20210506122150.42bd6phtpezr5ec2@sirius.home.kraxel.org> (raw)
In-Reply-To: <3dc52bb8-0a38-660b-7b2d-f1d0247c78d8@redhat.com>

  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	other threads:[~2021-05-06 12:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-06  9:10 [PATCH] virtio-gpu: handle partial maps properly Gerd Hoffmann
2021-05-06  9:30 ` no-reply
2021-05-06 11:54 ` Auger Eric
2021-05-06 12:21   ` Gerd Hoffmann [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=20210506122150.42bd6phtpezr5ec2@sirius.home.kraxel.org \
    --to=kraxel@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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;
as well as URLs for NNTP newsgroup(s).