diff mbox

[5/6] kvm tools: Block SIGALRM for vcpu thread using sig_block() helper

Message ID 1308156491-18488-5-git-send-email-asias.hejun@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Asias He June 15, 2011, 4:48 p.m. UTC
Signed-off-by: Asias He <asias.hejun@gmail.com>
---
 tools/kvm/kvm-cpu.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

Comments

Ingo Molnar June 15, 2011, 8:23 p.m. UTC | #1
* Asias He <asias.hejun@gmail.com> wrote:

> Signed-off-by: Asias He <asias.hejun@gmail.com>
> ---
>  tools/kvm/kvm-cpu.c |    7 ++-----
>  1 files changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/kvm/kvm-cpu.c b/tools/kvm/kvm-cpu.c
> index 1fb1c74..782a3b2 100644
> --- a/tools/kvm/kvm-cpu.c
> +++ b/tools/kvm/kvm-cpu.c
> @@ -420,12 +420,8 @@ static void kvm_cpu__handle_coalesced_mmio(struct kvm_cpu *cpu)
>  
>  int kvm_cpu__start(struct kvm_cpu *cpu)
>  {
> -	sigset_t sigset;
>  
> -	sigemptyset(&sigset);
> -	sigaddset(&sigset, SIGALRM);
> -
> -	pthread_sigmask(SIG_BLOCK, &sigset, NULL);
> +	sig_block(SIGALRM);

Is there no way to get a signal delivered to only one thread, instead 
of trying to broadcast all threads?

Playing with the blocked mask has a performance disadvantage: the 
kernel will iterate through all threads of the thread-group to find 
the single one that 'can' receive the SIGALRM. This will be a real 
scalability issue with 64 or more vcpus.

Thanks,

	Ingo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/tools/kvm/kvm-cpu.c b/tools/kvm/kvm-cpu.c
index 1fb1c74..782a3b2 100644
--- a/tools/kvm/kvm-cpu.c
+++ b/tools/kvm/kvm-cpu.c
@@ -420,12 +420,8 @@  static void kvm_cpu__handle_coalesced_mmio(struct kvm_cpu *cpu)
 
 int kvm_cpu__start(struct kvm_cpu *cpu)
 {
-	sigset_t sigset;
 
-	sigemptyset(&sigset);
-	sigaddset(&sigset, SIGALRM);
-
-	pthread_sigmask(SIG_BLOCK, &sigset, NULL);
+	sig_block(SIGALRM);
 
 	signal(SIGKVMEXIT, kvm_cpu_signal_handler);
 	signal(SIGKVMPAUSE, kvm_cpu_signal_handler);
@@ -485,6 +481,7 @@  int kvm_cpu__start(struct kvm_cpu *cpu)
 		default:
 			goto panic_kvm;
 		}
+
 		kvm_cpu__handle_coalesced_mmio(cpu);
 	}