From owner-freebsd-amd64@FreeBSD.ORG Tue Jul 27 15:14:33 2010 Return-Path: Delivered-To: freebsd-amd64@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CBAD21065694 for ; Tue, 27 Jul 2010 15:14:33 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from fallbackmx08.syd.optusnet.com.au (fallbackmx08.syd.optusnet.com.au [211.29.132.10]) by mx1.freebsd.org (Postfix) with ESMTP id 62B6C8FC31 for ; Tue, 27 Jul 2010 15:14:33 +0000 (UTC) Received: from mail06.syd.optusnet.com.au (mail06.syd.optusnet.com.au [211.29.132.187]) by fallbackmx08.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id o6RE1hEG028760 for ; Wed, 28 Jul 2010 00:01:43 +1000 Received: from c122-106-147-41.carlnfd1.nsw.optusnet.com.au (c122-106-147-41.carlnfd1.nsw.optusnet.com.au [122.106.147.41]) by mail06.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id o6RE1djJ016851 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 28 Jul 2010 00:01:41 +1000 Date: Wed, 28 Jul 2010 00:01:39 +1000 (EST) From: Bruce Evans X-X-Sender: bde@delplex.bde.org To: pluknet In-Reply-To: Message-ID: <20100727234004.E887@delplex.bde.org> References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-amd64@FreeBSD.org Subject: Re: PERFMON isn't operational on amd64 X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Jul 2010 15:14:33 -0000 On Tue, 27 Jul 2010, pluknet wrote: > What is a status of "options PERFMON" on amd64? It is just a bug in the options file. > AFAIK PERFMON opt. was inherited from i386 port and never worked. > Does it make sense to wipe out perfmon part on amd64? The inheritance is 1 line in the options file. Wiping this would be easy, but it would be better to fix it. This should be easy. > buildkernel with PERFMON on results in error: > /usr/src/sys/amd64/amd64/machdep.c:124:29: error: machine/perfmon.h: > No such file or directory > mkdep: compile failed > *** Error code 1 > > Looking at cvs I see amd64/include/perfmon.h was never here. Neither was amd64/amd64/perfmon.c. perfmon hasn't been updated since Y2K, so even on i386 it is missing support for most CPUs less than 10 years old, in particular all (?) Athlons (AthlonXP and Athlon64 at least) :-(. However, this is easy to fix. I use the following hack since I didn't want to edit the include files and conditionalize the constants properly: % diff -c2 perfmon.c~ perfmon.c % *** perfmon.c~ Sun Jun 20 13:41:16 2004 % --- perfmon.c Sun Dec 9 07:01:58 2007 % *************** % *** 99,106 **** % case CPUCLASS_686: % perfmon_cpuok = 1; % ! msr_ctl[0] = MSR_EVNTSEL0; % ! msr_ctl[1] = MSR_EVNTSEL1; % ! msr_pmc[0] = MSR_PERFCTR0; % ! msr_pmc[1] = MSR_PERFCTR1; % writectl = writectl6; % break; % --- 99,106 ---- % case CPUCLASS_686: % perfmon_cpuok = 1; % ! msr_ctl[0] = 0xc0010000; % ! msr_ctl[1] = 0xc0010001; % ! msr_pmc[0] = 0xc0010004; % ! msr_pmc[1] = 0xc0010005; % writectl = writectl6; % break; This works for AthlonXP and Athlon64 in i386 mode, and should work for Athlon64 in amd64 mode. The MSR constants in the above are not generic like their name suggests. They are mainly for P6. specialreg.h has a another set of similar but better-named constants for P5, but no perfmon constants for any other CPUs. Athlons are classified as 686's, but this is almost useless and just wrong in the above. Bruce