From: Avi Kivity <avi@redhat.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: Juan Quintela <quintela@redhat.com>,
Christoph Hellwig <hch@infradead.org>,
kvm@vger.kernel.org
Subject: Re: [PATCH 05/24] compatfd is included before, and it is compiled unconditionally
Date: Thu, 01 Oct 2009 19:00:58 +0200 [thread overview]
Message-ID: <4AC4E04A.4010304@redhat.com> (raw)
In-Reply-To: <4AC4DDE1.1070803@codemonkey.ws>
On 10/01/2009 06:50 PM, Anthony Liguori wrote:
> Avi Kivity wrote:
>> On 10/01/2009 04:23 PM, Anthony Liguori wrote:
>>> Juan Quintela wrote:
>>>> Discused with Anthony about it. signalfd is complicated for qemu
>>>> upstream (too difficult to use properly),
>>>
>>> It's not an issue of being difficult.
>>>
>>> To emulate signalfd, we need to create a thread that writes to a
>>> pipe from a signal handler. The problem is that a write() can
>>> return a partial result and following the partial result, we can end
>>> up getting an EAGAIN. We have no way to queue signals beyond that
>>> point and we have no sane way to deal with partial writes.
>>
>> pipe buffers are multiples of of the signalfd size. As long as we
>> read and write signalfd-sized blocks, we won't get partial writes.
>> It's true that depending on an implementation detail is bad practice,
>> but this is emulation code, and if helps simplifying everything else,
>> I think it's fine to use it.
>
> That's a pretty hairy detail to rely upon..
Well, it's a posix detail, as I quoted below. I'm not in love with it
but it should work.
>
>>> Instead, how we do this in upstream QEMU is that we install a signal
>>> handler and write one byte to the fd. If we get EAGAIN, that's fine
>>> because all we care about is that at least one byte exists in the
>>> fd's buffer. This requires that we use an fd-per-signal which means
>>> we end up with a different model than signalfd.
>>>
>>> The reason to use signalfd over what we do in upstream QEMU is that
>>> signalfd can allow us to mask the signals which means less EINTRs.
>>> I don't think that's a huge advantage and the inability to do
>>> backwards compatibility in a sane way means that emulated signalfd
>>> is not workable.
>>
>> signalfd is several microseconds faster than signals + pipes. Do we
>> have so much performance we can throw some of it away?
>
> Do we have any indication that this difference is actually
> observable? This seems like very premature optimization.
Multiply the signal rate by "a few microseconds", if you get more than
0.1% cpu it's worthwhile in my opinion. The code is localized, and
signalfd is a better interface than signals.
>
>>> The same is generally true for eventfd.
>>
>> eventfd emulation will also never get partial writes.
>
> But you cannot emulate eventfd faithfully because eventfd is supposed
> to be additive. If you write 1 50x to eventfd, you should be able to
> read a set of integers that add up to 50. If you hit EAGAIN in a
> signal handler, you have no way of handling that.
We never rely on the count anyway. You can simply ignore EAGAIN.
> As I said earlier, the better thing to do is have a higher level
> interface that has a subset of the behavior of eventfd/signalfd that
> we can emulate correctly.
Sure, but it's more work. Copying an existing interface is easier.
It's not like there's no other work in qemu left to be done.
--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
next prev parent reply other threads:[~2009-10-01 17:01 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-18 11:41 [PATCH 00/24] configure and Makefile cleanup Juan Quintela
2009-09-18 11:41 ` [PATCH 01/24] Don't disable werror unconditionally Juan Quintela
2009-09-18 19:02 ` Marcelo Tosatti
2009-09-19 10:13 ` Avi Kivity
2009-09-19 11:14 ` Jan Kiszka
2009-09-19 11:41 ` Juan Quintela
2009-09-18 11:41 ` [PATCH 02/24] extboot.bin is a generated file Juan Quintela
2009-09-18 11:41 ` [PATCH 03/24] Remove merge artifacts Juan Quintela
2009-09-18 11:41 ` [PATCH 04/24] piix4_dev is not used for pc's Juan Quintela
2009-09-18 19:05 ` Marcelo Tosatti
2009-09-18 21:42 ` Juan Quintela
2009-09-21 9:10 ` Avi Kivity
2009-09-21 9:37 ` Juan Quintela
2009-09-21 9:45 ` Avi Kivity
2009-09-18 11:41 ` [PATCH 05/24] compatfd is included before, and it is compiled unconditionally Juan Quintela
2009-09-22 13:19 ` Christoph Hellwig
2009-09-22 13:25 ` Juan Quintela
2009-09-22 13:34 ` Christoph Hellwig
2009-10-01 11:58 ` Juan Quintela
2009-10-01 12:05 ` Christoph Hellwig
2009-10-01 14:24 ` Anthony Liguori
2009-10-01 14:23 ` Anthony Liguori
2009-10-01 14:44 ` Avi Kivity
2009-10-01 16:50 ` Anthony Liguori
2009-10-01 17:00 ` Avi Kivity [this message]
2009-10-05 20:48 ` KVM Support for windows Saksena, Abhishek
2009-10-06 10:51 ` Avi Kivity
2009-09-18 11:41 ` [PATCH 06/24] Use common style for signalfd Juan Quintela
2009-09-18 11:41 ` [PATCH 07/24] One CONFIG_EVENTFD should be enough Juan Quintela
2009-09-18 11:41 ` [PATCH 08/24] Bring ia64 to current arch selection code Juan Quintela
2009-09-18 11:41 ` [PATCH 09/24] Use configure way of enabling kvm Juan Quintela
2009-09-18 11:41 ` [PATCH 10/24] Prin kvm options values as everything else Juan Quintela
2009-09-18 11:41 ` [PATCH 11/24] KVM temp hack not needed anymore Juan Quintela
2009-09-18 11:41 ` [PATCH 12/24] Introduce libs_softmmu to device assignment code Juan Quintela
2009-09-18 11:41 ` [PATCH 13/24] Use compile_prog function in thee missing compilations Juan Quintela
2009-09-18 11:41 ` [PATCH 14/24] Test for libpci, not only for header Juan Quintela
2009-09-18 11:41 ` [PATCH 15/24] Rename USE_KVM_* to CONFIG_KVM_* Juan Quintela
2009-09-18 11:41 ` [PATCH 16/24] Move kvm specific tests after main kvm test Juan Quintela
2009-09-18 11:41 ` [PATCH 17/24] Add kvm-cap-pit command line flags Juan Quintela
2009-09-18 11:41 ` [PATCH 18/24] Add kvm-cap-device-assignment " Juan Quintela
2009-09-18 11:41 ` [PATCH 19/24] Fix compilation without device assignment Juan Quintela
2009-09-18 11:41 ` [PATCH 20/24] Only print kvm options when kvm is enabled Juan Quintela
2009-09-18 19:42 ` Marcelo Tosatti
2009-09-18 21:43 ` Juan Quintela
2009-09-18 11:41 ` [PATCH 21/24] __user is not used anywhere in qemu sources Juan Quintela
2009-09-18 11:41 ` [PATCH 22/24] fix mis-merge (we define pkgversion 3 lines above Juan Quintela
2009-09-18 11:41 ` [PATCH 23/24] Get CONFIG_CPU_EMULATION back to life Juan Quintela
2009-09-18 19:54 ` Marcelo Tosatti
2009-09-18 21:44 ` Juan Quintela
2009-09-21 9:13 ` Avi Kivity
2009-09-21 9:36 ` Juan Quintela
2009-09-18 11:41 ` [PATCH 24/24] Remove build-targets-* rules that are always empty Juan Quintela
2009-09-18 19:57 ` [PATCH 00/24] configure and Makefile cleanup Marcelo Tosatti
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=4AC4E04A.4010304@redhat.com \
--to=avi@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=hch@infradead.org \
--cc=kvm@vger.kernel.org \
--cc=quintela@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).