qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 2/3] aio: use g_slice_alloc() for AIOCB pooling
Date: Mon, 12 Nov 2012 11:37:34 +0100	[thread overview]
Message-ID: <50A0D16E.7070901@redhat.com> (raw)
In-Reply-To: <50A0D09B.5080202@redhat.com>

Il 12/11/2012 11:34, Kevin Wolf ha scritto:
>> Note that the change from g_malloc0() to g_slice_alloc() should be safe
>> since the freelist reuse case doesn't zero the AIOCB either.
> 
> Of course the real reason is that all fields are set anyway.

This doesn't necessarily apply for "subclasses", though.  (It does for
the reason Stefan mentioned, but it is not possible to make it apparent
in the code).

Paolo

> diff --git a/block.c b/block.c
> index 854ebd6..6f5a0e7 100644
> --- a/block.c
> +++ b/block.c
> @@ -3910,10 +3910,13 @@ void *qemu_aio_get(const AIOCBInfo *aiocb_info,
> BlockDriverState *bs,
>      BlockDriverAIOCB *acb;
> 
>      acb = g_slice_alloc(aiocb_info->aiocb_size);
> -    acb->aiocb_info = aiocb_info;
> -    acb->bs = bs;
> -    acb->cb = cb;
> -    acb->opaque = opaque;
> +    *acb = (BlockDriverAIOCB) {
> +        .aiocb_info = aiocb_info,
> +        .bs         = bs,
> +        .cb         = cb,
> +        .opaque     = opaque,
> +    };
> +
>      return acb;
>  }
> 
> If you agree, I'll commit this on top of your series.
> 
> Kevin
> 

  reply	other threads:[~2012-11-12 10:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-31 15:34 [Qemu-devel] [PATCH v2 0/3] aio: use g_slice_alloc() for AIOCB pooling Stefan Hajnoczi
2012-10-31 15:34 ` [Qemu-devel] [PATCH v2 1/3] aio: switch aiocb_size type int -> size_t Stefan Hajnoczi
2012-11-02 14:49   ` Paolo Bonzini
2012-10-31 15:34 ` [Qemu-devel] [PATCH v2 2/3] aio: use g_slice_alloc() for AIOCB pooling Stefan Hajnoczi
2012-11-02 14:49   ` Paolo Bonzini
2012-11-12 10:34   ` Kevin Wolf
2012-11-12 10:37     ` Paolo Bonzini [this message]
2012-11-12 10:42       ` Kevin Wolf
2012-10-31 15:34 ` [Qemu-devel] [PATCH v2 3/3] aio: rename AIOPool to AIOCBInfo Stefan Hajnoczi
2012-11-02 14:50   ` Paolo Bonzini
2012-11-12 10:34 ` [Qemu-devel] [PATCH v2 0/3] aio: use g_slice_alloc() for AIOCB pooling Kevin Wolf

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=50A0D16E.7070901@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).