public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joerg Roedel <joerg.roedel@amd.com>
To: Avi Kivity <avi@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>,
	Alexander Graf <agraf@suse.de>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/5] KVM: SVM: Optimize nested svm msrpm merging
Date: Fri, 26 Feb 2010 13:25:02 +0100	[thread overview]
Message-ID: <20100226122502.GC12689@amd.com> (raw)
In-Reply-To: <4B87A248.1050300@redhat.com>

On Fri, Feb 26, 2010 at 12:28:24PM +0200, Avi Kivity wrote:
> >+static void add_msr_offset(u32 offset)
> >+{
> >+	u32 old;
> >+	int i;
> >+
> >+again:
> >+	for (i = 0; i<  MSRPM_OFFSETS; ++i) {
> >+		old = msrpm_offsets[i];
> >+
> >+		if (old == offset)
> >+			return;
> >+
> >+		if (old != MSR_INVALID)
> >+			continue;
> >+
> >+		if (cmpxchg(&msrpm_offsets[i], old, offset) != old)
> >+			goto again;
> >+
> >+		return;
> >+	}
> >+
> >+	/*
> >+	 * If this BUG triggers the msrpm_offsets table has an overflow. Just
> >+	 * increase MSRPM_OFFSETS in this case.
> >+	 */
> >+	BUG();
> >+}
> 
> Why all this atomic cleverness?  The possible offsets are all
> determined statically.  Even if you do them dynamically (makes sense
> when considering pmu passthrough), it's per-vcpu and therefore
> single threaded (just move msrpm_offsets into vcpu context).

The msr_offset table is the same for all guests. It doesn't make sense
to keep it per vcpu because it will currently look the same for all
vcpus. For standard guests this array contains 3 entrys. It is marked
with __read_mostly for the same reason.

> >@@ -1846,20 +1882,33 @@ static int nested_svm_vmexit(struct vcpu_svm *svm)
> >
> >  static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm)
> >  {
> >-	u32 *nested_msrpm;
> >-	struct page *page;
> >+	/*
> >+	 * This function merges the msr permission bitmaps of kvm and the
> >+	 * nested vmcb. It is omptimized in that it only merges the parts where
> >+	 * the kvm msr permission bitmap may contain zero bits
> >+	 */
> 
> A comment that describes the entire function can be moved above the
> function, freeing a whole tab stop for contents.

Ok, will move it out of the function.

	Joerg



  reply	other threads:[~2010-02-26 12:40 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-25 17:15 [PATCH 0/5] Rework of msrpm optimization and additional fixes for nested svm Joerg Roedel
2010-02-25 17:15 ` [PATCH 1/5] KVM: SVM: Move msrpm offset calculation to seperate function Joerg Roedel
2010-02-26 10:20   ` Avi Kivity
2010-02-26 10:25     ` Joerg Roedel
2010-02-25 17:15 ` [PATCH 2/5] KVM: SVM: Optimize nested svm msrpm merging Joerg Roedel
2010-02-26 10:28   ` Avi Kivity
2010-02-26 12:25     ` Joerg Roedel [this message]
2010-02-26 12:28       ` Alexander Graf
2010-02-26 13:04         ` Joerg Roedel
2010-02-26 13:08           ` Alexander Graf
2010-02-26 13:19             ` Joerg Roedel
2010-02-26 13:10           ` Avi Kivity
2010-02-26 13:21             ` Joerg Roedel
2010-02-26 13:26               ` Alexander Graf
2010-02-26 13:30                 ` Joerg Roedel
2010-02-26 13:59                   ` Avi Kivity
2010-02-26 12:42       ` Avi Kivity
2010-02-25 17:15 ` [PATCH 3/5] KVM: SVM: Use svm_msrpm_offset in nested_svm_exit_handled_msr Joerg Roedel
2010-02-26 10:30   ` Avi Kivity
2010-03-01 13:33     ` Joerg Roedel
2010-02-25 17:15 ` [PATCH 4/5] KVM: SVM: Add correct handling of nested iopm Joerg Roedel
2010-02-26 10:33   ` Avi Kivity
2010-02-25 17:15 ` [PATCH 5/5] KVM: SVM: Ignore lower 12 bit of nested msrpm_pa Joerg Roedel

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=20100226122502.GC12689@amd.com \
    --to=joerg.roedel@amd.com \
    --cc=agraf@suse.de \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtosatti@redhat.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