public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* KVM's signal masking
@ 2008-02-14 19:19 Hollis Blanchard
  2008-02-15 13:42 ` [kvm-ppc-devel] " Avi Kivity
  0 siblings, 1 reply; 2+ messages in thread
From: Hollis Blanchard @ 2008-02-14 19:19 UTC (permalink / raw)
  To: kvm-devel; +Cc: kvm-ppc-devel

We're having a hard time tracking down a PowerPC bug that seems to be
related to KVM's signal handling (SIGALRM in particular), so we're
trying to understand the overall signal handling design.

It looks like the run sequence goes something like this:
     1. qemu: block SIGALRM (and a couple others)
     2. qemu: call kvm_run
     3. kvm: unblocks SIGALRM
     4. kvm: executes guest
     5. kvm: exit handler checks signal_pending(); if true returns to
        qemu
     6. kvm: re-blocks SIGALRM and returns to qemu
     7. qemu: kvm_eat_signals() synchronously calls the normal handlers
        for blocked signals

I'm confused about a few things. First, why must qemu unblock these
signals? AFAICS signal_pending() still returns true regardless of the
process's signal mask.

Second, why are we synchronously calling the signal handlers in the
first place? Why not allow the signals simply to be delivered?

-- 
Hollis Blanchard
IBM Linux Technology Center


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [kvm-ppc-devel] KVM's signal masking
  2008-02-14 19:19 KVM's signal masking Hollis Blanchard
@ 2008-02-15 13:42 ` Avi Kivity
  0 siblings, 0 replies; 2+ messages in thread
From: Avi Kivity @ 2008-02-15 13:42 UTC (permalink / raw)
  To: Hollis Blanchard; +Cc: kvm-devel, kvm-ppc-devel

Hollis Blanchard wrote:
> We're having a hard time tracking down a PowerPC bug that seems to be
> related to KVM's signal handling (SIGALRM in particular), so we're
> trying to understand the overall signal handling design.
>
> It looks like the run sequence goes something like this:
>      1. qemu: block SIGALRM (and a couple others)
>      2. qemu: call kvm_run
>      3. kvm: unblocks SIGALRM
>      4. kvm: executes guest
>      5. kvm: exit handler checks signal_pending(); if true returns to
>         qemu
>      6. kvm: re-blocks SIGALRM and returns to qemu
>      7. qemu: kvm_eat_signals() synchronously calls the normal handlers
>         for blocked signals
>
>   

Yes.

> I'm confused about a few things. First, why must qemu unblock these
> signals? AFAICS signal_pending() still returns true regardless of the
> process's signal mask.
>   

You mean kvm unblocks.  If the signals are blocked, the kernel will not 
wake up a sleeping process (or IPI a running one), resulting in 
unbounded latency.

> Second, why are we synchronously calling the signal handlers in the
> first place? Why not allow the signals simply to be delivered?
>   

Async signal delivery is slow and racy (can happen between any two 
instructions, without locking).

Ideally, we wouldn't dispatch the signals at all; dequeing a signal 
means "go check if something happened via select() or aio completion".  
I hadn't checked that all signal handlers are safe to omit, hence the call.

-- 
Do not meddle in the internals of kernels, for they are subtle and quick to panic.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-02-15 13:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-14 19:19 KVM's signal masking Hollis Blanchard
2008-02-15 13:42 ` [kvm-ppc-devel] " Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox