Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Apr 2012 23:44:12 -0700
From:      Adrian Chadd <adrian@freebsd.org>
To:        Fabien Thomas <fabient@freebsd.org>, monthadar@freebsd.org
Cc:        freebsd-current <freebsd-current@freebsd.org>, freebsd-mips@freebsd.org
Subject:   Re: svn commit: r233628 - in head: lib/libpmc sys/amd64/amd64 sys/amd64/include sys/arm/include sys/conf sys/dev/hwpmc sys/i386/i386 sys/i386/include sys/kern sys/mips/include sys/modules/hwpmc sys/pow...
Message-ID:  <CAJ-Vmok-JHRsnwh5j2vnw54ccVSDOoYHCut_N9wfohsQSvOaZA@mail.gmail.com>
In-Reply-To: <201203282058.q2SKwVsJ053900@svn.freebsd.org>
References:  <201203282058.q2SKwVsJ053900@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi Fabien,

I've heard some rumours that this broke hwpmc support for mips24k.

Monthadar, can you please provide some background info for this?

Thanks,



adrian

On 28 March 2012 13:58, Fabien Thomas <fabient@freebsd.org> wrote:
> Author: fabient
> Date: Wed Mar 28 20:58:30 2012
> New Revision: 233628
> URL: http://svn.freebsd.org/changeset/base/233628
>
> Log:
> =A0Add software PMC support.
>
> =A0New kernel events can be added at various location for sampling or cou=
nting.
> =A0This will for example allow easy system profiling whatever the process=
or is
> =A0with known tools like pmcstat(8).
>
> =A0Simultaneous usage of software PMC and hardware PMC is possible, for e=
xample
> =A0looking at the lock acquire failure, page fault while sampling on
> =A0instructions.
>
> =A0Sponsored by: NETASQ
> =A0MFC after: =A0 =A01 month
>
> Added:
> =A0head/lib/libpmc/pmc.soft.3 =A0 (contents, props changed)
> =A0head/sys/dev/hwpmc/hwpmc_soft.c =A0 (contents, props changed)
> =A0head/sys/dev/hwpmc/hwpmc_soft.h =A0 (contents, props changed)
> Modified:
> =A0head/lib/libpmc/Makefile
> =A0head/lib/libpmc/libpmc.c
> =A0head/lib/libpmc/pmc.3
> =A0head/lib/libpmc/pmc.atom.3
> =A0head/lib/libpmc/pmc.core.3
> =A0head/lib/libpmc/pmc.core2.3
> =A0head/lib/libpmc/pmc.corei7.3
> =A0head/lib/libpmc/pmc.corei7uc.3
> =A0head/lib/libpmc/pmc.iaf.3
> =A0head/lib/libpmc/pmc.k7.3
> =A0head/lib/libpmc/pmc.k8.3
> =A0head/lib/libpmc/pmc.mips24k.3
> =A0head/lib/libpmc/pmc.octeon.3
> =A0head/lib/libpmc/pmc.p4.3
> =A0head/lib/libpmc/pmc.p5.3
> =A0head/lib/libpmc/pmc.p6.3
> =A0head/lib/libpmc/pmc.sandybridge.3
> =A0head/lib/libpmc/pmc.sandybridgeuc.3
> =A0head/lib/libpmc/pmc.tsc.3
> =A0head/lib/libpmc/pmc.ucf.3
> =A0head/lib/libpmc/pmc.westmere.3
> =A0head/lib/libpmc/pmc.westmereuc.3
> =A0head/lib/libpmc/pmc.xscale.3
> =A0head/lib/libpmc/pmclog.c
> =A0head/lib/libpmc/pmclog.h
> =A0head/sys/amd64/amd64/trap.c
> =A0head/sys/amd64/include/pmc_mdep.h
> =A0head/sys/arm/include/pmc_mdep.h
> =A0head/sys/conf/files
> =A0head/sys/dev/hwpmc/hwpmc_amd.c
> =A0head/sys/dev/hwpmc/hwpmc_core.c
> =A0head/sys/dev/hwpmc/hwpmc_intel.c
> =A0head/sys/dev/hwpmc/hwpmc_logging.c
> =A0head/sys/dev/hwpmc/hwpmc_mips.c
> =A0head/sys/dev/hwpmc/hwpmc_mod.c
> =A0head/sys/dev/hwpmc/hwpmc_piv.c
> =A0head/sys/dev/hwpmc/hwpmc_powerpc.c
> =A0head/sys/dev/hwpmc/hwpmc_ppro.c
> =A0head/sys/dev/hwpmc/hwpmc_tsc.c
> =A0head/sys/dev/hwpmc/hwpmc_x86.c
> =A0head/sys/dev/hwpmc/hwpmc_xscale.c
> =A0head/sys/dev/hwpmc/pmc_events.h
> =A0head/sys/i386/i386/trap.c
> =A0head/sys/i386/include/pmc_mdep.h
> =A0head/sys/kern/kern_clock.c
> =A0head/sys/kern/kern_lock.c
> =A0head/sys/kern/kern_mutex.c
> =A0head/sys/kern/kern_pmc.c
> =A0head/sys/kern/kern_rwlock.c
> =A0head/sys/kern/kern_sx.c
> =A0head/sys/kern/subr_trap.c
> =A0head/sys/mips/include/pmc_mdep.h
> =A0head/sys/modules/hwpmc/Makefile
> =A0head/sys/powerpc/include/pmc_mdep.h
> =A0head/sys/sys/pmc.h
> =A0head/sys/sys/pmckern.h
> =A0head/sys/sys/pmclog.h
> =A0head/usr.sbin/pmcstat/pmcstat_log.c
>
> Modified: head/lib/libpmc/Makefile
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/lib/libpmc/Makefile =A0 =A0Wed Mar 28 20:49:11 2012 =A0 =A0 =A0 =
=A0(r233627)
> +++ head/lib/libpmc/Makefile =A0 =A0Wed Mar 28 20:58:30 2012 =A0 =A0 =A0 =
=A0(r233628)
> @@ -20,6 +20,7 @@ MAN+=3D pmc_read.3
> =A0MAN+=3D =A0pmc_set.3
> =A0MAN+=3D =A0pmc_start.3
> =A0MAN+=3D =A0pmclog.3
> +MAN+=3D =A0pmc.soft.3
>
> =A0# PMC-dependent manual pages
> =A0.if ${MACHINE_CPUARCH} =3D=3D "i386" || ${MACHINE_CPUARCH} =3D=3D "amd=
64"
>
> Modified: head/lib/libpmc/libpmc.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/lib/libpmc/libpmc.c =A0 =A0Wed Mar 28 20:49:11 2012 =A0 =A0 =A0 =
=A0(r233627)
> +++ head/lib/libpmc/libpmc.c =A0 =A0Wed Mar 28 20:58:30 2012 =A0 =A0 =A0 =
=A0(r233628)
> @@ -77,11 +77,12 @@ static int tsc_allocate_pmc(enum pmc_eve
> =A0static int xscale_allocate_pmc(enum pmc_event _pe, char *_ctrspec,
> =A0 =A0 struct pmc_op_pmcallocate *_pmc_config);
> =A0#endif
> -
> =A0#if defined(__mips__)
> =A0static int mips_allocate_pmc(enum pmc_event _pe, char* ctrspec,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct pmc_op_pmc=
allocate *_pmc_config);
> =A0#endif /* __mips__ */
> +static int soft_allocate_pmc(enum pmc_event _pe, char *_ctrspec,
> + =A0 =A0struct pmc_op_pmcallocate *_pmc_config);
>
> =A0#if defined(__powerpc__)
> =A0static int ppc7450_allocate_pmc(enum pmc_event _pe, char* ctrspec,
> @@ -156,6 +157,8 @@ PMC_CLASSDEP_TABLE(octeon, OCTEON);
> =A0PMC_CLASSDEP_TABLE(ucf, UCF);
> =A0PMC_CLASSDEP_TABLE(ppc7450, PPC7450);
>
> +static struct pmc_event_descr soft_event_table[PMC_EV_DYN_COUNT];
> +
> =A0#undef __PMC_EV_ALIAS
> =A0#define =A0 =A0 =A0 =A0__PMC_EV_ALIAS(N,CODE) =A0{ N, PMC_EV_##CODE },
>
> @@ -215,21 +218,22 @@ static const struct pmc_event_descr west
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0PMC_CLASS_##C, __VA_ARGS__ =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 =A0 =A0 =A0 =A0\
> =A0 =A0 =A0 =A0}
>
> -PMC_MDEP_TABLE(atom, IAP, PMC_CLASS_IAF, PMC_CLASS_TSC);
> -PMC_MDEP_TABLE(core, IAP, PMC_CLASS_TSC);
> -PMC_MDEP_TABLE(core2, IAP, PMC_CLASS_IAF, PMC_CLASS_TSC);
> -PMC_MDEP_TABLE(corei7, IAP, PMC_CLASS_IAF, PMC_CLASS_TSC, PMC_CLASS_UCF,=
 PMC_CLASS_UCP);
> -PMC_MDEP_TABLE(sandybridge, IAP, PMC_CLASS_IAF, PMC_CLASS_TSC, PMC_CLASS=
_UCF, PMC_CLASS_UCP);
> -PMC_MDEP_TABLE(westmere, IAP, PMC_CLASS_IAF, PMC_CLASS_TSC, PMC_CLASS_UC=
F, PMC_CLASS_UCP);
> -PMC_MDEP_TABLE(k7, K7, PMC_CLASS_TSC);
> -PMC_MDEP_TABLE(k8, K8, PMC_CLASS_TSC);
> -PMC_MDEP_TABLE(p4, P4, PMC_CLASS_TSC);
> -PMC_MDEP_TABLE(p5, P5, PMC_CLASS_TSC);
> -PMC_MDEP_TABLE(p6, P6, PMC_CLASS_TSC);
> -PMC_MDEP_TABLE(xscale, XSCALE, PMC_CLASS_XSCALE);
> -PMC_MDEP_TABLE(mips24k, MIPS24K, PMC_CLASS_MIPS24K);
> -PMC_MDEP_TABLE(octeon, OCTEON, PMC_CLASS_OCTEON);
> -PMC_MDEP_TABLE(ppc7450, PPC7450, PMC_CLASS_PPC7450);
> +PMC_MDEP_TABLE(atom, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC);
> +PMC_MDEP_TABLE(core, IAP, PMC_CLASS_SOFT, PMC_CLASS_TSC);
> +PMC_MDEP_TABLE(core2, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC)=
;
> +PMC_MDEP_TABLE(corei7, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC=
, PMC_CLASS_UCF, PMC_CLASS_UCP);
> +PMC_MDEP_TABLE(sandybridge, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLAS=
S_TSC, PMC_CLASS_UCF, PMC_CLASS_UCP);
> +PMC_MDEP_TABLE(westmere, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_T=
SC, PMC_CLASS_UCF, PMC_CLASS_UCP);
> +PMC_MDEP_TABLE(k7, K7, PMC_CLASS_SOFT, PMC_CLASS_TSC);
> +PMC_MDEP_TABLE(k8, K8, PMC_CLASS_SOFT, PMC_CLASS_TSC);
> +PMC_MDEP_TABLE(p4, P4, PMC_CLASS_SOFT, PMC_CLASS_TSC);
> +PMC_MDEP_TABLE(p5, P5, PMC_CLASS_SOFT, PMC_CLASS_TSC);
> +PMC_MDEP_TABLE(p6, P6, PMC_CLASS_SOFT, PMC_CLASS_TSC);
> +PMC_MDEP_TABLE(xscale, XSCALE, PMC_CLASS_SOFT, PMC_CLASS_XSCALE);
> +PMC_MDEP_TABLE(mips24k, MIPS24K, PMC_CLASS_SOFT, PMC_CLASS_MIPS24K);
> +PMC_MDEP_TABLE(octeon, OCTEON, PMC_CLASS_SOFT, PMC_CLASS_OCTEON);
> +PMC_MDEP_TABLE(ppc7450, PPC7450, PMC_CLASS_SOFT, PMC_CLASS_PPC7450);
> +PMC_MDEP_TABLE(generic, SOFT, PMC_CLASS_SOFT);
>
> =A0static const struct pmc_event_descr tsc_event_table[] =3D
> =A0{
> @@ -279,16 +283,24 @@ PMC_CLASS_TABLE_DESC(tsc, TSC, tsc, tsc)
> =A0#if =A0 =A0defined(__XSCALE__)
> =A0PMC_CLASS_TABLE_DESC(xscale, XSCALE, xscale, xscale);
> =A0#endif
> -
> =A0#if defined(__mips__)
> =A0PMC_CLASS_TABLE_DESC(mips24k, MIPS24K, mips24k, mips);
> =A0PMC_CLASS_TABLE_DESC(octeon, OCTEON, octeon, mips);
> =A0#endif /* __mips__ */
> -
> =A0#if defined(__powerpc__)
> =A0PMC_CLASS_TABLE_DESC(ppc7450, PPC7450, ppc7450, ppc7450);
> =A0#endif
>
> +static struct pmc_class_descr soft_class_table_descr =3D
> +{
> + =A0 =A0 =A0 .pm_evc_name =A0=3D "SOFT-",
> + =A0 =A0 =A0 .pm_evc_name_size =3D sizeof("SOFT-") - 1,
> + =A0 =A0 =A0 .pm_evc_class =3D PMC_CLASS_SOFT,
> + =A0 =A0 =A0 .pm_evc_event_table =3D NULL,
> + =A0 =A0 =A0 .pm_evc_event_table_size =3D 0,
> + =A0 =A0 =A0 .pm_evc_allocate_pmc =3D soft_allocate_pmc
> +};
> +
> =A0#undef PMC_CLASS_TABLE_DESC
>
> =A0static const struct pmc_class_descr **pmc_class_table;
> @@ -343,9 +355,12 @@ static const char * pmc_state_names[] =3D
> =A0 =A0 =A0 =A0__PMC_STATES()
> =A0};
>
> -static int pmc_syscall =3D -1; =A0 =A0 =A0 =A0 =A0 /* filled in by pmc_i=
nit() */
> -
> -static struct pmc_cpuinfo cpu_info; =A0 =A0/* filled in by pmc_init() */
> +/*
> + * Filled in by pmc_init().
> + */
> +static int pmc_syscall =3D -1;
> +static struct pmc_cpuinfo cpu_info;
> +static struct pmc_op_getdyneventinfo soft_event_info;
>
> =A0/* Event masks for events */
> =A0struct pmc_masks {
> @@ -2179,6 +2194,25 @@ tsc_allocate_pmc(enum pmc_event pe, char
> =A0}
> =A0#endif
>
> +static struct pmc_event_alias generic_aliases[] =3D {
> + =A0 =A0 =A0 EV_ALIAS("instructions", =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"SO=
FT-CLOCK.HARD"),
> + =A0 =A0 =A0 EV_ALIAS(NULL, NULL)
> +};
> +
> +static int
> +soft_allocate_pmc(enum pmc_event pe, char *ctrspec,
> + =A0 =A0struct pmc_op_pmcallocate *pmc_config)
> +{
> + =A0 =A0 =A0 (void)ctrspec;
> + =A0 =A0 =A0 (void)pmc_config;
> +
> + =A0 =A0 =A0 if (pe < PMC_EV_SOFT_FIRST || pe > PMC_EV_SOFT_LAST)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return (-1);
> +
> + =A0 =A0 =A0 pmc_config->pm_caps |=3D (PMC_CAP_READ | PMC_CAP_WRITE);
> + =A0 =A0 =A0 return (0);
> +}
> +
> =A0#if =A0 =A0defined(__XSCALE__)
>
> =A0static struct pmc_event_alias xscale_aliases[] =3D {
> @@ -2663,6 +2697,10 @@ pmc_event_names_of_class(enum pmc_class
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ev =3D ppc7450_event_table;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0count =3D PMC_EVENT_TABLE_SIZE(ppc7450);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break;
> + =A0 =A0 =A0 case PMC_CLASS_SOFT:
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 ev =3D soft_event_table;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 count =3D soft_event_info.pm_nevent;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 break;
> =A0 =A0 =A0 =A0default:
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0errno =3D EINVAL;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return (-1);
> @@ -2676,6 +2714,7 @@ pmc_event_names_of_class(enum pmc_class
>
> =A0 =A0 =A0 =A0for (;count--; ev++, names++)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0*names =3D ev->pm_ev_name;
> +
> =A0 =A0 =A0 =A0return (0);
> =A0}
>
> @@ -2780,11 +2819,34 @@ pmc_init(void)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0pmc_class_table[n] =3D NULL;
>
> =A0 =A0 =A0 =A0/*
> + =A0 =A0 =A0 =A0* Get soft events list.
> + =A0 =A0 =A0 =A0*/
> + =A0 =A0 =A0 soft_event_info.pm_class =3D PMC_CLASS_SOFT;
> + =A0 =A0 =A0 if (PMC_CALL(GETDYNEVENTINFO, &soft_event_info) < 0)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return (pmc_syscall =3D -1);
> +
> + =A0 =A0 =A0 /* Map soft events to static list. */
> + =A0 =A0 =A0 for (n =3D 0; n < soft_event_info.pm_nevent; n++) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 soft_event_table[n].pm_ev_name =3D
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 soft_event_info.pm_events[n].pm_ev_=
name;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 soft_event_table[n].pm_ev_code =3D
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 soft_event_info.pm_events[n].pm_ev_=
code;
> + =A0 =A0 =A0 }
> + =A0 =A0 =A0 soft_class_table_descr.pm_evc_event_table_size =3D \
> + =A0 =A0 =A0 =A0 =A0 soft_event_info.pm_nevent;
> + =A0 =A0 =A0 soft_class_table_descr.pm_evc_event_table =3D \
> + =A0 =A0 =A0 =A0 =A0 soft_event_table;
> +
> + =A0 =A0 =A0 /*
> =A0 =A0 =A0 =A0 * Fill in the class table.
> =A0 =A0 =A0 =A0 */
> =A0 =A0 =A0 =A0n =3D 0;
> +
> + =A0 =A0 =A0 /* Fill soft events information. */
> + =A0 =A0 =A0 pmc_class_table[n++] =3D &soft_class_table_descr;
> =A0#if defined(__amd64__) || defined(__i386__)
> - =A0 =A0 =A0 pmc_class_table[n++] =3D &tsc_class_table_descr;
> + =A0 =A0 =A0 if (cpu_info.pm_cputype !=3D PMC_CPU_GENERIC)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pmc_class_table[n++] =3D &tsc_class_table_d=
escr;
>
> =A0 =A0 =A0 =A0/*
> =A0 =A0 =A0 =A0 * Check if this CPU has fixed function counters.
> @@ -2867,6 +2929,9 @@ pmc_init(void)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0pmc_class_table[n] =3D &p4_class_table_des=
cr;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break;
> =A0#endif
> + =A0 =A0 =A0 case PMC_CPU_GENERIC:
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 PMC_MDEP_INIT(generic);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 break;
> =A0#if defined(__XSCALE__)
> =A0 =A0 =A0 =A0case PMC_CPU_INTEL_XSCALE:
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0PMC_MDEP_INIT(xscale);
> @@ -3035,18 +3100,19 @@ _pmc_name_of_event(enum pmc_event pe, en
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0evfence =3D xscale_event_table + PMC_EVENT=
_TABLE_SIZE(xscale);
> =A0 =A0 =A0 =A0} else if (pe >=3D PMC_EV_MIPS24K_FIRST && pe <=3D PMC_EV_=
MIPS24K_LAST) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ev =3D mips24k_event_table;
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 evfence =3D mips24k_event_table + PMC_EVENT=
_TABLE_SIZE(mips24k
> -);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 evfence =3D mips24k_event_table + PMC_EVENT=
_TABLE_SIZE(mips24k);
> =A0 =A0 =A0 =A0} else if (pe >=3D PMC_EV_OCTEON_FIRST && pe <=3D PMC_EV_O=
CTEON_LAST) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ev =3D octeon_event_table;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0evfence =3D octeon_event_table + PMC_EVENT=
_TABLE_SIZE(octeon);
> =A0 =A0 =A0 =A0} else if (pe >=3D PMC_EV_PPC7450_FIRST && pe <=3D PMC_EV_=
PPC7450_LAST) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ev =3D ppc7450_event_table;
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 evfence =3D ppc7450_event_table + PMC_EVENT=
_TABLE_SIZE(ppc7450
> -);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 evfence =3D ppc7450_event_table + PMC_EVENT=
_TABLE_SIZE(ppc7450);
> =A0 =A0 =A0 =A0} else if (pe =3D=3D PMC_EV_TSC_TSC) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ev =3D tsc_event_table;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0evfence =3D tsc_event_table + PMC_EVENT_TA=
BLE_SIZE(tsc);
> + =A0 =A0 =A0 } else if (pe >=3D PMC_EV_SOFT_FIRST && pe <=3D PMC_EV_SOFT=
_LAST) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 ev =3D soft_event_table;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 evfence =3D soft_event_table + soft_event_i=
nfo.pm_nevent;
> =A0 =A0 =A0 =A0}
>
> =A0 =A0 =A0 =A0for (; ev !=3D evfence; ev++)
>
> Modified: head/lib/libpmc/pmc.3
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/lib/libpmc/pmc.3 =A0 =A0 =A0 Wed Mar 28 20:49:11 2012 =A0 =A0 =
=A0 =A0(r233627)
> +++ head/lib/libpmc/pmc.3 =A0 =A0 =A0 Wed Mar 28 20:58:30 2012 =A0 =A0 =
=A0 =A0(r233628)
> @@ -223,6 +223,8 @@ and
> =A0CPUs.
> =A0.It Li PMC_CLASS_TSC
> =A0The timestamp counter on i386 and amd64 architecture CPUs.
> +.It Li PMC_CLASS_SOFT
> +Software events.
> =A0.El
> =A0.Ss PMC Capabilities
> =A0Capabilities of performance monitoring hardware are denoted using
> @@ -525,6 +527,7 @@ API is
> =A0.Xr pmc.p4 3 ,
> =A0.Xr pmc.p5 3 ,
> =A0.Xr pmc.p6 3 ,
> +.Xr pmc.soft 3 ,
> =A0.Xr pmc.tsc 3 ,
> =A0.Xr pmclog 3 ,
> =A0.Xr hwpmc 4 ,
>
> Modified: head/lib/libpmc/pmc.atom.3
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/lib/libpmc/pmc.atom.3 =A0Wed Mar 28 20:49:11 2012 =A0 =A0 =A0 =
=A0(r233627)
> +++ head/lib/libpmc/pmc.atom.3 =A0Wed Mar 28 20:58:30 2012 =A0 =A0 =A0 =
=A0(r233628)
> @@ -1176,6 +1176,7 @@ and the underlying hardware events used
> =A0.Xr pmc.p4 3 ,
> =A0.Xr pmc.p5 3 ,
> =A0.Xr pmc.p6 3 ,
> +.Xr pmc.soft 3 ,
> =A0.Xr pmc.tsc 3 ,
> =A0.Xr pmc_cpuinfo 3 ,
> =A0.Xr pmclog 3 ,
>
> Modified: head/lib/libpmc/pmc.core.3
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/lib/libpmc/pmc.core.3 =A0Wed Mar 28 20:49:11 2012 =A0 =A0 =A0 =
=A0(r233627)
> +++ head/lib/libpmc/pmc.core.3 =A0Wed Mar 28 20:58:30 2012 =A0 =A0 =A0 =
=A0(r233628)
> @@ -792,6 +792,7 @@ may not count some transitions.
> =A0.Xr pmc.p4 3 ,
> =A0.Xr pmc.p5 3 ,
> =A0.Xr pmc.p6 3 ,
> +.Xr pmc.soft 3 ,
> =A0.Xr pmc.tsc 3 ,
> =A0.Xr pmclog 3 ,
> =A0.Xr hwpmc 4
>
> Modified: head/lib/libpmc/pmc.core2.3
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/lib/libpmc/pmc.core2.3 Wed Mar 28 20:49:11 2012 =A0 =A0 =A0 =A0(=
r233627)
> +++ head/lib/libpmc/pmc.core2.3 Wed Mar 28 20:58:30 2012 =A0 =A0 =A0 =A0(=
r233628)
> @@ -1107,6 +1107,7 @@ and the underlying hardware events used.
> =A0.Xr pmc.p4 3 ,
> =A0.Xr pmc.p5 3 ,
> =A0.Xr pmc.p6 3 ,
> +.Xr pmc.soft 3 ,
> =A0.Xr pmc.tsc 3 ,
> =A0.Xr pmc_cpuinfo 3 ,
> =A0.Xr pmclog 3 ,
>
> Modified: head/lib/libpmc/pmc.corei7.3
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/lib/libpmc/pmc.corei7.3 =A0 =A0 =A0 =A0Wed Mar 28 20:49:11 2012 =
=A0 =A0 =A0 =A0(r233627)
> +++ head/lib/libpmc/pmc.corei7.3 =A0 =A0 =A0 =A0Wed Mar 28 20:58:30 2012 =
=A0 =A0 =A0 =A0(r233628)
> @@ -1559,6 +1559,7 @@ Counts number of segment register loads.
> =A0.Xr pmc.corei7uc 3 ,
> =A0.Xr pmc.westmere 3 ,
> =A0.Xr pmc.westmereuc 3 ,
> +.Xr pmc.soft 3 ,
> =A0.Xr pmc.tsc 3 ,
> =A0.Xr pmc_cpuinfo 3 ,
> =A0.Xr pmclog 3 ,
>
> Modified: head/lib/libpmc/pmc.corei7uc.3
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/lib/libpmc/pmc.corei7uc.3 =A0 =A0 =A0Wed Mar 28 20:49:11 2012 =
=A0 =A0 =A0 =A0(r233627)
> +++ head/lib/libpmc/pmc.corei7uc.3 =A0 =A0 =A0Wed Mar 28 20:58:30 2012 =
=A0 =A0 =A0 =A0(r233628)
> @@ -863,6 +863,7 @@ refreshed or needs to go into a power do
> =A0.Xr pmc.corei7 3 ,
> =A0.Xr pmc.westmere 3 ,
> =A0.Xr pmc.westmereuc 3 ,
> +.Xr pmc.soft 3 ,
> =A0.Xr pmc.tsc 3 ,
> =A0.Xr pmc_cpuinfo 3 ,
> =A0.Xr pmclog 3 ,
>
> Modified: head/lib/libpmc/pmc.iaf.3
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/lib/libpmc/pmc.iaf.3 =A0 Wed Mar 28 20:49:11 2012 =A0 =A0 =A0 =
=A0(r233627)
> +++ head/lib/libpmc/pmc.iaf.3 =A0 Wed Mar 28 20:58:30 2012 =A0 =A0 =A0 =
=A0(r233628)
> @@ -132,6 +132,7 @@ CPU, use the event specifier
> =A0.Xr pmc.p4 3 ,
> =A0.Xr pmc.p5 3 ,
> =A0.Xr pmc.p6 3 ,
> +.Xr pmc.soft 3 ,
> =A0.Xr pmc.tsc 3 ,
> =A0.Xr pmc_cpuinfo 3 ,
> =A0.Xr pmclog 3 ,
>
> Modified: head/lib/libpmc/pmc.k7.3
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/lib/libpmc/pmc.k7.3 =A0 =A0Wed Mar 28 20:49:11 2012 =A0 =A0 =A0 =
=A0(r233627)
> +++ head/lib/libpmc/pmc.k7.3 =A0 =A0Wed Mar 28 20:58:30 2012 =A0 =A0 =A0 =
=A0(r233628)
> @@ -249,6 +249,7 @@ and the underlying hardware events used.
> =A0.Xr pmc.p4 3 ,
> =A0.Xr pmc.p5 3 ,
> =A0.Xr pmc.p6 3 ,
> +.Xr pmc.soft 3 ,
> =A0.Xr pmc.tsc 3 ,
> =A0.Xr pmclog 3 ,
> =A0.Xr hwpmc 4
>
> Modified: head/lib/libpmc/pmc.k8.3
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/lib/libpmc/pmc.k8.3 =A0 =A0Wed Mar 28 20:49:11 2012 =A0 =A0 =A0 =
=A0(r233627)
> +++ head/lib/libpmc/pmc.k8.3 =A0 =A0Wed Mar 28 20:58:30 2012 =A0 =A0 =A0 =
=A0(r233628)
> @@ -783,6 +783,7 @@ and the underlying hardware events used.
> =A0.Xr pmc.p4 3 ,
> =A0.Xr pmc.p5 3 ,
> =A0.Xr pmc.p6 3 ,
> +.Xr pmc.soft 3 ,
> =A0.Xr pmc.tsc 3 ,
> =A0.Xr pmclog 3 ,
> =A0.Xr hwpmc 4
>
> Modified: head/lib/libpmc/pmc.mips24k.3
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/lib/libpmc/pmc.mips24k.3 =A0 =A0 =A0 Wed Mar 28 20:49:11 2012 =
=A0 =A0 =A0 =A0(r233627)
> +++ head/lib/libpmc/pmc.mips24k.3 =A0 =A0 =A0 Wed Mar 28 20:58:30 2012 =
=A0 =A0 =A0 =A0(r233628)
> @@ -392,6 +392,7 @@ and the underlying hardware events used.
> =A0.Xr pmc.p4 3 ,
> =A0.Xr pmc.p5 3 ,
> =A0.Xr pmc.p6 3 ,
> +.Xr pmc.soft 3 ,
> =A0.Xr pmc.tsc 3 ,
> =A0.Xr pmc_cpuinfo 3 ,
> =A0.Xr pmclog 3 ,
>
> Modified: head/lib/libpmc/pmc.octeon.3
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/lib/libpmc/pmc.octeon.3 =A0 =A0 =A0 =A0Wed Mar 28 20:49:11 2012 =
=A0 =A0 =A0 =A0(r233627)
> +++ head/lib/libpmc/pmc.octeon.3 =A0 =A0 =A0 =A0Wed Mar 28 20:58:30 2012 =
=A0 =A0 =A0 =A0(r233628)
> @@ -232,6 +232,7 @@ and the underlying hardware events used.
> =A0.Xr pmc.p4 3 ,
> =A0.Xr pmc.p5 3 ,
> =A0.Xr pmc.p6 3 ,
> +.Xr pmc.soft 3 ,
> =A0.Xr pmc.tsc 3 ,
> =A0.Xr pmc_cpuinfo 3 ,
> =A0.Xr pmclog 3 ,
>
> Modified: head/lib/libpmc/pmc.p4.3
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/lib/libpmc/pmc.p4.3 =A0 =A0Wed Mar 28 20:49:11 2012 =A0 =A0 =A0 =
=A0(r233627)
> +++ head/lib/libpmc/pmc.p4.3 =A0 =A0Wed Mar 28 20:58:30 2012 =A0 =A0 =A0 =
=A0(r233628)
> @@ -1208,6 +1208,7 @@ and the underlying hardware events used.
> =A0.Xr pmc.k8 3 ,
> =A0.Xr pmc.p5 3 ,
> =A0.Xr pmc.p6 3 ,
> +.Xr pmc.soft 3 ,
> =A0.Xr pmc.tsc 3 ,
> =A0.Xr pmclog 3 ,
> =A0.Xr hwpmc 4
>
> Modified: head/lib/libpmc/pmc.p5.3
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/lib/libpmc/pmc.p5.3 =A0 =A0Wed Mar 28 20:49:11 2012 =A0 =A0 =A0 =
=A0(r233627)
> +++ head/lib/libpmc/pmc.p5.3 =A0 =A0Wed Mar 28 20:58:30 2012 =A0 =A0 =A0 =
=A0(r233628)
> @@ -444,6 +444,7 @@ and the underlying hardware events used.
> =A0.Xr pmc.k8 3 ,
> =A0.Xr pmc.p4 3 ,
> =A0.Xr pmc.p6 3 ,
> +.Xr pmc.soft 3 ,
> =A0.Xr pmc.tsc 3 ,
> =A0.Xr pmclog 3 ,
> =A0.Xr hwpmc 4
>
> Modified: head/lib/libpmc/pmc.p6.3
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/lib/libpmc/pmc.p6.3 =A0 =A0Wed Mar 28 20:49:11 2012 =A0 =A0 =A0 =
=A0(r233627)
> +++ head/lib/libpmc/pmc.p6.3 =A0 =A0Wed Mar 28 20:58:30 2012 =A0 =A0 =A0 =
=A0(r233628)
> @@ -1010,6 +1010,7 @@ and the underlying hardware events used.
> =A0.Xr pmc.k8 3 ,
> =A0.Xr pmc.p4 3 ,
> =A0.Xr pmc.p5 3 ,
> +.Xr pmc.soft 3 ,
> =A0.Xr pmc.tsc 3 ,
> =A0.Xr pmclog 3 ,
> =A0.Xr hwpmc 4
>
> Modified: head/lib/libpmc/pmc.sandybridge.3
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/lib/libpmc/pmc.sandybridge.3 =A0 Wed Mar 28 20:49:11 2012 =A0 =
=A0 =A0 =A0(r233627)
> +++ head/lib/libpmc/pmc.sandybridge.3 =A0 Wed Mar 28 20:58:30 2012 =A0 =
=A0 =A0 =A0(r233628)
> @@ -907,6 +907,7 @@ Split locks in SQ.
> =A0.Xr pmc.p5 3 ,
> =A0.Xr pmc.p6 3 ,
> =A0.Xr pmc.sandybridgeuc 3 ,
> +.Xr pmc.soft 3 ,
> =A0.Xr pmc.tsc 3 ,
> =A0.Xr pmc.ucf 3 ,
> =A0.Xr pmc.westmere 3 ,
>
> Modified: head/lib/libpmc/pmc.sandybridgeuc.3
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/lib/libpmc/pmc.sandybridgeuc.3 Wed Mar 28 20:49:11 2012 =A0 =A0 =
=A0 =A0(r233627)
> +++ head/lib/libpmc/pmc.sandybridgeuc.3 Wed Mar 28 20:58:30 2012 =A0 =A0 =
=A0 =A0(r233628)
> @@ -208,6 +208,7 @@ Counts the number of core-outgoing entri
> =A0.Xr pmc.p5 3 ,
> =A0.Xr pmc.p6 3 ,
> =A0.Xr pmc.sandybridge 3 ,
> +.Xr pmc.soft 3 ,
> =A0.Xr pmc.tsc 3 ,
> =A0.Xr pmc.ucf 3 ,
> =A0.Xr pmc.westmere 3 ,
>
> Added: head/lib/libpmc/pmc.soft.3
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- /dev/null =A0 00:00:00 1970 =A0 (empty, because file is newly added)
> +++ head/lib/libpmc/pmc.soft.3 =A0Wed Mar 28 20:58:30 2012 =A0 =A0 =A0 =
=A0(r233628)
> @@ -0,0 +1,104 @@
> +.\" Copyright (c) 2012 Fabien Thomas. =A0All rights reserved.
> +.\"
> +.\" Redistribution and use in source and binary forms, with or without
> +.\" modification, are permitted provided that the following conditions
> +.\" are met:
> +.\" 1. Redistributions of source code must retain the above copyright
> +.\" =A0 =A0notice, this list of conditions and the following disclaimer.
> +.\" 2. Redistributions in binary form must reproduce the above copyright
> +.\" =A0 =A0notice, this list of conditions and the following disclaimer =
in the
> +.\" =A0 =A0documentation and/or other materials provided with the distri=
bution.
> +.\"
> +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' A=
ND
> +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, TH=
E
> +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR P=
URPOSE
> +.\" ARE DISCLAIMED. =A0IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE L=
IABLE
> +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQU=
ENTIAL
> +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GO=
ODS
> +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION=
)
> +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, =
STRICT
> +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN AN=
Y WAY
> +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY =
OF
> +.\" SUCH DAMAGE.
> +.\"
> +.\" $FreeBSD$
> +.\"
> +.Dd March 28, 2012
> +.Os
> +.Dt PMC.SOFT 3
> +.Sh NAME
> +.Nm pmc.soft
> +.Nd measurements using software based events
> +.Sh LIBRARY
> +.Lb libpmc
> +.Sh SYNOPSIS
> +.In pmc.h
> +.Sh DESCRIPTION
> +Software events are used to collect various source of software events.
> +.Ss PMC Features
> +16 sampling counters using software events based on various sources.
> +These PMCs support the following capabilities:
> +.Bl -column "PMC_CAP_INTERRUPT" "Support"
> +.It Em Capability Ta Em Support
> +.It PMC_CAP_CASCADE Ta \&No
> +.It PMC_CAP_EDGE Ta \&No
> +.It PMC_CAP_INTERRUPT Ta Yes
> +.It PMC_CAP_INVERT Ta \&No
> +.It PMC_CAP_READ Ta Yes
> +.It PMC_CAP_PRECISE Ta \&No
> +.It PMC_CAP_SYSTEM Ta Yes
> +.It PMC_CAP_TAGGING Ta \&No
> +.It PMC_CAP_THRESHOLD Ta \&No
> +.It PMC_CAP_USER Ta Yes
> +.It PMC_CAP_WRITE Ta Yes
> +.El
> +.Ss Event Qualifiers
> +There is no supported event qualifier.
> +.Pp
> +The event specifiers supported by software are:
> +.Bl -tag -width indent
> +.It Li CLOCK.HARD
> +Hard clock ticks.
> +.It Li CLOCK.STAT
> +Stat clock ticks.
> +.It Li LOCK.FAILED
> +Lock acquisition failed.
> +.It Li PAGE_FAULT.ALL
> +All page fault type.
> +.It Li PAGE_FAULT.READ
> +Read page fault.
> +.It Li PAGE_FAULT.WRITE
> +Write page fault.
> +.El
> +.Sh SEE ALSO
> +.Xr pmc 3 ,
> +.Xr pmc.atom 3 ,
> +.Xr pmc.core 3 ,
> +.Xr pmc.iaf 3 ,
> +.Xr pmc.ucf 3 ,
> +.Xr pmc.k7 3 ,
> +.Xr pmc.k8 3 ,
> +.Xr pmc.p4 3 ,
> +.Xr pmc.p5 3 ,
> +.Xr pmc.p6 3 ,
> +.Xr pmc.corei7 3 ,
> +.Xr pmc.corei7uc 3 ,
> +.Xr pmc.westmereuc 3 ,
> +.Xr pmc.tsc 3 ,
> +.Xr pmc_cpuinfo 3 ,
> +.Xr pmclog 3 ,
> +.Xr hwpmc 4
> +.Sh HISTORY
> +The
> +.Nm pmc
> +library first appeared in
> +.Fx 6.0 .
> +.Sh AUTHORS
> +The
> +.Lb libpmc
> +library was written by
> +.An "Joseph Koshy"
> +.Aq jkoshy@FreeBSD.org .
> +Software PMC was written by
> +.An "Fabien Thomas"
> +.Aq fabient@FreeBSD.org .
>
> Modified: head/lib/libpmc/pmc.tsc.3
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/lib/libpmc/pmc.tsc.3 =A0 Wed Mar 28 20:49:11 2012 =A0 =A0 =A0 =
=A0(r233627)
> +++ head/lib/libpmc/pmc.tsc.3 =A0 Wed Mar 28 20:58:30 2012 =A0 =A0 =A0 =
=A0(r233628)
> @@ -68,6 +68,7 @@ maps to the TSC.
> =A0.Xr pmc.p4 3 ,
> =A0.Xr pmc.p5 3 ,
> =A0.Xr pmc.p6 3 ,
> +.Xr pmc.soft 3 ,
> =A0.Xr pmclog 3 ,
> =A0.Xr hwpmc 4
> =A0.Sh HISTORY
>
> Modified: head/lib/libpmc/pmc.ucf.3
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/lib/libpmc/pmc.ucf.3 =A0 Wed Mar 28 20:49:11 2012 =A0 =A0 =A0 =
=A0(r233627)
> +++ head/lib/libpmc/pmc.ucf.3 =A0 Wed Mar 28 20:58:30 2012 =A0 =A0 =A0 =
=A0(r233628)
> @@ -96,6 +96,7 @@ offset C0H under device number 0 and Fun
> =A0.Xr pmc.corei7uc 3 ,
> =A0.Xr pmc.westmere 3 ,
> =A0.Xr pmc.westmereuc 3 ,
> +.Xr pmc.soft 3 ,
> =A0.Xr pmc.tsc 3 ,
> =A0.Xr pmc_cpuinfo 3 ,
> =A0.Xr pmclog 3 ,
>
> Modified: head/lib/libpmc/pmc.westmere.3
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/lib/libpmc/pmc.westmere.3 =A0 =A0 =A0Wed Mar 28 20:49:11 2012 =
=A0 =A0 =A0 =A0(r233627)
> +++ head/lib/libpmc/pmc.westmere.3 =A0 =A0 =A0Wed Mar 28 20:58:30 2012 =
=A0 =A0 =A0 =A0(r233628)
> @@ -1381,6 +1381,7 @@ Counts number of SID integer 64 bit shif
> =A0.Xr pmc.corei7 3 ,
> =A0.Xr pmc.corei7uc 3 ,
> =A0.Xr pmc.westmereuc 3 ,
> +.Xr pmc.soft 3 ,
> =A0.Xr pmc.tsc 3 ,
> =A0.Xr pmc_cpuinfo 3 ,
> =A0.Xr pmclog 3 ,
>
> Modified: head/lib/libpmc/pmc.westmereuc.3
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/lib/libpmc/pmc.westmereuc.3 =A0 =A0Wed Mar 28 20:49:11 2012 =A0 =
=A0 =A0 =A0(r233627)
> +++ head/lib/libpmc/pmc.westmereuc.3 =A0 =A0Wed Mar 28 20:58:30 2012 =A0 =
=A0 =A0 =A0(r233628)
> @@ -1066,6 +1066,7 @@ disabled.
> =A0.Xr pmc.corei7 3 ,
> =A0.Xr pmc.corei7uc 3 ,
> =A0.Xr pmc.westmere 3 ,
> +.Xr pmc.soft 3 ,
> =A0.Xr pmc.tsc 3 ,
> =A0.Xr pmc_cpuinfo 3 ,
> =A0.Xr pmclog 3 ,
>
> Modified: head/lib/libpmc/pmc.xscale.3
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/lib/libpmc/pmc.xscale.3 =A0 =A0 =A0 =A0Wed Mar 28 20:49:11 2012 =
=A0 =A0 =A0 =A0(r233627)
> +++ head/lib/libpmc/pmc.xscale.3 =A0 =A0 =A0 =A0Wed Mar 28 20:58:30 2012 =
=A0 =A0 =A0 =A0(r233628)
> @@ -134,6 +134,7 @@ and the underlying hardware events used.
> =A0.Xr pmc 3 ,
> =A0.Xr pmc_cpuinfo 3 ,
> =A0.Xr pmclog 3 ,
> +.Xr pmc.soft 3 ,
> =A0.Xr hwpmc 4
> =A0.Sh HISTORY
> =A0The
>
> Modified: head/lib/libpmc/pmclog.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/lib/libpmc/pmclog.c =A0 =A0Wed Mar 28 20:49:11 2012 =A0 =A0 =A0 =
=A0(r233627)
> +++ head/lib/libpmc/pmclog.c =A0 =A0Wed Mar 28 20:58:30 2012 =A0 =A0 =A0 =
=A0(r233628)
> @@ -369,6 +369,12 @@ pmclog_get_event(void *cookie, char **da
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=3D=3D NULL)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0goto error;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break;
> + =A0 =A0 =A0 case PMCLOG_TYPE_PMCALLOCATEDYN:
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 PMCLOG_READ32(le,ev->pl_u.pl_ad.pl_pmcid);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 PMCLOG_READ32(le,ev->pl_u.pl_ad.pl_event);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 PMCLOG_READ32(le,ev->pl_u.pl_ad.pl_flags);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 PMCLOG_READSTRING(le,ev->pl_u.pl_ad.pl_evna=
me,PMC_NAME_MAX);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 break;
> =A0 =A0 =A0 =A0case PMCLOG_TYPE_PMCATTACH:
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0PMCLOG_GET_PATHLEN(pathlen,evlen,pmclog_pm=
cattach);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0PMCLOG_READ32(le,ev->pl_u.pl_t.pl_pmcid);
>
> Modified: head/lib/libpmc/pmclog.h
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/lib/libpmc/pmclog.h =A0 =A0Wed Mar 28 20:49:11 2012 =A0 =A0 =A0 =
=A0(r233627)
> +++ head/lib/libpmc/pmclog.h =A0 =A0Wed Mar 28 20:58:30 2012 =A0 =A0 =A0 =
=A0(r233628)
> @@ -88,6 +88,13 @@ struct pmclog_ev_pmcallocate {
> =A0 =A0 =A0 =A0pmc_id_t =A0 =A0 =A0 =A0pl_pmcid;
> =A0};
>
> +struct pmclog_ev_pmcallocatedyn {
> + =A0 =A0 =A0 uint32_t =A0 =A0 =A0 =A0pl_event;
> + =A0 =A0 =A0 char =A0 =A0 =A0 =A0 =A0 =A0pl_evname[PMC_NAME_MAX];
> + =A0 =A0 =A0 uint32_t =A0 =A0 =A0 =A0pl_flags;
> + =A0 =A0 =A0 pmc_id_t =A0 =A0 =A0 =A0pl_pmcid;
> +};
> +
> =A0struct pmclog_ev_pmcattach {
> =A0 =A0 =A0 =A0pmc_id_t =A0 =A0 =A0 =A0pl_pmcid;
> =A0 =A0 =A0 =A0pid_t =A0 =A0 =A0 =A0 =A0 pl_pid;
> @@ -146,6 +153,7 @@ struct pmclog_ev {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0struct pmclog_ev_map_out =A0 =A0 =A0 =A0pl=
_mo;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0struct pmclog_ev_pcsample =A0 =A0 =A0 pl_s=
;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0struct pmclog_ev_pmcallocate =A0 =A0pl_a;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct pmclog_ev_pmcallocatedyn pl_ad;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0struct pmclog_ev_pmcattach =A0 =A0 =A0pl_t=
;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0struct pmclog_ev_pmcdetach =A0 =A0 =A0pl_d=
;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0struct pmclog_ev_proccsw =A0 =A0 =A0 =A0pl=
_c;
>
> Modified: head/sys/amd64/amd64/trap.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/sys/amd64/amd64/trap.c Wed Mar 28 20:49:11 2012 =A0 =A0 =A0 =A0(=
r233627)
> +++ head/sys/amd64/amd64/trap.c Wed Mar 28 20:58:30 2012 =A0 =A0 =A0 =A0(=
r233628)
> @@ -71,6 +71,9 @@ __FBSDID("$FreeBSD$");
> =A0#include <sys/vmmeter.h>
> =A0#ifdef HWPMC_HOOKS
> =A0#include <sys/pmckern.h>
> +PMC_SOFT_DEFINE( , , page_fault, all);
> +PMC_SOFT_DEFINE( , , page_fault, read);
> +PMC_SOFT_DEFINE( , , page_fault, write);
> =A0#endif
>
> =A0#include <vm/vm.h>
> @@ -743,8 +746,20 @@ trap_pfault(frame, usermode)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 */
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0rv =3D vm_fault(map, va, ftype, VM_FAULT_N=
ORMAL);
> =A0 =A0 =A0 =A0}
> - =A0 =A0 =A0 if (rv =3D=3D KERN_SUCCESS)
> + =A0 =A0 =A0 if (rv =3D=3D KERN_SUCCESS) {
> +#ifdef HWPMC_HOOKS
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (ftype =3D=3D VM_PROT_READ || ftype =3D=
=3D VM_PROT_WRITE) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 PMC_SOFT_CALL_TF( , , page_=
fault, all, frame);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (ftype =3D=3D VM_PROT_RE=
AD)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 PMC_SOFT_CA=
LL_TF( , , page_fault, read,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 fra=
me);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 else
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 PMC_SOFT_CA=
LL_TF( , , page_fault, write,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 fra=
me);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> +#endif
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return (0);
> + =A0 =A0 =A0 }
> =A0nogo:
> =A0 =A0 =A0 =A0if (!usermode) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (td->td_intr_nesting_level =3D=3D 0 &&
>
> Modified: head/sys/amd64/include/pmc_mdep.h
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/sys/amd64/include/pmc_mdep.h =A0 Wed Mar 28 20:49:11 2012 =A0 =
=A0 =A0 =A0(r233627)
> +++ head/sys/amd64/include/pmc_mdep.h =A0 Wed Mar 28 20:58:30 2012 =A0 =
=A0 =A0 =A0(r233628)
> @@ -50,13 +50,13 @@ struct pmc_mdep;
> =A0* measurement architecture have PMCs of the following classes: TSC,
> =A0* IAF, IAP, UCF and UCP.
> =A0*/
> -#define =A0 =A0 =A0 =A0PMC_MDEP_CLASS_INDEX_TSC =A0 =A0 =A0 =A00
> -#define =A0 =A0 =A0 =A0PMC_MDEP_CLASS_INDEX_K8 =A0 =A0 =A0 =A0 1
> -#define =A0 =A0 =A0 =A0PMC_MDEP_CLASS_INDEX_P4 =A0 =A0 =A0 =A0 1
> -#define =A0 =A0 =A0 =A0PMC_MDEP_CLASS_INDEX_IAP =A0 =A0 =A0 =A01
> -#define =A0 =A0 =A0 =A0PMC_MDEP_CLASS_INDEX_IAF =A0 =A0 =A0 =A02
> -#define =A0 =A0 =A0 =A0PMC_MDEP_CLASS_INDEX_UCP =A0 =A0 =A0 =A03
> -#define =A0 =A0 =A0 =A0PMC_MDEP_CLASS_INDEX_UCF =A0 =A0 =A0 =A04
> +#define =A0 =A0 =A0 =A0PMC_MDEP_CLASS_INDEX_TSC =A0 =A0 =A0 =A01
> +#define =A0 =A0 =A0 =A0PMC_MDEP_CLASS_INDEX_K8 =A0 =A0 =A0 =A0 2
> +#define =A0 =A0 =A0 =A0PMC_MDEP_CLASS_INDEX_P4 =A0 =A0 =A0 =A0 2
> +#define =A0 =A0 =A0 =A0PMC_MDEP_CLASS_INDEX_IAP =A0 =A0 =A0 =A02
> +#define =A0 =A0 =A0 =A0PMC_MDEP_CLASS_INDEX_IAF =A0 =A0 =A0 =A03
> +#define =A0 =A0 =A0 =A0PMC_MDEP_CLASS_INDEX_UCP =A0 =A0 =A0 =A04
> +#define =A0 =A0 =A0 =A0PMC_MDEP_CLASS_INDEX_UCF =A0 =A0 =A0 =A05
>
> =A0/*
> =A0* On the amd64 platform we support the following PMCs.
> @@ -119,6 +119,15 @@ union pmc_md_pmc {
>
> =A0#define =A0 =A0 =A0 =A0PMC_IN_USERSPACE(va) ((va) <=3D VM_MAXUSER_ADDR=
ESS)
>
> +/* Build a fake kernel trapframe from current instruction pointer. */
> +#define PMC_FAKE_TRAPFRAME(TF) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 \
> + =A0 =A0 =A0 do { =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0\
> + =A0 =A0 =A0 (TF)->tf_cs =3D 0; (TF)->tf_rflags =3D 0; =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 \
> + =A0 =A0 =A0 __asm __volatile("movq %%rbp,%0" : "=3Dr" ((TF)->tf_rbp)); =
=A0 =A0 =A0 =A0\
> + =A0 =A0 =A0 __asm __volatile("movq %%rsp,%0" : "=3Dr" ((TF)->tf_rsp)); =
=A0 =A0 =A0 =A0\
> + =A0 =A0 =A0 __asm __volatile("call 1f \n\t1: pop %0" : "=3Dr"((TF)->tf_=
rip)); \
> + =A0 =A0 =A0 } while (0)
> +
> =A0/*
> =A0* Prototypes
> =A0*/
>
> Modified: head/sys/arm/include/pmc_mdep.h
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/sys/arm/include/pmc_mdep.h =A0 =A0 Wed Mar 28 20:49:11 2012 =A0 =
=A0 =A0 =A0(r233627)
> +++ head/sys/arm/include/pmc_mdep.h =A0 =A0 Wed Mar 28 20:58:30 2012 =A0 =
=A0 =A0 =A0(r233628)
> @@ -29,7 +29,7 @@
> =A0#ifndef _MACHINE_PMC_MDEP_H_
> =A0#define =A0 =A0 =A0 =A0_MACHINE_PMC_MDEP_H_
>
> -#define =A0 =A0 =A0 =A0PMC_MDEP_CLASS_INDEX_XSCALE =A0 =A0 0
> +#define =A0 =A0 =A0 =A0PMC_MDEP_CLASS_INDEX_XSCALE =A0 =A0 1
> =A0/*
> =A0* On the ARM platform we support the following PMCs.
> =A0*
>
> Modified: head/sys/conf/files
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/sys/conf/files Wed Mar 28 20:49:11 2012 =A0 =A0 =A0 =A0(r233627)
> +++ head/sys/conf/files Wed Mar 28 20:58:30 2012 =A0 =A0 =A0 =A0(r233628)
> @@ -1260,6 +1260,7 @@ dev/hme/if_hme_sbus.c =A0 =A0 =A0 =A0 =A0 =A0 optio=
nal hme sbus
> =A0dev/hptiop/hptiop.c =A0 =A0 =A0 =A0 =A0 =A0optional hptiop scbus
> =A0dev/hwpmc/hwpmc_logging.c =A0 =A0 =A0optional hwpmc
> =A0dev/hwpmc/hwpmc_mod.c =A0 =A0 =A0 =A0 =A0optional hwpmc
> +dev/hwpmc/hwpmc_soft.c =A0 =A0 =A0 =A0 optional hwpmc
> =A0dev/ichsmb/ichsmb.c =A0 =A0 =A0 =A0 =A0 =A0optional ichsmb
> =A0dev/ichsmb/ichsmb_pci.c =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0optional ichsmb=
 pci
> =A0dev/ida/ida.c =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0optional ida
>
> Modified: head/sys/dev/hwpmc/hwpmc_amd.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/sys/dev/hwpmc/hwpmc_amd.c =A0 =A0 =A0Wed Mar 28 20:49:11 2012 =
=A0 =A0 =A0 =A0(r233627)
> +++ head/sys/dev/hwpmc/hwpmc_amd.c =A0 =A0 =A0Wed Mar 28 20:58:30 2012 =
=A0 =A0 =A0 =A0(r233628)
> @@ -687,7 +687,8 @@ amd_intr(int cpu, struct trapframe *tf)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0wrmsr(perfctr, AMD_RELOAD_COUNT_TO_PERFCTR=
_VALUE(v));
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* Restart the counter if logging succeede=
d. */
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 error =3D pmc_process_interrupt(cpu, pm, tf=
, TRAPF_USERMODE(tf));
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 error =3D pmc_process_interrupt(cpu, PMC_HR=
, pm, tf,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 TRAPF_USERMODE(tf));
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (error =3D=3D 0)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0wrmsr(evsel, config | AMD_=
PMC_ENABLE);
> =A0 =A0 =A0 =A0}
> @@ -874,7 +875,7 @@ amd_pcpu_fini(struct pmc_mdep *md, int c
> =A0struct pmc_mdep *
> =A0pmc_amd_initialize(void)
> =A0{
> - =A0 =A0 =A0 int classindex, error, i, nclasses, ncpus;
> + =A0 =A0 =A0 int classindex, error, i, ncpus;
> =A0 =A0 =A0 =A0struct pmc_classdep *pcd;
> =A0 =A0 =A0 =A0enum pmc_cputype cputype;
> =A0 =A0 =A0 =A0struct pmc_mdep *pmc_mdep;
> @@ -926,12 +927,9 @@ pmc_amd_initialize(void)
> =A0 =A0 =A0 =A0 * These processors have two classes of PMCs: the TSC and
> =A0 =A0 =A0 =A0 * programmable PMCs.
> =A0 =A0 =A0 =A0 */
> - =A0 =A0 =A0 nclasses =3D 2;
> - =A0 =A0 =A0 pmc_mdep =3D malloc(sizeof(struct pmc_mdep) + nclasses * si=
zeof (struct pmc_classdep),
> - =A0 =A0 =A0 =A0 =A0 M_PMC, M_WAITOK|M_ZERO);
> + =A0 =A0 =A0 pmc_mdep =3D pmc_mdep_alloc(2);
>
> =A0 =A0 =A0 =A0pmc_mdep->pmd_cputype =3D cputype;
> - =A0 =A0 =A0 pmc_mdep->pmd_nclass =A0=3D nclasses;
>
> =A0 =A0 =A0 =A0ncpus =3D pmc_cpu_max();
>
>
> Modified: head/sys/dev/hwpmc/hwpmc_core.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/sys/dev/hwpmc/hwpmc_core.c =A0 =A0 Wed Mar 28 20:49:11 2012 =A0 =
=A0 =A0 =A0(r233627)
> +++ head/sys/dev/hwpmc/hwpmc_core.c =A0 =A0 Wed Mar 28 20:58:30 2012 =A0 =
=A0 =A0 =A0(r233628)
> @@ -2239,7 +2239,7 @@ core_intr(int cpu, struct trapframe *tf)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (pm->pm_state !=3D PMC_STATE_RUNNING)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0continue;
>
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 error =3D pmc_process_interrupt(cpu, pm, tf=
,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 error =3D pmc_process_interrupt(cpu, PMC_HR=
, pm, tf,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0TRAPF_USERMODE(tf));
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0v =3D pm->pm_sc.pm_reloadcount;
> @@ -2326,7 +2326,7 @@ core2_intr(int cpu, struct trapframe *tf
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0!PMC_IS_SAMPLING_MODE(PMC_TO_MODE(=
pm)))
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0continue;
>
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 error =3D pmc_process_interrupt(cpu, pm, tf=
,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 error =3D pmc_process_interrupt(cpu, PMC_HR=
, pm, tf,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0TRAPF_USERMODE(tf));
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (error)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0intrenable &=3D ~flag;
> @@ -2354,7 +2354,7 @@ core2_intr(int cpu, struct trapframe *tf
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0!PMC_IS_SAMPLING_MODE(PMC_TO_MODE(=
pm)))
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0continue;
>
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 error =3D pmc_process_interrupt(cpu, pm, tf=
,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 error =3D pmc_process_interrupt(cpu, PMC_HR=
, pm, tf,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0TRAPF_USERMODE(tf));
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (error)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0intrenable &=3D ~flag;
>
> Modified: head/sys/dev/hwpmc/hwpmc_intel.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/sys/dev/hwpmc/hwpmc_intel.c =A0 =A0Wed Mar 28 20:49:11 2012 =A0 =
=A0 =A0 =A0(r233627)
> +++ head/sys/dev/hwpmc/hwpmc_intel.c =A0 =A0Wed Mar 28 20:58:30 2012 =A0 =
=A0 =A0 =A0(r233628)
> @@ -162,12 +162,10 @@ pmc_intel_initialize(void)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return (NULL);
> =A0 =A0 =A0 =A0}
>
> - =A0 =A0 =A0 pmc_mdep =3D malloc(sizeof(struct pmc_mdep) + nclasses *
> - =A0 =A0 =A0 =A0 =A0 sizeof(struct pmc_classdep), M_PMC, M_WAITOK|M_ZERO=
);
> + =A0 =A0 =A0 /* Allocate base class and initialize machine dependent str=
uct */
> + =A0 =A0 =A0 pmc_mdep =3D pmc_mdep_alloc(nclasses);
>
> =A0 =A0 =A0 =A0pmc_mdep->pmd_cputype =A0 =A0=3D cputype;
> - =A0 =A0 =A0 pmc_mdep->pmd_nclass =A0 =A0 =3D nclasses;
> -
> =A0 =A0 =A0 =A0pmc_mdep->pmd_switch_in =A0=3D intel_switch_in;
> =A0 =A0 =A0 =A0pmc_mdep->pmd_switch_out =3D intel_switch_out;
>
>
> Modified: head/sys/dev/hwpmc/hwpmc_logging.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/sys/dev/hwpmc/hwpmc_logging.c =A0Wed Mar 28 20:49:11 2012 =A0 =
=A0 =A0 =A0(r233627)
> +++ head/sys/dev/hwpmc/hwpmc_logging.c =A0Wed Mar 28 20:58:30 2012 =A0 =
=A0 =A0 =A0(r233628)
> @@ -129,6 +129,7 @@ static struct mtx pmc_kthread_mtx; =A0/* sl
>
> =A0/* Emit a string. =A0Caution: does NOT update _le, so needs to be last=
 */
> =A0#define =A0 =A0 =A0 =A0PMCLOG_EMITSTRING(S,L) =A0do { bcopy((S), _le, =
(L)); } while (0)
> +#define =A0 =A0 =A0 =A0PMCLOG_EMITNULLSTRING(L) do { bzero(_le, (L)); } =
while (0)
>
> =A0#define =A0 =A0 =A0 =A0PMCLOG_DESPATCH(PO) =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 \
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0pmclog_release((PO)); =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 \
> @@ -835,16 +836,33 @@ void
> =A0pmclog_process_pmcallocate(struct pmc *pm)
> =A0{
> =A0 =A0 =A0 =A0struct pmc_owner *po;
> + =A0 =A0 =A0 struct pmc_soft *ps;
>
> =A0 =A0 =A0 =A0po =3D pm->pm_owner;
>
> =A0 =A0 =A0 =A0PMCDBG(LOG,ALL,1, "pm=3D%p", pm);
>
> - =A0 =A0 =A0 PMCLOG_RESERVE(po, PMCALLOCATE, sizeof(struct pmclog_pmcall=
ocate));
> - =A0 =A0 =A0 PMCLOG_EMIT32(pm->pm_id);
> - =A0 =A0 =A0 PMCLOG_EMIT32(pm->pm_event);
> - =A0 =A0 =A0 PMCLOG_EMIT32(pm->pm_flags);
> - =A0 =A0 =A0 PMCLOG_DESPATCH(po);
> + =A0 =A0 =A0 if (PMC_TO_CLASS(pm) =3D=3D PMC_CLASS_SOFT) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 PMCLOG_RESERVE(po, PMCALLOCATEDYN,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 sizeof(struct pmclog_pmcallocatedyn=
));
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 PMCLOG_EMIT32(pm->pm_id);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 PMCLOG_EMIT32(pm->pm_event);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 PMCLOG_EMIT32(pm->pm_flags);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 ps =3D pmc_soft_ev_acquire(pm->pm_event);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (ps !=3D NULL)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 PMCLOG_EMITSTRING(ps->ps_ev=
.pm_ev_name,PMC_NAME_MAX);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 else
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 PMCLOG_EMITNULLSTRING(PMC_N=
AME_MAX);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pmc_soft_ev_release(ps);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 PMCLOG_DESPATCH(po);
> + =A0 =A0 =A0 } else {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 PMCLOG_RESERVE(po, PMCALLOCATE,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 sizeof(struct pmclog_pmcallocate));
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 PMCLOG_EMIT32(pm->pm_id);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 PMCLOG_EMIT32(pm->pm_event);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 PMCLOG_EMIT32(pm->pm_flags);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 PMCLOG_DESPATCH(po);
> + =A0 =A0 =A0 }
> =A0}
>
> =A0void
>
> Modified: head/sys/dev/hwpmc/hwpmc_mips.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/sys/dev/hwpmc/hwpmc_mips.c =A0 =A0 Wed Mar 28 20:49:11 2012 =A0 =
=A0 =A0 =A0(r233627)
> +++ head/sys/dev/hwpmc/hwpmc_mips.c =A0 =A0 Wed Mar 28 20:58:30 2012 =A0 =
=A0 =A0 =A0(r233628)
> @@ -287,7 +287,7 @@ mips_pmc_intr(int cpu, struct trapframe
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0retval =3D 1;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (pm->pm_state !=3D PMC_STATE_RUNNING)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0continue;
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 error =3D pmc_process_interrupt(cpu, pm, tf=
,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 error =3D pmc_process_interrupt(cpu, PMC_HR=
, pm, tf,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0TRAPF_USERMODE(tf));
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (error) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* Clear/disable the relev=
ant counter */
>
> Modified: head/sys/dev/hwpmc/hwpmc_mod.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/sys/dev/hwpmc/hwpmc_mod.c =A0 =A0 =A0Wed Mar 28 20:49:11 2012 =
=A0 =A0 =A0 =A0(r233627)
> +++ head/sys/dev/hwpmc/hwpmc_mod.c =A0 =A0 =A0Wed Mar 28 20:58:30 2012 =
=A0 =A0 =A0 =A0(r233628)
> @@ -70,6 +70,8 @@ __FBSDID("$FreeBSD$");
> =A0#include <vm/vm_map.h>
> =A0#include <vm/vm_object.h>
>
> +#include "hwpmc_soft.h"
> +
> =A0/*
> =A0* Types
> =A0*/
> @@ -182,7 +184,7 @@ static int =A0pmc_attach_one_process(struct
> =A0static int =A0 =A0 pmc_can_allocate_rowindex(struct proc *p, unsigned =
int ri,
> =A0 =A0 int cpu);
> =A0static int =A0 =A0 pmc_can_attach(struct pmc *pm, struct proc *p);
> -static void =A0 =A0pmc_capture_user_callchain(int cpu, struct trapframe =
*tf);
> +static void =A0 =A0pmc_capture_user_callchain(int cpu, int soft, struct =
trapframe *tf);
> =A0static void =A0 =A0pmc_cleanup(void);
> =A0static int =A0 =A0 pmc_detach_process(struct proc *p, struct pmc *pm);
> =A0static int =A0 =A0 pmc_detach_one_process(struct proc *p, struct pmc *=
pm,
> @@ -206,7 +208,7 @@ static void pmc_process_csw_out(struct t
> =A0static void =A0 =A0pmc_process_exit(void *arg, struct proc *p);
> =A0static void =A0 =A0pmc_process_fork(void *arg, struct proc *p1,
> =A0 =A0 struct proc *p2, int n);
> -static void =A0 =A0pmc_process_samples(int cpu);
> +static void =A0 =A0pmc_process_samples(int cpu, int soft);
> =A0static void =A0 =A0pmc_release_pmc_descriptor(struct pmc *pmc);
> =A0static void =A0 =A0pmc_remove_owner(struct pmc_owner *po);
> =A0static void =A0 =A0pmc_remove_process_descriptor(struct pmc_process *p=
p);
> @@ -218,12 +220,16 @@ static int =A0 =A0 =A0 =A0pmc_stop(struct pmc *pm);
> =A0static int =A0 =A0 pmc_syscall_handler(struct thread *td, void *syscal=
l_args);
> =A0static void =A0 =A0pmc_unlink_target_process(struct pmc *pmc,
> =A0 =A0 struct pmc_process *pp);
> +static int generic_switch_in(struct pmc_cpu *pc, struct pmc_process *pp)=
;
> +static int generic_switch_out(struct pmc_cpu *pc, struct pmc_process *pp=
);
> +static struct pmc_mdep *pmc_generic_cpu_initialize(void);
> +static void pmc_generic_cpu_finalize(struct pmc_mdep *md);
>
> =A0/*
> =A0* Kernel tunables and sysctl(8) interface.
> =A0*/
>
> -SYSCTL_NODE(_kern, OID_AUTO, hwpmc, CTLFLAG_RW, 0, "HWPMC parameters");
> +SYSCTL_DECL(_kern_hwpmc);
>
> =A0static int pmc_callchaindepth =3D PMC_CALLCHAIN_DEPTH;
> =A0TUNABLE_INT(PMC_SYSCTL_NAME_PREFIX "callchaindepth", &pmc_callchaindep=
th);
> @@ -1833,7 +1839,9 @@ const char *pmc_hooknames[] =3D {
> =A0 =A0 =A0 =A0"KLDUNLOAD",
> =A0 =A0 =A0 =A0"MMAP",
> =A0 =A0 =A0 =A0"MUNMAP",
> - =A0 =A0 =A0 "CALLCHAIN"
> + =A0 =A0 =A0 "CALLCHAIN-NMI",
> + =A0 =A0 =A0 "CALLCHAIN-SOFT",
> + =A0 =A0 =A0 "SOFTSAMPLING"
> =A0};
> =A0#endif
>
> @@ -1992,7 +2000,8 @@ pmc_hook_handler(struct thread *td, int
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 * lose the interrupt sample.
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 */
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0CPU_CLR_ATOMIC(PCPU_GET(cpuid), &pmc_cpuma=
sk);
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 pmc_process_samples(PCPU_GET(cpuid));
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pmc_process_samples(PCPU_GET(cpuid), PMC_HR=
);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pmc_process_samples(PCPU_GET(cpuid), PMC_SR=
);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break;
>
>
> @@ -2022,11 +2031,30 @@ pmc_hook_handler(struct thread *td, int
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 */
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0KASSERT(td =3D=3D curthread, ("[pmc,%d] td=
 !=3D curthread",
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0__LINE__));
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 pmc_capture_user_callchain(PCPU_GET(cpuid),
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pmc_capture_user_callchain(PCPU_GET(cpuid),=
 PMC_HR,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(struct trapframe *) arg);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0td->td_pflags &=3D ~TDP_CALLCHAIN;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break;
>
> + =A0 =A0 =A0 case PMC_FN_USER_CALLCHAIN_SOFT:
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /*
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* Record a call chain.
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0*/
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 KASSERT(td =3D=3D curthread, ("[pmc,%d] td =
!=3D curthread",
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 __LINE__));
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pmc_capture_user_callchain(PCPU_GET(cpuid),=
 PMC_SR,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (struct trapframe *) arg);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 td->td_pflags &=3D ~TDP_CALLCHAIN;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 break;
> +
> + =A0 =A0 =A0 case PMC_FN_SOFT_SAMPLING:
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /*
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* Call soft PMC sampling intr.
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0*/
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pmc_soft_intr((struct pmckern_soft *) arg);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 break;
> +
> =A0 =A0 =A0 =A0default:
> =A0#ifdef DEBUG
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0KASSERT(0, ("[pmc,%d] unknown hook %d\n", =
__LINE__, function));
> @@ -2221,18 +2249,17 @@ pmc_destroy_pmc_descriptor(struct pmc *p
> =A0static void
> =A0pmc_wait_for_pmc_idle(struct pmc *pm)
> =A0{
> -#ifdef DEBUG
> +#ifdef DEBUG
> =A0 =A0 =A0 =A0volatile int maxloop;
>
> =A0 =A0 =A0 =A0maxloop =3D 100 * pmc_cpu_max();
> =A0#endif
> -
> =A0 =A0 =A0 =A0/*
> =A0 =A0 =A0 =A0 * Loop (with a forced context switch) till the PMC's runc=
ount
> =A0 =A0 =A0 =A0 * comes down to zero.
> =A0 =A0 =A0 =A0 */
> =A0 =A0 =A0 =A0while (atomic_load_acq_32(&pm->pm_runcount) > 0) {
> -#ifdef DEBUG
> +#ifdef DEBUG
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0maxloop--;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0KASSERT(maxloop > 0,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0("[pmc,%d] (ri%d, rc%d) waiting to=
o long for "
> @@ -2972,6 +2999,53 @@ pmc_syscall_handler(struct thread *td, v
> =A0 =A0 =A0 =A0}
> =A0 =A0 =A0 =A0break;
>
> + =A0 =A0 =A0 /*
> + =A0 =A0 =A0 =A0* Retrieve soft events list.
> + =A0 =A0 =A0 =A0*/
> + =A0 =A0 =A0 case PMC_OP_GETDYNEVENTINFO:
> + =A0 =A0 =A0 {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 enum pmc_class =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0cl;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 enum pmc_event =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0ev;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct pmc_op_getdyneventinfo =A0 *gei;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct pmc_dyn_event_descr =A0 =A0 =A0dev;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct pmc_soft =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 *ps;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 uint32_t =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0nevent;
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 sx_assert(&pmc_sx, SX_LOCKED);
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 gei =3D (struct pmc_op_getdyneventinfo *) a=
rg;
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if ((error =3D copyin(&gei->pm_class, &cl, =
sizeof(cl))) !=3D 0)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break;
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Only SOFT class is dynamic. */
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (cl !=3D PMC_CLASS_SOFT) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 error =3D EINVAL;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 nevent =3D 0;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 for (ev =3D PMC_EV_SOFT_FIRST; ev <=3D PMC_=
EV_SOFT_LAST; ev++) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ps =3D pmc_soft_ev_acquire(=
ev);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (ps =3D=3D NULL)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 continue;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 bcopy(&ps->ps_ev, &dev, siz=
eof(dev));
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pmc_soft_ev_release(ps);
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 error =3D copyout(&dev,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 &gei->pm_events[nev=
ent],
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 sizeof(struct pmc_d=
yn_event_descr));
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (error !=3D 0)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 nevent++;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (error !=3D 0)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break;
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 error =3D copyout(&nevent, &gei->pm_nevent,
>
> *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



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