From patchwork Fri Aug 4 04:24:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Huang X-Patchwork-Id: 9880423 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 65D26603F4 for ; Fri, 4 Aug 2017 04:25:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5642A2898A for ; Fri, 4 Aug 2017 04:25:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B43228995; Fri, 4 Aug 2017 04:25:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D575F28997 for ; Fri, 4 Aug 2017 04:25:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751269AbdHDEYe (ORCPT ); Fri, 4 Aug 2017 00:24:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60924 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751257AbdHDEYd (ORCPT ); Fri, 4 Aug 2017 00:24:33 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DC8EB883AE for ; Fri, 4 Aug 2017 04:24:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DC8EB883AE Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=wei@redhat.com Received: from weilaptop.redhat.com (ovpn-120-159.rdu2.redhat.com [10.10.120.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 446E381E3B; Fri, 4 Aug 2017 04:24:32 +0000 (UTC) From: Wei Huang To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, rkrcmar@redhat.com, wei@redhat.com Subject: [kvm-unit-tests RFC 1/3] x86/pmu: Move common x86 PMU definitions to pmu.h Date: Thu, 3 Aug 2017 23:24:28 -0500 Message-Id: <1501820670-23194-2-git-send-email-wei@redhat.com> In-Reply-To: <1501820670-23194-1-git-send-email-wei@redhat.com> References: <1501820670-23194-1-git-send-email-wei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 04 Aug 2017 04:24:33 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch moves common x86 PMU counter and event defintions to pmu.h file. This header file will be used by both Intel and AMD PMU test code. Signed-off-by: Wei Huang Reviewed-by: Andrew Jones --- x86/pmu.c | 38 ++------------------------------------ x86/pmu.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 36 deletions(-) create mode 100644 x86/pmu.h diff --git a/x86/pmu.c b/x86/pmu.c index a0238dc..1b818c2 100644 --- a/x86/pmu.c +++ b/x86/pmu.c @@ -8,38 +8,9 @@ #include "x86/vm.h" #include "libcflat.h" +#include "pmu.h" #include -#define FIXED_CNT_INDEX 32 -#define PC_VECTOR 32 - -#define EVNSEL_EVENT_SHIFT 0 -#define EVNTSEL_UMASK_SHIFT 8 -#define EVNTSEL_USR_SHIFT 16 -#define EVNTSEL_OS_SHIFT 17 -#define EVNTSEL_EDGE_SHIFT 18 -#define EVNTSEL_PC_SHIFT 19 -#define EVNTSEL_INT_SHIFT 20 -#define EVNTSEL_EN_SHIF 22 -#define EVNTSEL_INV_SHIF 23 -#define EVNTSEL_CMASK_SHIFT 24 - -#define EVNTSEL_EN (1 << EVNTSEL_EN_SHIF) -#define EVNTSEL_USR (1 << EVNTSEL_USR_SHIFT) -#define EVNTSEL_OS (1 << EVNTSEL_OS_SHIFT) -#define EVNTSEL_PC (1 << EVNTSEL_PC_SHIFT) -#define EVNTSEL_INT (1 << EVNTSEL_INT_SHIFT) -#define EVNTSEL_INV (1 << EVNTSEL_INV_SHIF) - -#define N 1000000 - -typedef struct { - uint32_t ctr; - uint32_t config; - uint64_t count; - int idx; -} pmu_counter_t; - union cpuid10_eax { struct { unsigned int version_id:8; @@ -72,12 +43,7 @@ union cpuid10_edx { unsigned int full; } edx; -struct pmu_event { - const char *name; - uint32_t unit_sel; - int min; - int max; -} gp_events[] = { +struct pmu_event gp_events[] = { {"core cycles", 0x003c, 1*N, 50*N}, {"instructions", 0x00c0, 10*N, 10.2*N}, {"ref cycles", 0x013c, 0.1*N, 30*N}, diff --git a/x86/pmu.h b/x86/pmu.h new file mode 100644 index 0000000..b1e8e51 --- /dev/null +++ b/x86/pmu.h @@ -0,0 +1,42 @@ +/* vPMU unit testing for x86 */ +#ifndef __PMU_H +#define __PMU_H + +#define N 1000000 + +#define FIXED_CNT_INDEX 32 +#define PC_VECTOR 32 + +#define EVNTSEL_EVENT_SHIFT 0 +#define EVNTSEL_UMASK_SHIFT 8 +#define EVNTSEL_USR_SHIFT 16 +#define EVNTSEL_OS_SHIFT 17 +#define EVNTSEL_EDGE_SHIFT 18 +#define EVNTSEL_PC_SHIFT 19 +#define EVNTSEL_INT_SHIFT 20 +#define EVNTSEL_EN_SHIF 22 +#define EVNTSEL_INV_SHIF 23 +#define EVNTSEL_CMASK_SHIFT 24 + +#define EVNTSEL_EN (1 << EVNTSEL_EN_SHIF) +#define EVNTSEL_USR (1 << EVNTSEL_USR_SHIFT) +#define EVNTSEL_OS (1 << EVNTSEL_OS_SHIFT) +#define EVNTSEL_PC (1 << EVNTSEL_PC_SHIFT) +#define EVNTSEL_INT (1 << EVNTSEL_INT_SHIFT) +#define EVNTSEL_INV (1 << EVNTSEL_INV_SHIF) + +typedef struct { + uint32_t ctr; + uint32_t config; + uint64_t count; + int idx; +} pmu_counter_t; + +struct pmu_event { + const char *name; + uint32_t unit_sel; + int min; + int max; +}; + +#endif /* __PMU_H */