From patchwork Wed Nov 14 20:43:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Len Brown X-Patchwork-Id: 1744081 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id BA5DDDFF38 for ; Wed, 14 Nov 2012 20:45:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755444Ab2KNUnh (ORCPT ); Wed, 14 Nov 2012 15:43:37 -0500 Received: from mail-qc0-f174.google.com ([209.85.216.174]:46838 "EHLO mail-qc0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753057Ab2KNUnf (ORCPT ); Wed, 14 Nov 2012 15:43:35 -0500 Received: by mail-qc0-f174.google.com with SMTP id o22so558292qcr.19 for ; Wed, 14 Nov 2012 12:43:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:in-reply-to:references:reply-to:organization; bh=tTf2vhCDLTa3A8bdD+NjUsg7VYqaWloiOmBh1+n3czY=; b=CxGwY8nGO0pD/9yOGm8qpAxtYwxEahMepleyxlSvgipwYJjB0GMnQC6eM6JSCxDVrj zpl9DFTpSCo9CKf+9+iibj1OlxDSVFiCen1I+CfPEVtcf+27MBXajbKUB+MZ3xO/edn8 kXpk0dB3LwpzTBLAQ2pkN3aIjXuu9m+EaFdF2D+98i2pNQMmJglebnhDhRWPlMM+2cpT 1xKvs1pVY7ITWLUuHqZX7wLN1QMNSt1LRKmeicBwL5LK6fee9OsjfghizLksZf2Sn6g5 SGYUYKuX/s6HqAk9tdq3jShhTgzz1FveeM8uNSg18lIpideKqlw5wDhPEOTHxDyVMfaD NwJA== Received: by 10.229.244.81 with SMTP id lp17mr1494906qcb.64.1352925814567; Wed, 14 Nov 2012 12:43:34 -0800 (PST) Received: from x980.localdomain6 ([173.48.76.143]) by mx.google.com with ESMTPS id f3sm3314272qaj.7.2012.11.14.12.43.33 (version=SSLv3 cipher=OTHER); Wed, 14 Nov 2012 12:43:34 -0800 (PST) From: Len Brown To: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Len Brown , x86@kernel.org Subject: [PATCH 3/7] tools/power/x86/turbostat: use kernel MSR #defines Date: Wed, 14 Nov 2012 15:43:20 -0500 Message-Id: <38fbc0a1ee900bbdc18fba2d7cfbc4e9b5d51ce8.1352925508.git.len.brown@intel.com> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1352925804-6746-1-git-send-email-lenb@kernel.org> References: <1352925804-6746-1-git-send-email-lenb@kernel.org> In-Reply-To: <39300ffb9b6666714c60735cf854e1280e4e75f4.1352925508.git.len.brown@intel.com> References: <39300ffb9b6666714c60735cf854e1280e4e75f4.1352925508.git.len.brown@intel.com> Reply-To: Len Brown Organization: Intel Open Source Technology Center Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Len Brown Now that turbostat is built in the kernel tree, it can share MSR #defines with the kernel. Signed-off-by: Len Brown Cc: x86@kernel.org --- arch/x86/include/asm/msr-index.h | 12 ++++++++++++ tools/power/x86/turbostat/Makefile | 1 + tools/power/x86/turbostat/turbostat.c | 26 +++++++------------------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index 7f0edce..c9775a3 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -35,6 +35,7 @@ #define MSR_IA32_PERFCTR0 0x000000c1 #define MSR_IA32_PERFCTR1 0x000000c2 #define MSR_FSB_FREQ 0x000000cd +#define MSR_NHM_PLATFORM_INFO 0x000000ce #define MSR_NHM_SNB_PKG_CST_CFG_CTL 0x000000e2 #define NHM_C3_AUTO_DEMOTE (1UL << 25) @@ -55,6 +56,8 @@ #define MSR_OFFCORE_RSP_0 0x000001a6 #define MSR_OFFCORE_RSP_1 0x000001a7 +#define MSR_NHM_TURBO_RATIO_LIMIT 0x000001ad +#define MSR_IVT_TURBO_RATIO_LIMIT 0x000001ae #define MSR_LBR_SELECT 0x000001c8 #define MSR_LBR_TOS 0x000001c9 @@ -103,6 +106,15 @@ #define MSR_IA32_MC0_ADDR 0x00000402 #define MSR_IA32_MC0_MISC 0x00000403 +/* C-state Residency Counters */ +#define MSR_PKG_C3_RESIDENCY 0x000003f8 +#define MSR_PKG_C6_RESIDENCY 0x000003f9 +#define MSR_PKG_C7_RESIDENCY 0x000003fa +#define MSR_CORE_C3_RESIDENCY 0x000003fc +#define MSR_CORE_C6_RESIDENCY 0x000003fd +#define MSR_CORE_C7_RESIDENCY 0x000003fe +#define MSR_PKG_C2_RESIDENCY 0x0000060d + #define MSR_AMD64_MC0_MASK 0xc0010044 #define MSR_IA32_MCx_CTL(x) (MSR_IA32_MC0_CTL + 4*(x)) diff --git a/tools/power/x86/turbostat/Makefile b/tools/power/x86/turbostat/Makefile index f856495..51880e8 100644 --- a/tools/power/x86/turbostat/Makefile +++ b/tools/power/x86/turbostat/Makefile @@ -1,5 +1,6 @@ turbostat : turbostat.c CFLAGS += -Wall +CFLAGS += -I../../../../arch/x86/include/ clean : rm -f turbostat diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index ea095ab..3c063a0 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c @@ -20,6 +20,7 @@ */ #define _GNU_SOURCE +#include #include #include #include @@ -35,19 +36,6 @@ #include #include -#define MSR_NEHALEM_PLATFORM_INFO 0xCE -#define MSR_NEHALEM_TURBO_RATIO_LIMIT 0x1AD -#define MSR_IVT_TURBO_RATIO_LIMIT 0x1AE -#define MSR_APERF 0xE8 -#define MSR_MPERF 0xE7 -#define MSR_PKG_C2_RESIDENCY 0x60D /* SNB only */ -#define MSR_PKG_C3_RESIDENCY 0x3F8 -#define MSR_PKG_C6_RESIDENCY 0x3F9 -#define MSR_PKG_C7_RESIDENCY 0x3FA /* SNB only */ -#define MSR_CORE_C3_RESIDENCY 0x3FC -#define MSR_CORE_C6_RESIDENCY 0x3FD -#define MSR_CORE_C7_RESIDENCY 0x3FE /* SNB only */ - char *proc_stat = "/proc/stat"; unsigned int interval_sec = 5; /* set with -i interval_sec */ unsigned int verbose; /* set with -v */ @@ -674,9 +662,9 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p) t->tsc = rdtsc(); /* we are running on local CPU of interest */ if (has_aperf) { - if (get_msr(cpu, MSR_APERF, &t->aperf)) + if (get_msr(cpu, MSR_IA32_APERF, &t->aperf)) return -3; - if (get_msr(cpu, MSR_MPERF, &t->mperf)) + if (get_msr(cpu, MSR_IA32_MPERF, &t->mperf)) return -4; } @@ -742,10 +730,10 @@ void print_verbose_header(void) if (!do_nehalem_platform_info) return; - get_msr(0, MSR_NEHALEM_PLATFORM_INFO, &msr); + get_msr(0, MSR_NHM_PLATFORM_INFO, &msr); if (verbose > 1) - fprintf(stderr, "MSR_NEHALEM_PLATFORM_INFO: 0x%llx\n", msr); + fprintf(stderr, "MSR_NHM_PLATFORM_INFO: 0x%llx\n", msr); ratio = (msr >> 40) & 0xFF; fprintf(stderr, "%d * %.0f = %.0f MHz max efficiency\n", @@ -808,10 +796,10 @@ print_nhm_turbo_ratio_limits: if (!do_nehalem_turbo_ratio_limit) return; - get_msr(0, MSR_NEHALEM_TURBO_RATIO_LIMIT, &msr); + get_msr(0, MSR_NHM_TURBO_RATIO_LIMIT, &msr); if (verbose > 1) - fprintf(stderr, "MSR_NEHALEM_TURBO_RATIO_LIMIT: 0x%llx\n", msr); + fprintf(stderr, "MSR_NHM_TURBO_RATIO_LIMIT: 0x%llx\n", msr); ratio = (msr >> 56) & 0xFF; if (ratio)