qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Andrea Arcangeli <aarcange@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Tom Knych <thomaswk@google.com>,
	qemu-devel@nongnu.org, gleb@redhat.com,
	David Turner <digit@google.com>
Subject: Re: [Qemu-devel] [PATCH 1/1] KVM: Retry KVM_CREATE_VM on EINTR or EAGAIN
Date: Tue, 14 Jan 2014 19:56:57 +0100	[thread overview]
Message-ID: <20140114185657.GN1141@redhat.com> (raw)
In-Reply-To: <52D3CAFB.8030003@redhat.com>

On Mon, Jan 13, 2014 at 12:16:11PM +0100, Paolo Bonzini wrote:
> Il 10/01/2014 23:15, Tom Knych ha scritto:
> > I'll flip the conditional check
> > 
> > So I traced thru the code and the one path I saw returning EINTR was:
> > 
> > kvm_dev_ioctl_create_vm -> kvm_create_vm -> kvm_init_mmu_notifier ->
> > mmu_notifier_register ->  do_mmu_notifier_register -> mm_take_all_locks
> > 
> > Which checks if any signals have been raised while it was attaining
> > locks and returns EINTR.
> > 
> > Going thru my logs - all of my errors actually are EINTRs I'll remove
> > the EAGAIN
> 
> Andrea, what do you think here?  Is it intended that
> kvm_init_mmu_notifier return an EINTR that percolates up to userspace?

It is intended yes. The reason being that mm_take_all_locks is
potentially a CPU intensive operation so if we don't return -EINTR and
break it immediately if a signal is pending, we'd be potentially
hanging the process for too long, if you press C^c or the task wouldn't
go away immediately, or if you kill -9 same problem.

All CPU intensive syscalls in the kernel should check for pending
signals and return -EINTR immediately to allow userland to remain
interactive.

EAGAIN shouldn't originate anywhere in those paths so yes they're all
EINTR for interactivity.

Why don't you mask the signals instead of looping? That would be more
efficient, what's the point of interrupting the syscall and restarting
it when you can just avoid being interrupted during it? If the signal
is blocked signal_pending won't be raised and EINTR won't be
generated. I think you only need a sigprocmask or equivalent around
the call.

It's important to check the retval and fail the startup of qemu if you
still get a error, but you shouldn't loop if you just mask the signal
instead of looping.

  reply	other threads:[~2014-01-14 18:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-09 21:14 [Qemu-devel] [PATCH 0/1] KVM: Retry KVM_CREATE_VM on EINTR or EAGAIN thomas knych
2014-01-09 21:14 ` [Qemu-devel] [PATCH 1/1] " thomas knych
2014-01-10 13:01   ` Paolo Bonzini
2014-01-10 22:15     ` Tom Knych
2014-01-13 11:16       ` Paolo Bonzini
2014-01-14 18:56         ` Andrea Arcangeli [this message]
2014-01-15  2:09           ` Tom Knych
2014-01-15  7:47             ` 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=20140114185657.GN1141@redhat.com \
    --to=aarcange@redhat.com \
    --cc=digit@google.com \
    --cc=gleb@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=thomaswk@google.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).