From peter@rulingia.com  Thu May 31 03:53:48 2012
Return-Path: <peter@rulingia.com>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id CA44E106566C
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 31 May 2012 03:53:48 +0000 (UTC)
	(envelope-from peter@rulingia.com)
Received: from vps.rulingia.com (host-122-100-2-194.octopus.com.au [122.100.2.194])
	by mx1.freebsd.org (Postfix) with ESMTP id 485E48FC1D
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 31 May 2012 03:53:47 +0000 (UTC)
Received: from aspire.rulingia.com (12.58.233.220.static.exetel.com.au [220.233.58.12])
	by vps.rulingia.com (8.14.5/8.14.5) with ESMTP id q4V3rbIC066086
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK);
	Thu, 31 May 2012 13:53:41 +1000 (EST)
	(envelope-from peter@rulingia.com)
Received: from aspire.rulingia.com (localhost [127.0.0.1])
	by aspire.rulingia.com (8.14.5/8.14.5) with ESMTP id q4V3nFhw064771
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Thu, 31 May 2012 13:49:30 +1000 (EST)
	(envelope-from peter@aspire.rulingia.com)
Received: (from peter@localhost)
	by aspire.rulingia.com (8.14.5/8.14.5/Submit) id q4V3nE3q064770;
	Thu, 31 May 2012 13:49:14 +1000 (EST)
	(envelope-from peter)
Message-Id: <201205310349.q4V3nE3q064770@aspire.rulingia.com>
Date: Thu, 31 May 2012 13:49:14 +1000 (EST)
From: Peter Jeremy <peter@rulingia.com>
Reply-To: Peter Jeremy <peter@rulingia.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: hwpmc(4) sampling stops working on P4
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         168485
>Category:       kern
>Synopsis:       hwpmc(4) sampling stops working on P4
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    hiren
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu May 31 04:00:15 UTC 2012
>Closed-Date:    Thu May 09 16:01:59 UTC 2013
>Last-Modified:  Thu May 09 16:01:59 UTC 2013
>Originator:     Peter Jeremy
>Release:        FreeBSD 8.3 and later amd64
>Organization:
n/a
>Environment:
System: FreeBSD pjdesk.au.alcatel-lucent.com 8.3-STABLE FreeBSD 8.3-STABLE #13 r235137M: Wed May  9 14:15:42 EST 2012     root@pjdesk.au.alcatel-lucent.com:/var/obj/usr/src/sys/pjdesk  amd64
System: FreeBSD C2B0004103.au.alcatel-lucent.com 10.0-CURRENT FreeBSD 10.0-CURRENT #28 r236183M: Thu May 31 11:06:33 EST 2012     root@C2B0004103.au.alcatel-lucent.com:/usr/obj/usr/src/sys/pjdesk  amd64

CPU: Intel(R) Pentium(R) 4 CPU 3.20GHz (3192.15-MHz K8-class CPU)
  Origin = "GenuineIntel"  Id = 0xf43  Family = f  Model = 4  Stepping = 3
  Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>
  Features2=0x649d<SSE3,DTES64,MON,DS_CPL,EST,CNXT-ID,CX16,xTPR>
  AMD Features=0x20100800<SYSCALL,NX,LM>

>Description:
	When running (eg)
	# pmcstat -r 1231 -O logfile -S unhalted-cycles
	logfile will collect some callchain entries and then stop.
	At about the same time, the system reports "NMI ISA 30, EISA ff".
	This happens for both OS versions above (identical hardware).

	Looking at the output from "pmccontrol -s" and the code in
	sys/dev/hwpmc/hwpmc_piv.c, it appears that under some
	conditions, p4_intr() will be invoked (due to an NMI) without
	any PMC interrupts being present.  In this case, the PMC 'pcint'
	entry is not unmasked so no further PMC events are reported.

>How-To-Repeat:
	Run "pmcstat -r 1231 -O logfile -S unhalted-cycles" on a P4

>Fix:
	I removed 'if (did_interrupt)' from the -current code (so
	that lapic_reenable_pmc() is always invoked).  This led so
	some (spurious) NMI reports on the console but hwpmc works.

	This is a work-around, rather than a fix but possibly someone
	with better knowledge of the P4 PMC can provide the correct fix.

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->hiren 
Responsible-Changed-By: hiren 
Responsible-Changed-When: Wed May 8 20:03:04 UTC 2013 
Responsible-Changed-Why:  
Grab. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=168485 

From: hiren panchasara <hiren@FreeBSD.org>
To: bug-followup@FreeBSD.org, peter@rulingia.com
Cc:  
Subject: Re: kern/168485: hwpmc(4) sampling stops working on P4
Date: Wed, 8 May 2013 13:18:04 -0700

 Peter,
 I tested this on following machine with CURRENT (Sat Mar 30 2013) and
 I could not see the problem you are reporting.
 
 CPU: Intel(R) Pentium(R) 4 CPU 2.66GHz (2660.23-MHz 686-class CPU)
     Origin = "GenuineIntel" Id = 0xf29  Family = 0xf  Model = 0x2  Stepping = 9
     Features=0xbfebfbff<FPU ,VME ,DE ,PSE ,TSC ,MSR ,PAE ,MCE ,CX8
 ,APIC ,SEP ,MTRR,
 PGE ,MCA ,CMOV ,PAT ,PSE36 ,CLFLUSH ,DTS ,ACPI ,MMX ,FXSR ,SSE ,SSE2
 ,SS ,HTT ,TM ,PBE>
     Features2=0x4400<CNTX-ID ,xTPR>
 
 Can you still see the problem on your machine? I see that you have
 different model of P4 than what I have.
 
 Many variables here but trying to see if we can make any progress.
 
 cheers,
 Hiren
State-Changed-From-To: open->closed 
State-Changed-By: hiren 
State-Changed-When: Thu May 9 16:00:03 UTC 2013 
State-Changed-Why:  
Received a private message from submitter that he does not have any P4s anymore. 
My testing (on a bit different P4) did not show the problem. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=168485 
>Unformatted:
