Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 Jul 2010 00:01:39 +1000 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        pluknet <pluknet@gmail.com>
Cc:        freebsd-amd64@FreeBSD.org
Subject:   Re: PERFMON isn't operational on amd64
Message-ID:  <20100727234004.E887@delplex.bde.org>
In-Reply-To: <AANLkTim3m4VX3sy6diTNna2Yb7i%2B4RQZ0kT6U7e_wqTU@mail.gmail.com>
References:  <AANLkTim3m4VX3sy6diTNna2Yb7i%2B4RQZ0kT6U7e_wqTU@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100727234004.E887>