From: Paolo Bonzini <pbonzini@redhat.com>
To: Fam Zheng <famz@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 2/2] virtio-scsi: Optimize virtio_scsi_init_req
Date: Mon, 15 Sep 2014 12:17:20 +0200 [thread overview]
Message-ID: <5416BCB0.30502@redhat.com> (raw)
In-Reply-To: <1410758605-29375-3-git-send-email-famz@redhat.com>
Il 15/09/2014 07:23, Fam Zheng ha scritto:
> SCSIRequest *sreq;
> size_t resp_size;
> enum SCSIXferMode mode;
> - QEMUIOVector resp_iov;
> union {
> VirtIOSCSICmdResp cmd;
> VirtIOSCSICtrlTMFResp tmf;
> @@ -68,23 +75,27 @@ static inline SCSIDevice *virtio_scsi_device_find(VirtIOSCSI *s, uint8_t *lun)
> static VirtIOSCSIReq *virtio_scsi_init_req(VirtIOSCSI *s, VirtQueue *vq)
> {
> VirtIOSCSIReq *req;
> - VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
> -
> - req = g_malloc0(sizeof(*req) + vs->cdb_size);
> + VirtIOSCSICommon *vs = (VirtIOSCSICommon *)s;
> + const size_t zero_skip = offsetof(VirtIOSCSIReq, elem)
> + + sizeof(VirtQueueElement);
>
> + req = g_slice_alloc(sizeof(*req) + vs->cdb_size);
Looks good, but why do you need to zero the union? You only need to
zero sreq, resp_size and mode, don't you (and at this point, memset
becomes superfluous)?
Paolo
next prev parent reply other threads:[~2014-09-15 10:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-15 5:23 [Qemu-devel] [PATCH v2 0/2] virtio-scsi: Optimizing request allocation Fam Zheng
2014-09-15 5:23 ` [Qemu-devel] [PATCH v2 1/2] scsi: Optimize scsi_req_alloc Fam Zheng
2014-09-15 10:15 ` Paolo Bonzini
2014-09-15 5:23 ` [Qemu-devel] [PATCH v2 2/2] virtio-scsi: Optimize virtio_scsi_init_req Fam Zheng
2014-09-15 10:17 ` Paolo Bonzini [this message]
2014-09-16 7:16 ` Fam Zheng
2014-09-16 8:15 ` Paolo Bonzini
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=5416BCB0.30502@redhat.com \
--to=pbonzini@redhat.com \
--cc=famz@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.