kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: kvm-devel <kvm@vger.kernel.org>,
	linux-kernel@vger.kernel.org, Mike Travis <travis@sgi.com>,
	Avi Kivity <avi@redhat.com>
Subject: Re: [PATCH 1/2] kvm: use modern cpumask primitives, no cpumask_t on stack
Date: Sun, 07 Dec 2008 17:52:36 +0200	[thread overview]
Message-ID: <493BF144.9080106@redhat.com> (raw)
In-Reply-To: <200812072125.14416.rusty@rustcorp.com.au>

Rusty Russell wrote:
> We're getting rid on on-stack cpumasks for large NR_CPUS.
>
> 1) Use cpumask_var_t and alloc_cpumask_var (a noop normally).  Fallback
>    code is inefficient but never happens in practice.
> 2) smp_call_function_mask -> smp_call_function_many
> 3) cpus_clear, cpus_empty, cpu_set -> cpumask_clear, cpumask_empty,
>    cpumask_set_cpu.
>
> --- linux-2.6.orig/virt/kvm/kvm_main.c
> +++ linux-2.6/virt/kvm/kvm_main.c
> @@ -358,11 +358,23 @@ static void ack_flush(void *_completed)
>  void kvm_flush_remote_tlbs(struct kvm *kvm)
>  {
>  	int i, cpu, me;
> -	cpumask_t cpus;
> +	cpumask_var_t cpus;
>  	struct kvm_vcpu *vcpu;
>  
>  	me = get_cpu();
> -	cpus_clear(cpus);
> +	if (!alloc_cpumask_var(&cpus, GFP_ATOMIC)) {
> +		/* Slow path on failure.  Call everyone. */
> +		for (i = 0; i < KVM_MAX_VCPUS; ++i) {
> +			vcpu = kvm->vcpus[i];
> +			if (vcpu)
> +				set_bit(KVM_REQ_TLB_FLUSH, &vcpu->requests);
> +		}
> +		++kvm->stat.remote_tlb_flush;
> +		smp_call_function_many(cpu_online_mask, ack_flush, NULL, 1);
> +		put_cpu();
> +		return;
> +	}
> +
>   

Wow, code duplication from Rusty. Things must be bad.

Since we're in a get_cpu() here, how about a per_cpu static cpumask 
instead? I don't mind the inefficient fallback, just the duplication.

-- 
error compiling committee.c: too many arguments to function


       reply	other threads:[~2008-12-07 15:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200812072125.14416.rusty@rustcorp.com.au>
2008-12-07 15:52 ` Avi Kivity [this message]
2008-12-07 16:14   ` [PATCH 1/2] kvm: use modern cpumask primitives, no cpumask_t on stack Avi Kivity
2008-12-08  6:08     ` Rusty Russell
2008-12-08  9:49       ` Avi Kivity
2008-12-08 11:55         ` Rusty Russell
2008-12-08  9:56   ` [PATCH] kvm: Extract core of kvm_flush_remote_tlbs/kvm_reload_remote_mmus Rusty Russell
2008-12-08  9:58     ` kvm: use modern cpumask primitives, no cpumask_t on stack Rusty Russell
2008-12-08 12:00     ` [PATCH] kvm: Extract core of kvm_flush_remote_tlbs/kvm_reload_remote_mmus Avi Kivity
2008-12-08 14:32   ` [PATCH 1/2] kvm: use modern cpumask primitives, no cpumask_t on stack Mike Travis
2008-12-08 14:55     ` Avi Kivity

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=493BF144.9080106@redhat.com \
    --to=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    --cc=travis@sgi.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).