# HG changeset patch
# User Niraj Tolia <ntolia@gmail.com>
# 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@gmail.com>
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@lists.xensource.com
http://lists.xensource.com/xen-devel
Keir Fraser
2009-Jan-06 14:10 UTC
Re: [Xen-devel] [PATCH] Fix xenoprof counter overflow check
On 06/01/2009 04:49, "Niraj Tolia" <ntolia@gmail.com> wrote:> # HG changeset patch > # User Niraj Tolia <ntolia@gmail.com> > # 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@gmail.com>This patch can''t possibly build, and is pointless anyway since the overflow width check is still hardcoded to 32 bits in CTR_OVERFLOWED(). -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Niraj Tolia
2009-Jan-06 18:37 UTC
Re: [Xen-devel] [PATCH] Fix xenoprof counter overflow check
On Tue, Jan 6, 2009 at 6:10 AM, Keir Fraser <keir.fraser@eu.citrix.com>wrote:> On 06/01/2009 04:49, "Niraj Tolia" <ntolia@gmail.com> wrote: > > > # HG changeset patch > > # User Niraj Tolia <ntolia@gmail.com> > > # 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@gmail.com> > > This patch can''t possibly build, and is pointless anyway since the overflowWhile the mainline patch won''t build, the one attached definitely does. That said, I see your point about the overflow. Now I need to figure out why this broken patch actually enables xenoprof to work on my Intel Xeon. The only reason would be the switch from CTR_READ() (which uses rdmsr() internally) to rdmsrl() but let me dig into it. Cheers, Niraj> > width check is still hardcoded to 32 bits in CTR_OVERFLOWED(). > > -- Keir >-- Niraj Tolia, Researcher, HP Labs http://www.hpl.hp.com/personal/Niraj_Tolia/ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser
2009-Jan-06 22:15 UTC
Re: [Xen-devel] [PATCH] Fix xenoprof counter overflow check
On 06/01/2009 18:37, "Niraj Tolia" <ntolia@gmail.com> wrote:> While the mainline patch won''t build, the one attached definitely does. That > said, I see your point about the overflow. Now I need to figure out why this > broken patch actually enables xenoprof to work on my Intel Xeon. The only > reason would be the switch from CTR_READ() (which uses rdmsr() internally) to > rdmsrl() but let me dig into it.The patch absolutely did not build. There were still references to local variables (''low'' and ''high'') that you removed the definitions of. -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Niraj Tolia
2009-Jan-06 22:24 UTC
Re: [Xen-devel] [PATCH] Fix xenoprof counter overflow check
On Tue, Jan 6, 2009 at 2:15 PM, Keir Fraser <keir.fraser@eu.citrix.com>wrote:> On 06/01/2009 18:37, "Niraj Tolia" <ntolia@gmail.com> wrote: > > > While the mainline patch won''t build, the one attached definitely does. > That > > said, I see your point about the overflow. Now I need to figure out why > this > > broken patch actually enables xenoprof to work on my Intel Xeon. The only > > reason would be the switch from CTR_READ() (which uses rdmsr() > internally) to > > rdmsrl() but let me dig into it. > > The patch absolutely did not build. There were still references to local > variables (''low'' and ''high'') that you removed the definitions of. >Ah. My patch was generated against xen-3.3-testing.hg. I just noticed that the same function has a number of changes in xen-unstable and would cause a build failure. Sorry about that. Niraj> > -- Keir > > >-- Niraj Tolia, Researcher, HP Labs http://www.hpl.hp.com/personal/Niraj_Tolia/ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel