diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2008-12-08 04:58:04 -0500 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2008-12-31 09:55:45 -0500 |
commit | 6ef7a1bc45f80fe0a263119d404688c596ea5031 (patch) | |
tree | 331e8f5ba73b53fa5997eb4dc376249d18897876 /virt/kvm | |
parent | 498468961ed6f62a306eb90c49125776c526fa40 (diff) |
KVM: use modern cpumask primitives, no cpumask_t on stack
We're getting rid on on-stack cpumasks for large NR_CPUS.
1) Use cpumask_var_t/alloc_cpumask_var.
2) smp_call_function_mask -> smp_call_function_many
3) cpus_clear, cpus_empty, cpu_set -> cpumask_clear, cpumask_empty,
cpumask_set_cpu.
This actually generates slightly smaller code than the old one with
CONFIG_CPUMASKS_OFFSTACK=n. (gcc knows that cpus cannot be NULL in
that case, where cpumask_var_t is cpumask_t[1]).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'virt/kvm')
-rw-r--r-- | virt/kvm/kvm_main.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index ba4275d06fb7..2d6ca7968d65 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -555,12 +555,14 @@ static void ack_flush(void *_completed) | |||
555 | static bool make_all_cpus_request(struct kvm *kvm, unsigned int req) | 555 | static bool make_all_cpus_request(struct kvm *kvm, unsigned int req) |
556 | { | 556 | { |
557 | int i, cpu, me; | 557 | int i, cpu, me; |
558 | cpumask_t cpus; | 558 | cpumask_var_t cpus; |
559 | bool called = false; | 559 | bool called = true; |
560 | struct kvm_vcpu *vcpu; | 560 | struct kvm_vcpu *vcpu; |
561 | 561 | ||
562 | if (alloc_cpumask_var(&cpus, GFP_ATOMIC)) | ||
563 | cpumask_clear(cpus); | ||
564 | |||
562 | me = get_cpu(); | 565 | me = get_cpu(); |
563 | cpus_clear(cpus); | ||
564 | for (i = 0; i < KVM_MAX_VCPUS; ++i) { | 566 | for (i = 0; i < KVM_MAX_VCPUS; ++i) { |
565 | vcpu = kvm->vcpus[i]; | 567 | vcpu = kvm->vcpus[i]; |
566 | if (!vcpu) | 568 | if (!vcpu) |
@@ -568,14 +570,17 @@ static bool make_all_cpus_request(struct kvm *kvm, unsigned int req) | |||
568 | if (test_and_set_bit(req, &vcpu->requests)) | 570 | if (test_and_set_bit(req, &vcpu->requests)) |
569 | continue; | 571 | continue; |
570 | cpu = vcpu->cpu; | 572 | cpu = vcpu->cpu; |
571 | if (cpu != -1 && cpu != me) | 573 | if (cpus != NULL && cpu != -1 && cpu != me) |
572 | cpu_set(cpu, cpus); | 574 | cpumask_set_cpu(cpu, cpus); |
573 | } | ||
574 | if (!cpus_empty(cpus)) { | ||
575 | smp_call_function_mask(cpus, ack_flush, NULL, 1); | ||
576 | called = true; | ||
577 | } | 575 | } |
576 | if (unlikely(cpus == NULL)) | ||
577 | smp_call_function_many(cpu_online_mask, ack_flush, NULL, 1); | ||
578 | else if (!cpumask_empty(cpus)) | ||
579 | smp_call_function_many(cpus, ack_flush, NULL, 1); | ||
580 | else | ||
581 | called = false; | ||
578 | put_cpu(); | 582 | put_cpu(); |
583 | free_cpumask_var(cpus); | ||
579 | return called; | 584 | return called; |
580 | } | 585 | } |
581 | 586 | ||