public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] pmu emulation fixes
@ 2012-02-26 14:55 Gleb Natapov
  2012-02-26 14:55 ` [PATCH 1/3] KVM: x86 emulator: warn when pin control is set in eventsel msr Gleb Natapov
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Gleb Natapov @ 2012-02-26 14:55 UTC (permalink / raw)
  To: kvm; +Cc: avi, mtosatti

Gleb Natapov (3):
  KVM: x86 emulator: warn when pin control is set in eventsel msr
  KVM: x86 emulator: Fix raw event check
  KVM: x86 emulator: add proper support for fixed counter 2

 arch/x86/include/asm/perf_event.h |    1 +
 arch/x86/kvm/pmu.c                |    8 ++++++--
 2 files changed, 7 insertions(+), 2 deletions(-)

-- 
1.7.7.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] KVM: x86 emulator: warn when pin control is set in eventsel msr
  2012-02-26 14:55 [PATCH 0/3] pmu emulation fixes Gleb Natapov
@ 2012-02-26 14:55 ` Gleb Natapov
  2012-02-26 14:55 ` [PATCH 2/3] KVM: x86 emulator: Fix raw event check Gleb Natapov
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Gleb Natapov @ 2012-02-26 14:55 UTC (permalink / raw)
  To: kvm; +Cc: avi, mtosatti

Print warning once if pin control bit is set in eventsel msr since
emulation does not support it yet.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
 arch/x86/include/asm/perf_event.h |    1 +
 arch/x86/kvm/pmu.c                |    3 +++
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/arch/x86/include/asm/perf_event.h b/arch/x86/include/asm/perf_event.h
index 096c975..f1f7182 100644
--- a/arch/x86/include/asm/perf_event.h
+++ b/arch/x86/include/asm/perf_event.h
@@ -23,6 +23,7 @@
 #define ARCH_PERFMON_EVENTSEL_USR			(1ULL << 16)
 #define ARCH_PERFMON_EVENTSEL_OS			(1ULL << 17)
 #define ARCH_PERFMON_EVENTSEL_EDGE			(1ULL << 18)
+#define ARCH_PERFMON_EVENTSEL_PIN_CONTROL		(1ULL << 19)
 #define ARCH_PERFMON_EVENTSEL_INT			(1ULL << 20)
 #define ARCH_PERFMON_EVENTSEL_ANY			(1ULL << 21)
 #define ARCH_PERFMON_EVENTSEL_ENABLE			(1ULL << 22)
diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c
index 3e48c1d..6af9a54 100644
--- a/arch/x86/kvm/pmu.c
+++ b/arch/x86/kvm/pmu.c
@@ -210,6 +210,9 @@ static void reprogram_gp_counter(struct kvm_pmc *pmc, u64 eventsel)
 	unsigned config, type = PERF_TYPE_RAW;
 	u8 event_select, unit_mask;
 
+	if (eventsel & ARCH_PERFMON_EVENTSEL_PIN_CONTROL)
+		printk_once("kvm pmu: pin control bit is ignored\n");
+
 	pmc->eventsel = eventsel;
 
 	stop_counter(pmc);
-- 
1.7.7.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] KVM: x86 emulator: Fix raw event check
  2012-02-26 14:55 [PATCH 0/3] pmu emulation fixes Gleb Natapov
  2012-02-26 14:55 ` [PATCH 1/3] KVM: x86 emulator: warn when pin control is set in eventsel msr Gleb Natapov
@ 2012-02-26 14:55 ` Gleb Natapov
  2012-02-26 14:55 ` [PATCH 3/3] KVM: x86 emulator: add proper support for fixed counter 2 Gleb Natapov
  2012-03-05 14:18 ` [PATCH 0/3] pmu emulation fixes Avi Kivity
  3 siblings, 0 replies; 6+ messages in thread
From: Gleb Natapov @ 2012-02-26 14:55 UTC (permalink / raw)
  To: kvm; +Cc: avi, mtosatti

If eventsel has EDGE, INV or CMASK set we should create raw counter for
it, but the check is done on a wrong variable. Fix it.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
 arch/x86/kvm/pmu.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c
index 6af9a54..b52a8ed 100644
--- a/arch/x86/kvm/pmu.c
+++ b/arch/x86/kvm/pmu.c
@@ -223,7 +223,7 @@ static void reprogram_gp_counter(struct kvm_pmc *pmc, u64 eventsel)
 	event_select = eventsel & ARCH_PERFMON_EVENTSEL_EVENT;
 	unit_mask = (eventsel & ARCH_PERFMON_EVENTSEL_UMASK) >> 8;
 
-	if (!(event_select & (ARCH_PERFMON_EVENTSEL_EDGE |
+	if (!(eventsel & (ARCH_PERFMON_EVENTSEL_EDGE |
 				ARCH_PERFMON_EVENTSEL_INV |
 				ARCH_PERFMON_EVENTSEL_CMASK))) {
 		config = find_arch_event(&pmc->vcpu->arch.pmu, event_select,
-- 
1.7.7.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] KVM: x86 emulator: add proper support for fixed counter 2
  2012-02-26 14:55 [PATCH 0/3] pmu emulation fixes Gleb Natapov
  2012-02-26 14:55 ` [PATCH 1/3] KVM: x86 emulator: warn when pin control is set in eventsel msr Gleb Natapov
  2012-02-26 14:55 ` [PATCH 2/3] KVM: x86 emulator: Fix raw event check Gleb Natapov
@ 2012-02-26 14:55 ` Gleb Natapov
  2012-03-05 14:18 ` [PATCH 0/3] pmu emulation fixes Avi Kivity
  3 siblings, 0 replies; 6+ messages in thread
From: Gleb Natapov @ 2012-02-26 14:55 UTC (permalink / raw)
  To: kvm; +Cc: avi, mtosatti

Currently pmu emulation emulates fixed counter 2 as bus cycles
architectural counter, but since commit 9c1497ea591b25d perf has
pseudo encoding for it. Use it.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
 arch/x86/kvm/pmu.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c
index b52a8ed..a73f0c1 100644
--- a/arch/x86/kvm/pmu.c
+++ b/arch/x86/kvm/pmu.c
@@ -33,10 +33,11 @@ static struct kvm_arch_event_perf_mapping {
 	[4] = { 0x2e, 0x41, PERF_COUNT_HW_CACHE_MISSES },
 	[5] = { 0xc4, 0x00, PERF_COUNT_HW_BRANCH_INSTRUCTIONS },
 	[6] = { 0xc5, 0x00, PERF_COUNT_HW_BRANCH_MISSES },
+	[7] = { 0x00, 0x30, PERF_COUNT_HW_REF_CPU_CYCLES },
 };
 
 /* mapping between fixed pmc index and arch_events array */
-int fixed_pmc_events[] = {1, 0, 2};
+int fixed_pmc_events[] = {1, 0, 7};
 
 static bool pmc_is_gp(struct kvm_pmc *pmc)
 {
-- 
1.7.7.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/3] pmu emulation fixes
  2012-02-26 14:55 [PATCH 0/3] pmu emulation fixes Gleb Natapov
                   ` (2 preceding siblings ...)
  2012-02-26 14:55 ` [PATCH 3/3] KVM: x86 emulator: add proper support for fixed counter 2 Gleb Natapov
@ 2012-03-05 14:18 ` Avi Kivity
  2012-03-05 15:08   ` Gleb Natapov
  3 siblings, 1 reply; 6+ messages in thread
From: Avi Kivity @ 2012-03-05 14:18 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: kvm, mtosatti

On 02/26/2012 04:55 PM, Gleb Natapov wrote:
> Gleb Natapov (3):
>   KVM: x86 emulator: warn when pin control is set in eventsel msr
>   KVM: x86 emulator: Fix raw event check
>   KVM: x86 emulator: add proper support for fixed counter 2
>

Thanks, applied (s/emulator/pmu/...)

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/3] pmu emulation fixes
  2012-03-05 14:18 ` [PATCH 0/3] pmu emulation fixes Avi Kivity
@ 2012-03-05 15:08   ` Gleb Natapov
  0 siblings, 0 replies; 6+ messages in thread
From: Gleb Natapov @ 2012-03-05 15:08 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm, mtosatti

On Mon, Mar 05, 2012 at 04:18:21PM +0200, Avi Kivity wrote:
> On 02/26/2012 04:55 PM, Gleb Natapov wrote:
> > Gleb Natapov (3):
> >   KVM: x86 emulator: warn when pin control is set in eventsel msr
> >   KVM: x86 emulator: Fix raw event check
> >   KVM: x86 emulator: add proper support for fixed counter 2
> >
> 
> Thanks, applied (s/emulator/pmu/...)
> 
You, maintainers, are hard to please! My previous fix to PMU 
ee3f9f114bdc8b315eed7b1c651ca6c9b8251cf7 was prefixed "KVM: x86
emulator:" so I followed suit :)

--
			Gleb.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-03-05 15:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-26 14:55 [PATCH 0/3] pmu emulation fixes Gleb Natapov
2012-02-26 14:55 ` [PATCH 1/3] KVM: x86 emulator: warn when pin control is set in eventsel msr Gleb Natapov
2012-02-26 14:55 ` [PATCH 2/3] KVM: x86 emulator: Fix raw event check Gleb Natapov
2012-02-26 14:55 ` [PATCH 3/3] KVM: x86 emulator: add proper support for fixed counter 2 Gleb Natapov
2012-03-05 14:18 ` [PATCH 0/3] pmu emulation fixes Avi Kivity
2012-03-05 15:08   ` Gleb Natapov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox