qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Nir Soffer <nirsof@gmail.com>
To: Eric Blake <eblake@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>, Nir Soffer <nsoffer@redhat.com>,
	QEMU Developers <qemu-devel@nongnu.org>,
	qemu-block <qemu-block@nongnu.org>, Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 1/2] block: posix: Always allocate the first block
Date: Mon, 26 Aug 2019 18:19:35 +0300	[thread overview]
Message-ID: <CAMr-obvapP0fcjrQafvdi+vDuyEDMnwG9cBC1HYmW1gwH=JrUw@mail.gmail.com> (raw)
In-Reply-To: <65085dba-f180-8a4e-8464-65e91323b69b@redhat.com>

On Mon, Aug 26, 2019 at 4:46 PM Eric Blake <eblake@redhat.com> wrote:
>
> On 8/25/19 5:03 PM, Nir Soffer wrote:
> > When creating an image with preallocation "off" or "falloc", the first
> > block of the image is typically not allocated. When using Gluster
> > storage backed by XFS filesystem, reading this block using direct I/O
> > succeeds regardless of request length, fooling alignment detection.
> >
> > In this case we fallback to a safe value (4096) instead of the optimal
> > value (512), which may lead to unneeded data copying when aligning
> > requests.  Allocating the first block avoids the fallback.
> >
>
> > Here is a table comparing the total time spent:
> >
> > Type    Before(s)   After(s)    Diff(%)
> > ---------------------------------------
> > real      530.028    469.123      -11.4
> > user       17.204     10.768      -37.4
> > sys        17.881      7.011      -60.7
> >
> > We can see very clear improvement in CPU usage.
>
> Nice justification.
>
>
> > +/*
> > + * Help alignment probing by allocating the first block.
> > + *
>
> > +    do {
> > +        n = pwrite(fd, buf, write_size, 0);
> > +    } while (n == -1 && errno == EINTR);
> > +
> > +    qemu_vfree(buf);
>
> qemu_vfree() can corrupt errno...
>
> > +
> > +    return (n == -1) ? -errno : 0;
>
> ...which means you may be returning an unexpected value here.
>
> Either we should patch qemu_vfree() to guarantee that errno is
> preserved, or you locally capture errno before calling it here.

qemu_vfree() returns void like free(), so changing errno is unexpected, but
other code using it should not be effected, so preserving errno here seems
like a better change.

Thanks!

Nir


  reply	other threads:[~2019-08-26 15:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-25 22:03 [Qemu-devel] [PATCH v2 0/2] Optimize alignment probing Nir Soffer
2019-08-25 22:03 ` [Qemu-devel] [PATCH v2 1/2] block: posix: Always allocate the first block Nir Soffer
2019-08-26 12:31   ` Max Reitz
2019-08-26 13:49     ` Eric Blake
2019-08-26 15:23       ` Nir Soffer
2019-08-26 15:41     ` Nir Soffer
2019-08-26 16:20       ` Max Reitz
2019-08-26 13:46   ` Eric Blake
2019-08-26 15:19     ` Nir Soffer [this message]
2019-08-25 22:03 ` [Qemu-devel] [PATCH v2 2/2] iotests: Test allocate_first_block() with O_DIRECT Nir Soffer
2019-08-25 22:41   ` Nir Soffer
2019-08-26 12:38   ` Max Reitz
2019-08-25 22:19 ` [Qemu-devel] [PATCH v2 0/2] Optimize alignment probing no-reply

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='CAMr-obvapP0fcjrQafvdi+vDuyEDMnwG9cBC1HYmW1gwH=JrUw@mail.gmail.com' \
    --to=nirsof@gmail.com \
    --cc=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=nsoffer@redhat.com \
    --cc=qemu-block@nongnu.org \
    --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).