From: Marcelo Tosatti <mtosatti@redhat.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: Anthony Liguori <aliguori@linux.vnet.ibm.com>,
qemu-devel@nongnu.org, kvm@vger.kernel.org,
Avi Kivity <avi@redhat.com>
Subject: Re: [Qemu-devel] Re: [PATCH 08/10] MCE: Relay UCR MCE to guest
Date: Wed, 20 Oct 2010 19:33:02 -0200 [thread overview]
Message-ID: <20101020213302.GB11588@amt.cnet> (raw)
In-Reply-To: <4CBF5831.7030709@codemonkey.ws>
On Wed, Oct 20, 2010 at 03:59:29PM -0500, Anthony Liguori wrote:
> On 10/20/2010 02:51 PM, Anthony Liguori wrote:
> >
> >>+}
> >>+
> >> static void qemu_kvm_eat_signal(CPUState *env, int timeout)
> >> {
> >> struct timespec ts;
> >> int r, e;
> >> siginfo_t siginfo;
> >> sigset_t waitset;
> >>+ sigset_t chkset;
> >>
> >> ts.tv_sec = timeout / 1000;
> >> ts.tv_nsec = (timeout % 1000) * 1000000;
> >>
> >> sigemptyset(&waitset);
> >> sigaddset(&waitset, SIG_IPI);
> >>+ sigaddset(&waitset, SIGBUS);
> >>
> >>- qemu_mutex_unlock(&qemu_global_mutex);
> >>- r = sigtimedwait(&waitset,&siginfo,&ts);
> >>- e = errno;
> >>- qemu_mutex_lock(&qemu_global_mutex);
> >>+ do {
> >>+ qemu_mutex_unlock(&qemu_global_mutex);
> >>
> >>- if (r == -1&& !(e == EAGAIN || e == EINTR)) {
> >>- fprintf(stderr, "sigtimedwait: %s\n", strerror(e));
> >>- exit(1);
> >>- }
> >>+ r = sigtimedwait(&waitset,&siginfo,&ts);
> >>+ e = errno;
> >>+
> >>+ qemu_mutex_lock(&qemu_global_mutex);
> >>+
> >>+ if (r == -1&& !(e == EAGAIN || e == EINTR)) {
> >>+ fprintf(stderr, "sigtimedwait: %s\n", strerror(e));
> >>+ exit(1);
> >>+ }
> >>+
> >>+ switch (r) {
> >>+ case SIGBUS:
> >>+#ifdef TARGET_I386
> >>+ if (kvm_on_sigbus_vcpu(env, siginfo.si_code,
> >>siginfo.si_addr))
> >>+#endif
> >>+ sigbus_reraise();
> >>+ break;
> >>+ default:
> >>+ break;
> >>+ }
> >>+
> >>+ r = sigpending(&chkset);
> >>+ if (r == -1) {
> >>+ fprintf(stderr, "sigpending: %s\n", strerror(e));
> >>+ exit(1);
> >>+ }
> >>+ } while (sigismember(&chkset, SIG_IPI) ||
> >>sigismember(&chkset, SIGBUS));
> >> }
> >
> >I don't understand why this loop is needed but we specifically
> >wait for a signal to get delivered that's either SIG_IPI or
> >SIGBUS. We then check whether a SIG_IPI or SIGBUS is pending and
> >loop waiting for signals again.
> >
> >Shouldn't we be looping on just sigismember(SIGBUS)?
> >
> >BTW, we're no longer respecting timeout because we're not
> >adjusting ts after each iteration.
>
> I think this is important too. The last time I went through the
> code and played around here, it wasn't possible to set timeout to a
> very, very large value because there are still things that we poll
> for (like whether shutdown has occurred). If we loop indefinitely
> without reducing ts, we can potentially recreate an infinite timeout
> which means we won't catch any of the events we poll for. This
> would be a very, very subtle bug to track down.
We should just kill timeout parameter, i don't see any use for it.
next prev parent reply other threads:[~2010-10-20 21:40 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-20 17:43 [Qemu-devel] [PATCH 00/10] [PULL] qemu-kvm.git uq/master queue Marcelo Tosatti
2010-10-20 17:43 ` [Qemu-devel] [PATCH 01/10] Set cpuid definition to 0 before initializing it Marcelo Tosatti
2010-10-20 17:43 ` [Qemu-devel] [PATCH 02/10] Add svm cpuid features Marcelo Tosatti
2010-10-20 17:43 ` [Qemu-devel] [PATCH 03/10] signalfd compatibility Marcelo Tosatti
2010-10-20 17:43 ` [Qemu-devel] [PATCH 04/10] iothread: use signalfd Marcelo Tosatti
2010-10-20 17:43 ` [Qemu-devel] [PATCH 05/10] kvm: x86: add mce support Marcelo Tosatti
2010-10-20 19:58 ` [Qemu-devel] " Anthony Liguori
2010-10-20 17:43 ` [Qemu-devel] [PATCH 06/10] Export qemu_ram_addr_from_host Marcelo Tosatti
2010-10-20 17:43 ` [Qemu-devel] [PATCH 07/10] Add RAM -> physical addr mapping in MCE simulation Marcelo Tosatti
2010-10-20 19:56 ` [Qemu-devel] " Anthony Liguori
2010-10-20 17:43 ` [Qemu-devel] [PATCH 08/10] MCE: Relay UCR MCE to guest Marcelo Tosatti
2010-10-20 19:51 ` [Qemu-devel] " Anthony Liguori
2010-10-20 20:59 ` Anthony Liguori
2010-10-20 21:33 ` Marcelo Tosatti [this message]
2010-10-20 21:28 ` Marcelo Tosatti
2010-10-20 21:56 ` Paolo Bonzini
2010-10-20 22:03 ` Anthony Liguori
2010-10-21 7:41 ` Paolo Bonzini
2010-10-20 17:43 ` [Qemu-devel] [PATCH 09/10] Add savevm/loadvm support for MCE Marcelo Tosatti
2010-10-20 19:54 ` [Qemu-devel] " Anthony Liguori
2010-10-20 17:43 ` [Qemu-devel] [PATCH 10/10] Fix memory leak in register save load due to xsave support Marcelo Tosatti
2010-10-20 19:01 ` [Qemu-devel] Re: [PATCH 00/10] [PULL] qemu-kvm.git uq/master queue Anthony Liguori
2010-10-20 19:05 ` Marcelo Tosatti
2010-10-20 19:15 ` Anthony Liguori
2010-10-20 19:52 ` Anthony Liguori
2010-10-20 21:59 ` Anthony Liguori
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=20101020213302.GB11588@amt.cnet \
--to=mtosatti@redhat.com \
--cc=aliguori@linux.vnet.ibm.com \
--cc=anthony@codemonkey.ws \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.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).