Date: Tue, 27 Jul 2010 15:40:30 -0400 From: John Baldwin <jhb@freebsd.org> To: Bruce Evans <brde@optusnet.com.au> Cc: jkoshy@freebsd.org, freebsd-amd64@freebsd.org Subject: Re: PERFMON isn't operational on amd64 Message-ID: <201007271540.30774.jhb@freebsd.org> In-Reply-To: <20100728044151.Y1330@delplex.bde.org> References: <AANLkTim3m4VX3sy6diTNna2Yb7i%2B4RQZ0kT6U7e_wqTU@mail.gmail.com> <201007270928.24959.jhb@freebsd.org> <20100728044151.Y1330@delplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tuesday, July 27, 2010 3:06:50 pm Bruce Evans wrote: > On Tue, 27 Jul 2010, John Baldwin wrote: > > > On Tuesday, July 27, 2010 8:43:00 am pluknet wrote: > >> Hi. > >> > >> What is a status of "options PERFMON" on amd64? > >> ... > >> Looking at cvs I see amd64/include/perfmon.h was never here. > > > > PERFMON in general is obsoleted by hwpmc(4) which is far more useful and > > featureful. It should probably just be axed. > > Nothing should just be axed. > > hwpmc(4) is far too featureful for me, yet perfmon(4) still does things > for me that hwpmc cannot do: > - from userland, without using the library, try undocumented unnamed > counters. There are a few useful ones for k7. E.g.: > 0xc8 (k8-fr-retired-near-returns) and > 0xc9 (k8-fr-retired-near-returns-mispredicted) > are k8-only according to hwpmc and amd docs, but also work on my k7 > (after a 4-line fix for perfmon on kx). I believe this is not too terribly hard to fix. For the two above I think this will suffice (manpage would also need to be updated for a full patch): (I think the misordering in pmc_events.h is required to preserve userland ABI.) Index: hwpmc_amd.c =================================================================== --- hwpmc_amd.c (revision 210547) +++ hwpmc_amd.c (working copy) @@ -137,6 +137,8 @@ { PMC_EV_K7_RETIRED_TAKEN_BRANCHES_MISPREDICTED, 0xC5, 0 }, { PMC_EV_K7_RETIRED_FAR_CONTROL_TRANSFERS, 0xC6, 0 }, { PMC_EV_K7_RETIRED_RESYNC_BRANCHES, 0xC7, 0 }, + { PMC_EV_K7_RETIRED_NEAR_RETURNS, 0xC8, 0 }, + { PMC_EV_K7_RETIRED_NEAR_RETURNS_MISPREDICTED, 0xC9, 0 }, { PMC_EV_K7_INTERRUPTS_MASKED_CYCLES, 0xCD, 0 }, { PMC_EV_K7_INTERRUPTS_MASKED_WHILE_PENDING_CYCLES, 0xCE, 0 }, { PMC_EV_K7_HARDWARE_INTERRUPTS, 0xCF, 0 }, Index: pmc_events.h =================================================================== --- pmc_events.h (revision 210547) +++ pmc_events.h (working copy) @@ -74,10 +74,12 @@ __PMC_EV(K7, RETIRED_RESYNC_BRANCHES) \ __PMC_EV(K7, INTERRUPTS_MASKED_CYCLES) \ __PMC_EV(K7, INTERRUPTS_MASKED_WHILE_PENDING_CYCLES) \ -__PMC_EV(K7, HARDWARE_INTERRUPTS) +__PMC_EV(K7, HARDWARE_INTERRUPTS) \ +__PMC_EV(K7, RETIRED_NEAR_RETURNS) \ +__PMC_EV(K7, RETIRED_NEAR_RETURNS_MISPREDICTED) #define PMC_EV_K7_FIRST PMC_EV_K7_DC_ACCESSES -#define PMC_EV_K7_LAST PMC_EV_K7_HARDWARE_INTERRUPTS +#define PMC_EV_K7_LAST PMC_EV_K7_RETIRED_NEAR_RETURNS_MISPREDICTED /* > - in the kernel count, events at the level of individual functions, non- > statistically using high resolution kernel profiling. This may result > in more time spent counting than doing useful work, but provides > high resolution. I would rather us provide this via hwpmc(4). perfmon(4) does not support programmable events on modern Intel CPUs nor does it support non-x86 CPUs. -- John Baldwin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201007271540.30774.jhb>