All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gleb Natapov <gleb@redhat.com>
To: Avi Kivity <avi@redhat.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
	joerg.roedel@amd.com, mingo@elte.hu, a.p.zijlstra@chello.nl
Subject: Re: [PATCH 7/9] KVM, VMX: add support for switching of PERF_GLOBAL_CTRL
Date: Tue, 4 Oct 2011 11:57:26 +0200	[thread overview]
Message-ID: <20111004095726.GF30105@redhat.com> (raw)
In-Reply-To: <4E8AD293.8070905@redhat.com>

On Tue, Oct 04, 2011 at 11:32:03AM +0200, Avi Kivity wrote:
> On 10/03/2011 03:49 PM, Gleb Natapov wrote:
> >Some cpus have special support for switching PERF_GLOBAL_CTRL msr.
> >Add logic to detect if such support exists and works properly and extend
> >msr switching code to use it if available. Also extend number of generic
> >msr switching entries to 8.
> >
> >
> >  static DECLARE_BITMAP(vmx_vpid_bitmap, VMX_NR_VPIDS);
> >  static DEFINE_SPINLOCK(vmx_vpid_lock);
> >@@ -1195,10 +1196,29 @@ static void clear_atomic_switch_msr(struct vcpu_vmx *vmx, unsigned msr)
> >  {
> >  	unsigned i;
> >  	struct msr_autoload *m =&vmx->msr_autoload;
> >+	u32 entry_load, exit_load;
> >+	bool done = false;
> >
> >-	if (msr == MSR_EFER&&  cpu_has_load_ia32_efer) {
> >-		vmcs_clear_bits(VM_ENTRY_CONTROLS, VM_ENTRY_LOAD_IA32_EFER);
> >-		vmcs_clear_bits(VM_EXIT_CONTROLS, VM_EXIT_LOAD_IA32_EFER);
> >+	switch (msr) {
> >+	case MSR_EFER:
> >+		if (cpu_has_load_ia32_efer) {
> >+			entry_load = VM_ENTRY_LOAD_IA32_EFER;
> >+			exit_load = VM_EXIT_LOAD_IA32_EFER;
> >+			done = true;
> >+		}
> >+		break;
> >+	case MSR_CORE_PERF_GLOBAL_CTRL:
> >+		if (cpu_has_load_perf_global_ctrl) {
> >+			entry_load = VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL;
> >+			exit_load = VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL;
> >+			done = true;
> >+		}
> >+		break;
> >+	}
> >+
> >+	if (done) {
> >+		vmcs_clear_bits(VM_ENTRY_CONTROLS, entry_load);
> >+		vmcs_clear_bits(VM_EXIT_CONTROLS, exit_load);
> >  		return;
> >  	}
> >
> >
> 
> This is ugly.  How about
> 
>    if (msr == MSR_EFER && cpu_has_load_ia32_efer) {
>        clear_atomic_switch_msr_special(VM_ENTRY_LOAD_IA32_EFER,
> VM_EXIT_LOAD_IA32_EFER);
>        return;
>    }
> 
> avoids the fake 'done' variable.
> 
OK.

--
			Gleb.

  reply	other threads:[~2011-10-04 10:33 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-03 13:49 [PATCH 0/9] perf support for x86 guest/host-only bits Gleb Natapov
2011-10-03 13:49 ` [PATCH 1/9] perf, core: Introduce attrs to count in either host or guest mode Gleb Natapov
2011-10-03 13:49 ` [PATCH 2/9] perf, amd: Use GO/HO bits in perf-ctr Gleb Natapov
2011-10-03 13:49 ` [PATCH 3/9] perf, tools: Add support for guest/host-only profiling Gleb Natapov
2011-10-03 13:49 ` [PATCH 4/9] perf, tools: Fix copy&paste error in perf-kvm option description Gleb Natapov
2011-10-03 13:49 ` [PATCH 5/9] perf, tools: Do guest-only counting in perf-kvm by default Gleb Natapov
2011-10-03 13:49 ` [PATCH 6/9] perf, intel: Use GO/HO bits in perf-ctr Gleb Natapov
2011-10-03 15:06   ` Avi Kivity
2011-10-03 15:41     ` Gleb Natapov
2011-10-04  9:21       ` Avi Kivity
2011-10-03 13:49 ` [PATCH 7/9] KVM, VMX: add support for switching of PERF_GLOBAL_CTRL Gleb Natapov
2011-10-04  9:32   ` Avi Kivity
2011-10-04  9:57     ` Gleb Natapov [this message]
2011-10-03 13:49 ` [PATCH 8/9] KVM, VMX: Add support for guest/host-only profiling Gleb Natapov
2011-10-03 15:00   ` Avi Kivity
2011-10-03 15:36     ` Gleb Natapov
2011-10-04  9:28       ` Avi Kivity
2011-10-04  9:56         ` Gleb Natapov
2011-10-04 11:10           ` Avi Kivity
2011-10-04 11:17             ` Gleb Natapov
2011-10-04 11:24               ` Avi Kivity
2011-10-04 12:12                 ` Gleb Natapov
2011-10-03 13:49 ` [PATCH 9/9] KVM, VMX: Check for automatic switch msr table overflow Gleb Natapov

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=20111004095726.GF30105@redhat.com \
    --to=gleb@redhat.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=avi@redhat.com \
    --cc=joerg.roedel@amd.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.