Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Apr 2023 15:06:38 -0500
From:      Kyle Evans <kevans@freebsd.org>
To:        Alexander Motin <mav@freebsd.org>
Cc:        src-committers@freebsd.org, dev-commits-src-all@freebsd.org,  dev-commits-src-main@freebsd.org,  "Sideropoulos, Alexander" <alexander.sideropoulos@netapp.com>
Subject:   Re: git: c1e813d12309 - main - hwpmc: Correct selection of Intel fixed counters.
Message-ID:  <CACNAnaGyE6GunLMN-KNtuVPAMC7MNeRQU1uonaXBnyk_FdCFUw@mail.gmail.com>
In-Reply-To: <202205310005.24V05MTi034088@gitrepo.freebsd.org>
References:  <202205310005.24V05MTi034088@gitrepo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, May 30, 2022 at 7:05=E2=80=AFPM Alexander Motin <mav@freebsd.org> w=
rote:
>
> The branch main has been updated by mav:
>
> URL: https://cgit.FreeBSD.org/src/commit/?id=3Dc1e813d1230915e19a236ec687=
cadc1051841e56
>
> commit c1e813d1230915e19a236ec687cadc1051841e56
> Author:     Alexander Motin <mav@FreeBSD.org>
> AuthorDate: 2022-05-30 23:46:48 +0000
> Commit:     Alexander Motin <mav@FreeBSD.org>
> CommitDate: 2022-05-31 00:05:15 +0000
>
>     hwpmc: Correct selection of Intel fixed counters.
>
>     Intel json's use event=3D0 to specify fixed counter number via umask.
>     Alternatively fixed counters have equivalent programmable event/umask=
.
>
>     MFC after:      1 month
> ---
>  sys/dev/hwpmc/hwpmc_core.c | 34 +++++++++++++++++++++++++---------
>  1 file changed, 25 insertions(+), 9 deletions(-)
>
> diff --git a/sys/dev/hwpmc/hwpmc_core.c b/sys/dev/hwpmc/hwpmc_core.c
> index fce97cbd5b8e..73cfee0b3975 100644
> --- a/sys/dev/hwpmc/hwpmc_core.c
> +++ b/sys/dev/hwpmc/hwpmc_core.c
> @@ -245,15 +245,31 @@ iaf_allocate_pmc(int cpu, int ri, struct pmc *pm,
>         ev =3D IAP_EVSEL_GET(config);
>         umask =3D IAP_UMASK_GET(config);
>
> -       /* INST_RETIRED.ANY */
> -       if (ev =3D=3D 0xC0 && ri !=3D 0)
> -               return (EINVAL);
> -       /* CPU_CLK_UNHALTED.THREAD */
> -       if (ev =3D=3D 0x3C && ri !=3D 1)
> -               return (EINVAL);
> -       /* CPU_CLK_UNHALTED.REF */
> -       if (ev =3D=3D 0x0 && umask =3D=3D 0x3 && ri !=3D 2)
> -               return (EINVAL);
> +       if (ev =3D=3D 0x0) {
> +               if (umask !=3D ri + 1)
> +                       return (EINVAL);

Hey Alexander,

This seems to break system-mode sampling of fixed-mode counters; e.g.,
from the manpage, `pmcstat -S instructions`, and I'm not at all
familiar with these parts of pmc. We come in once with umask=3D1, ri=3D0;
then again with umask=3D1, ri=3D1. The latter fails and we try umask=3D1,
ri=3D2, which again fails, and the PMCALLOCATE op ultimately fails.

Is `umask !=3D ri + 1` correct, or should this be reverted back to
`umask =3D=3D 0x3 && ri !=3D 2` or something else? I've no idea what the
`umask` values represent in this context.

Thanks,

Kyle Evans



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