From: Laurent Vivier <Laurent@Vivier.EU>
To: kwolf@redhat.com
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] Improve qemu-nbd performance by 4400 %
Date: Fri, 17 Sep 2010 14:58:04 +0200 [thread overview]
Message-ID: <15052289.110377.1284728283758.JavaMail.servlet@pustefix159> (raw)
>Am 16.09.2010 20:54, schrieb Laurent Vivier:
>> This patch allows to reduce the boot time from an NBD server from 225
>seconds to
>> 5 seconds (time between the "boot cd:0" and the kernel init) for the
>> following command lines:
>>
>> ./qemu-nbd -t ../ISO/debian-500-powerpc-netinst.iso
>> and
>> ./ppc-softmmu/qemu-system-ppc -cdrom nbd:localhost:1024
>>
>> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
>
>I agree with Stefan. It's good to have a description of the results in
>the commit message, but describing what has actually changed from a
>technical perspective would be helpful, too.
OK.
>> ---
>> nbd.c | 20 +++++++++++++++-----
>> 1 files changed, 15 insertions(+), 5 deletions(-)
>>
>> diff --git a/nbd.c b/nbd.c
>> index 011b50f..5d7c758 100644
>> --- a/nbd.c
>> +++ b/nbd.c
>> @@ -655,7 +655,7 @@ int nbd_trip(BlockDriverState *bs, int csock, off_t
>size, uint64_t dev_offset,
>> if (nbd_receive_request(csock, &request) == -1)
>> return -1;
>>
>> - if (request.len > data_size) {
>> + if (request.len + sizeof(struct nbd_reply) > data_size) {
>> LOG("len (%u) is larger than max len (%u)",
>> request.len, data_size);
>> errno = EINVAL;
>> @@ -687,7 +687,8 @@ int nbd_trip(BlockDriverState *bs, int csock, off_t
>size, uint64_t dev_offset,
>> case NBD_CMD_READ:
>> TRACE("Request type is READ");
>>
>> - if (bdrv_read(bs, (request.from + dev_offset) / 512, data,
>> + if (bdrv_read(bs, (request.from + dev_offset) / 512,
>> + data + sizeof(struct nbd_reply),
>> request.len / 512) == -1) {
>> LOG("reading from file failed");
>> errno = EINVAL;
>> @@ -697,12 +698,21 @@ int nbd_trip(BlockDriverState *bs, int csock, off_t
>size, uint64_t dev_offset,
>>
>> TRACE("Read %u byte(s)", request.len);
>>
>> - if (nbd_send_reply(csock, &reply) == -1)
>> - return -1;
>> + /* Reply
>> + [ 0 .. 3] magic (NBD_REPLY_MAGIC)
>> + [ 4 .. 7] error (0 == no error)
>> + [ 7 .. 15] handle
>> + */
>> +
>> + cpu_to_be32w((uint32_t*)data, NBD_REPLY_MAGIC);
>> + cpu_to_be32w((uint32_t*)(data + 4), reply.error);
>> + cpu_to_be64w((uint64_t*)(data + 8), reply.handle);
>
>Hm, if I understand this right, you rely on the compiler padding out
>structs here. You reserved sizeof(struct nbd_reply) bytes and the struct
>is defined like this:
>
>struct nbd_reply {
> uint32_t error;
> uint64_t handle;
>};
>
>So isn't it pure luck that the compiler does the right thing and gives
>you 16 bytes? If you want to use the struct for this, you should add a
>uint32_t magic to it and make it packed.
>
Yes, it's pure luck, I will add a NBD_REPLY_SIZE defined to 16 and will replace the sizeof() by it.
Regards,
Laurent
--
--------------------- Laurent@vivier.eu ---------------------
"Tout ce qui est impossible reste à accomplir" Jules Verne
"Things are only impossible until they're not" Jean-Luc Picard
next reply other threads:[~2010-09-17 12:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-17 12:58 Laurent Vivier [this message]
-- strict thread matches above, loose matches on Subject: below --
2010-09-16 18:54 [Qemu-devel] [PATCH] Improve qemu-nbd performance by 4400 % Laurent Vivier
2010-09-17 8:33 ` Stefan Hajnoczi
2010-09-17 10:24 ` 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=15052289.110377.1284728283758.JavaMail.servlet@pustefix159 \
--to=laurent@vivier.eu \
--cc=kwolf@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).