WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] Fix xenoprof counter overflow check

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] Fix xenoprof counter overflow check
From: Niraj Tolia <ntolia@xxxxxxxxx>
Date: Mon, 05 Jan 2009 20:49:11 -0800
Cc: ntolia@xxxxxxxxx
Delivery-date: Mon, 05 Jan 2009 20:49:50 -0800
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:content-type:mime-version :content-transfer-encoding:subject:x-mercurial-node:message-id:date :from:to:cc; bh=2GqJR5nr7+PgkWr8jqaLweYLudccxr6Q1cllE9P02DU=; b=TnZZNh8mX+ts0z24V9xANzWeYHtanbogslu08aBLlbRxnwlar3a7BMtsOYJVGhx5QW fMz0Udu1QHCHdQq1jcOAIC5zH2AZq+dok0Ib7hB0oKduReY7jg9scrRjyN4UHwmLZnlr SBGFRMp8ILqXbxuHU+O+Rygf9TDtozT6ZsBKM=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=content-type:mime-version:content-transfer-encoding:subject :x-mercurial-node:message-id:date:from:to:cc; b=I7XhIndbkF3OKkz7y485aPk+/4wGba+WmDH2vaWF4QHaPwh03/O7vQoBvdgTuPZVdd MgBnqg8eiGKg/IuYoKQsuVPi20ULp+3MxVQ5Jp/pOYmADE90l1MQ1v6wZ14vahyrRjqQ iKB6//gspXGHzqhsyWo0Om6NZYXoMUU26FqCc=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Niraj Tolia <ntolia@xxxxxxxxx>
# Date 1231217146 28800
# Node ID eb1ad7bbdaf3ae553a6bf319180b5880f5ac4307
# Parent  8417ddc981b407753f966c568ef8c7b673d8d22a
Xenoprof patch to fix the counter overflow check for CPUs with counter
width > 32

I had to port this patch from mainline Linux where it can be found at
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=7c64ade53a6f977d73f16243865c42ceae999aea

Signed-off-by: Niraj Tolia <ntolia@xxxxxxxxx>

diff -r 8417ddc981b4 -r eb1ad7bbdaf3 xen/arch/x86/oprofile/op_model_ppro.c
--- a/xen/arch/x86/oprofile/op_model_ppro.c     Mon Jan 05 11:10:54 2009 +0000
+++ b/xen/arch/x86/oprofile/op_model_ppro.c     Mon Jan 05 20:45:46 2009 -0800
@@ -25,9 +25,8 @@
 #define NUM_COUNTERS 2
 #define NUM_CONTROLS 2
 
-#define CTR_READ(l,h,msrs,c) do {rdmsr(msrs->counters[(c)].addr, (l), (h));} 
while (0)
 #define CTR_WRITE(l,msrs,c) do {wrmsr(msrs->counters[(c)].addr, -(u32)(l), 
-1);} while (0)
-#define CTR_OVERFLOWED(n) (!((n) & (1U<<31)))
+#define CTR_OVERFLOWED(n) (!((n) & (1ULL<<31)))
 
 #define CTRL_READ(l,h,msrs,c) do {rdmsr((msrs->controls[(c)].addr), (l), 
(h));} while (0)
 #define CTRL_WRITE(l,h,msrs,c) do {wrmsr((msrs->controls[(c)].addr), (l), 
(h));} while (0)
@@ -98,7 +97,7 @@ static int ppro_check_ctrs(unsigned int 
                            struct op_msrs const * const msrs,
                            struct cpu_user_regs * const regs)
 {
-       unsigned int low, high;
+       u64 val;
        int i;
        int ovf = 0;
        unsigned long eip = regs->eip;
@@ -107,8 +106,8 @@ static int ppro_check_ctrs(unsigned int 
        for (i = 0 ; i < NUM_COUNTERS; ++i) {
                if (!reset_value[i])
                        continue;
-               CTR_READ(low, high, msrs, i);
-               if (CTR_OVERFLOWED(low)) {
+               rdmsrl(msrs->counters[i].addr, val);
+               if (CTR_OVERFLOWED(val)) {
                        xenoprof_log_event(current, regs, eip, mode, i);
                        CTR_WRITE(reset_value[i], msrs, i);
                        ovf = 1;

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel