qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Marc Marí" <marc.mari.barcelo@gmail.com>
To: John Snow <jsnow@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] libqos: Convert malloc-pc allocator to a generic allocator
Date: Wed, 22 Oct 2014 23:09:54 +0200	[thread overview]
Message-ID: <20141022230954.6e847daa@crunchbang> (raw)
In-Reply-To: <5447DC61.50005@redhat.com>

> > +void alloc_uninit(QGuestAllocator *allocator)
> > +{
> > +    MemBlock *node;
> > +    MemBlock *tmp;
> > +    QAllocOpts mask;
> > +
> > +    /* Check for guest leaks, and destroy the list. */
> > +    QTAILQ_FOREACH_SAFE(node, &allocator->used, MLIST_ENTNAME,
> > tmp) {
> > +        if (allocator->opts & (ALLOC_LEAK_WARN |
> > ALLOC_LEAK_ASSERT)) {
> > +            fprintf(stderr, "guest malloc leak @ 0x%016" PRIx64 ";
> > "
> > +                    "size 0x%016" PRIx64 ".\n",
> > +                    node->addr, node->size);
> > +        }
> > +        if (allocator->opts & (ALLOC_LEAK_ASSERT)) {
> > +            g_assert_not_reached();
> > +        }
> > +        g_free(node);
> > +    }
> > +
> > +    /* If we have previously asserted that there are no leaks,
> > then there
> > +     * should be only one node here with a specific address and
> > size. */
> > +    mask = ALLOC_LEAK_ASSERT | ALLOC_PARANOID;
> > +    QTAILQ_FOREACH_SAFE(node, &allocator->free, MLIST_ENTNAME,
> > tmp) {
> > +        if ((allocator->opts & mask) == mask) {
> > +            if ((node->addr != allocator->start) ||
> > +                (node->size != allocator->end - allocator->start))
> > {
> > +                fprintf(stderr, "Free list is corrupted.\n");
> > +                g_assert_not_reached();
> > +            }
> > +        }
> > +
> > +        g_free(node);
> > +    }
> > +}
> 
> The original malloc-pc implementation for alloc_uninit() also deletes 
> the QGuestAllocator here, but this version doesn't, which creates a 
> small leak. Did you have a different cleanup pathway in mind?

When moving things, that free got lost, a little typo. I'll resend
tomorrow morning. Thanks.

  reply	other threads:[~2014-10-22 21:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-18  9:24 [Qemu-devel] [PATCH] libqos: Convert malloc-pc allocator to a generic allocator Marc Marí
2014-10-22 16:01 ` Stefan Hajnoczi
2014-10-22 16:33 ` John Snow
2014-10-22 21:09   ` Marc Marí [this message]
2014-10-23 22:49 ` John Snow
2014-10-24  9:00   ` Marc Marí
2014-10-24 15:02     ` John Snow

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=20141022230954.6e847daa@crunchbang \
    --to=marc.mari.barcelo@gmail.com \
    --cc=jsnow@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).