From: Avi Kivity <avi@redhat.com>
To: Saul Tamari <stamari@gmail.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH] qemu-kvm: clear only essential parts of VirtIOBlockReq on object allocation
Date: Sun, 08 Nov 2009 15:07:29 +0200 [thread overview]
Message-ID: <4AF6C291.90204@redhat.com> (raw)
In-Reply-To: <41be791c0911040941y3548de23v20959cf1c1300875@mail.gmail.com>
On 11/04/2009 07:41 PM, Saul Tamari wrote:
> This patch reduces the size of memory being cleared on every virtio-blk IO.
>
> On every virtio-blk IO passed to QEMU, virtio_blk_alloc_request()
> allocates and clears (with qemu_mallocz()) a VirtIOBlockReq object.
> The sizeof(VirtIOBlockReq) equals 41040 bytes on my x86-64 machine.
> By moving the 'elem' variable to the end of VirtIOBlockReq and
> clearing only upto the address of the 'elem.in_addr' field, the
> memset() call now clears only 80 bytes.
>
>
> Signed-off-by: Saul Tamari<st...@gmail.com>
>
Use the full email in signoffs.
> @@ -79,12 +79,12 @@ static inline void virtio_identify_template(struct
> virtio_blk_config *bc)
> typedef struct VirtIOBlockReq
> {
> VirtIOBlock *dev;
> - VirtQueueElement elem;
> struct virtio_blk_inhdr *in;
> struct virtio_blk_outhdr *out;
> struct virtio_scsi_inhdr *scsi;
> QEMUIOVector qiov;
> struct VirtIOBlockReq *next;
> + VirtQueueElement elem;
> } VirtIOBlockReq;
>
Needs a comment to indicate new members must be before 'elem' if they
need to be cleared.
> static void virtio_blk_req_complete(VirtIOBlockReq *req, int status)
> @@ -139,7 +139,8 @@ static void virtio_blk_flush_complete(void *opaque, int ret)
>
> static VirtIOBlockReq *virtio_blk_alloc_request(VirtIOBlock *s)
> {
> - VirtIOBlockReq *req = qemu_mallocz(sizeof(*req));
> + VirtIOBlockReq *req = qemu_malloc(sizeof(*req));
> + memset(req, 0, (size_t)&(((VirtIOBlockReq*)0)->elem.in_addr[0]));
>
Please use offsetof() instead of open-coding it.
Submit to qemu-devel@nongnu.org since this came from upstream.
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2009-11-08 13:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-04 17:41 [PATCH] qemu-kvm: clear only essential parts of VirtIOBlockReq on object allocation Saul Tamari
2009-11-08 13:07 ` Avi Kivity [this message]
2009-11-09 16:35 ` Saul Tamari
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=4AF6C291.90204@redhat.com \
--to=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=stamari@gmail.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 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.