<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src/sys/dev/hwpmc, branch stable/14</title>
<subtitle>FreeBSD source tree</subtitle>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/'/>
<entry>
<title>pmc: Import Intel Granite Rapids events</title>
<updated>2026-02-06T15:19:30+00:00</updated>
<author>
<name>Bojan Novković</name>
<email>bnovkov@FreeBSD.org</email>
</author>
<published>2026-02-02T10:13:12+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=625ed651833e76a439a7010aa28c93bc83013168'/>
<id>625ed651833e76a439a7010aa28c93bc83013168</id>
<content type='text'>
Reviewed by:	mhorne
Sponsored by:	Klara, Inc.
Obtained from:	Intel perfmon (JSON event definitions)
Differential Revision:	https://reviews.freebsd.org/D55081
MFC after:	2 days

(cherry picked from commit a3ff85e11925ba1e25465c8ba633356f405f9214)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Reviewed by:	mhorne
Sponsored by:	Klara, Inc.
Obtained from:	Intel perfmon (JSON event definitions)
Differential Revision:	https://reviews.freebsd.org/D55081
MFC after:	2 days

(cherry picked from commit a3ff85e11925ba1e25465c8ba633356f405f9214)
</pre>
</div>
</content>
</entry>
<entry>
<title>pmc: add alderlaken model</title>
<updated>2025-12-11T20:24:29+00:00</updated>
<author>
<name>Anaëlle CAZUC</name>
<email>Anaelle.CAZUC@stormshield.eu</email>
</author>
<published>2025-12-04T17:52:23+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=e56189d4436b91c2ccf915774cb2eef53c8eca0e'/>
<id>e56189d4436b91c2ccf915774cb2eef53c8eca0e</id>
<content type='text'>
This commit adds alderlaken CPU model to hwpmc/libpmc. JSON event
definitions are imported from Intel perfmon version 1.16.

Reviewed by:	mhorne
MFC after:	1 week
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D49229

(cherry picked from commit ca3e47b0ea68664c7e10e1c3e28c5ac7d9932c21)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This commit adds alderlaken CPU model to hwpmc/libpmc. JSON event
definitions are imported from Intel perfmon version 1.16.

Reviewed by:	mhorne
MFC after:	1 week
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D49229

(cherry picked from commit ca3e47b0ea68664c7e10e1c3e28c5ac7d9932c21)
</pre>
</div>
</content>
</entry>
<entry>
<title>pmc: add emerald rapids model</title>
<updated>2025-12-11T20:24:29+00:00</updated>
<author>
<name>Anaëlle CAZUC</name>
<email>Anaelle.CAZUC@stormshield.eu</email>
</author>
<published>2025-12-04T17:36:32+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=f7129ef918b77596536107e5687a14907bda07c1'/>
<id>f7129ef918b77596536107e5687a14907bda07c1</id>
<content type='text'>
This commit adds emerald rapids CPU model to hwpmc/libpmc. JSON event
definitions are imported from Intel perfmon version 1.06.

Reviewed by:	mhorne
MFC after:	1 week
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D49228

(cherry picked from commit 51a01f3debff8abf63c7cc21db9523c8feb53823)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This commit adds emerald rapids CPU model to hwpmc/libpmc. JSON event
definitions are imported from Intel perfmon version 1.06.

Reviewed by:	mhorne
MFC after:	1 week
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D49228

(cherry picked from commit 51a01f3debff8abf63c7cc21db9523c8feb53823)
</pre>
</div>
</content>
</entry>
<entry>
<title>pmc: add alderlake model</title>
<updated>2025-12-11T20:24:29+00:00</updated>
<author>
<name>Anaëlle CAZUC</name>
<email>Anaelle.CAZUC@stormshield.eu</email>
</author>
<published>2025-12-04T17:32:39+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=2635037db7702ddad40d3349bd7a56e54408fced'/>
<id>2635037db7702ddad40d3349bd7a56e54408fced</id>
<content type='text'>
The commit 601925180df4 added the models 6-B7, 6-BA, 6-BF to libpmc, but
they must also be added to the hwpmc module to allow pmc to work on
those CPUs.

Reviewed by:	mhorne
MFC after:	1 week
Fixes:		601925180df4 ("libpmc: add more alderlake models")
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D49255

(cherry picked from commit 057dae35ffc6b17dacc84fa21921e93a17ce12b0)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The commit 601925180df4 added the models 6-B7, 6-BA, 6-BF to libpmc, but
they must also be added to the hwpmc module to allow pmc to work on
those CPUs.

Reviewed by:	mhorne
MFC after:	1 week
Fixes:		601925180df4 ("libpmc: add more alderlake models")
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D49255

(cherry picked from commit 057dae35ffc6b17dacc84fa21921e93a17ce12b0)
</pre>
</div>
</content>
</entry>
<entry>
<title>hwpmc: On attach, fix allowing a PMC's owner to attach it to itself</title>
<updated>2025-09-18T10:13:10+00:00</updated>
<author>
<name>Olivier Certner</name>
<email>olce@FreeBSD.org</email>
</author>
<published>2025-09-09T12:48:05+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=009268dbfdd5fe487117654f75ae3850a2c1a7d9'/>
<id>009268dbfdd5fe487117654f75ae3850a2c1a7d9</id>
<content type='text'>
The returned value in this case was wrong, and would basically prevent
some PMC's owner process to attach that PMC to itself although the
security checks underneath would have allowed it.

Now that this early return has been fixed, its block basically becomes
a performance short-circuit which has no effect from a functional
standpoint.

Fixes:          ebccf1e3a6b1 ("Bring a working snapshot of hwpmc(4), ...")
MFC after:      9 days
Sponsored by:   The FreeBSD Foundation

(cherry picked from commit 1c40b15971f09c0c0676ae476b88b32166eae8ac)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The returned value in this case was wrong, and would basically prevent
some PMC's owner process to attach that PMC to itself although the
security checks underneath would have allowed it.

Now that this early return has been fixed, its block basically becomes
a performance short-circuit which has no effect from a functional
standpoint.

Fixes:          ebccf1e3a6b1 ("Bring a working snapshot of hwpmc(4), ...")
MFC after:      9 days
Sponsored by:   The FreeBSD Foundation

(cherry picked from commit 1c40b15971f09c0c0676ae476b88b32166eae8ac)
</pre>
</div>
</content>
</entry>
<entry>
<title>hwpmc: On attach, ensure owner is a target effective GID's member</title>
<updated>2025-09-18T10:13:05+00:00</updated>
<author>
<name>Olivier Certner</name>
<email>olce@FreeBSD.org</email>
</author>
<published>2025-08-26T09:43:38+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=59a73e9a1fe33517393a18ff958ef8d05f550a56'/>
<id>59a73e9a1fe33517393a18ff958ef8d05f550a56</id>
<content type='text'>
This restores a check that existed prior to commit be1f7435ef218b1d
("kern: start tracking cr_gid outside of cr_groups[]").

While here, improve pmc_can_attach()'s style by changing the type of
'decline_attach' to 'bool', fixing tests on it, adding missing
parentheses to 'return' statements, and by changing its return value
type to 'bool'.

Fixes:          be1f7435ef218b1d ("kern: start tracking cr_gid outside of cr_groups[]")
MFC after:      9 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D52252

(cherry picked from commit 1c3c698ba4c40485ebbbd157cb49172cfa7de9b2)

MFC to 14 does not fix any bug, but just applies some style changes
needed by next MFC.

In pmc_can_attach(): Start index of the loop on groups was changed to
1 in order to avoid a (harmless) duplicated groupmember() call with
'tc-&gt;cr_gid', which in 14 is still an alias of 'tc-&gt;cr_groups[0]'.  We
chose to MFC the addition of that latter call to minimize differences
with what is in -CURRENT and 15.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This restores a check that existed prior to commit be1f7435ef218b1d
("kern: start tracking cr_gid outside of cr_groups[]").

While here, improve pmc_can_attach()'s style by changing the type of
'decline_attach' to 'bool', fixing tests on it, adding missing
parentheses to 'return' statements, and by changing its return value
type to 'bool'.

Fixes:          be1f7435ef218b1d ("kern: start tracking cr_gid outside of cr_groups[]")
MFC after:      9 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D52252

(cherry picked from commit 1c3c698ba4c40485ebbbd157cb49172cfa7de9b2)

MFC to 14 does not fix any bug, but just applies some style changes
needed by next MFC.

In pmc_can_attach(): Start index of the loop on groups was changed to
1 in order to avoid a (harmless) duplicated groupmember() call with
'tc-&gt;cr_gid', which in 14 is still an alias of 'tc-&gt;cr_groups[0]'.  We
chose to MFC the addition of that latter call to minimize differences
with what is in -CURRENT and 15.
</pre>
</div>
</content>
</entry>
<entry>
<title>hwpmc: Restore line lost in previous commit</title>
<updated>2024-12-01T00:56:10+00:00</updated>
<author>
<name>Alexander Motin</name>
<email>mav@FreeBSD.org</email>
</author>
<published>2024-11-28T16:53:24+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=7589f9bb7555c0f84eed9df6f1964082e6ff2698'/>
<id>7589f9bb7555c0f84eed9df6f1964082e6ff2698</id>
<content type='text'>
MFC after:	3 days

(cherry picked from commit de852d78ff58643d91bb672571757ef73ca74c39)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
MFC after:	3 days

(cherry picked from commit de852d78ff58643d91bb672571757ef73ca74c39)
</pre>
</div>
</content>
</entry>
<entry>
<title>hwpmc: Fix whitespace in logging macros</title>
<updated>2024-11-28T14:38:17+00:00</updated>
<author>
<name>Mark Johnston</name>
<email>markj@FreeBSD.org</email>
</author>
<published>2024-11-19T23:48:53+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=ee0c917eeb0dfd2cc74b487cac6374a5892bc4d2'/>
<id>ee0c917eeb0dfd2cc74b487cac6374a5892bc4d2</id>
<content type='text'>
MFC after:	1 week
Sponsored by:	Klara, Inc.

(cherry picked from commit 3c29734502c330fc8f8e345213791722aeaf55c1)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
MFC after:	1 week
Sponsored by:	Klara, Inc.

(cherry picked from commit 3c29734502c330fc8f8e345213791722aeaf55c1)
</pre>
</div>
</content>
</entry>
<entry>
<title>dev/hwpmc: Fix the dmc620 MD4 macro</title>
<updated>2024-07-15T12:27:45+00:00</updated>
<author>
<name>Andrew Turner</name>
<email>andrew@FreeBSD.org</email>
</author>
<published>2024-05-22T08:19:49+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=dfd26e29dd43e4370ba31159c57fa474ef6e995b'/>
<id>dfd26e29dd43e4370ba31159c57fa474ef6e995b</id>
<content type='text'>
Add braces to the dmc620 MD4 macro to fix the GCC build.

Reviewed by:	brooks, imp, jhb
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45266

(cherry picked from commit 131c1718c6331e87f139b42b4ad0e57b6a71ea44)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add braces to the dmc620 MD4 macro to fix the GCC build.

Reviewed by:	brooks, imp, jhb
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45266

(cherry picked from commit 131c1718c6331e87f139b42b4ad0e57b6a71ea44)
</pre>
</div>
</content>
</entry>
<entry>
<title>pmc: better distinguish pmu-events allocation path</title>
<updated>2023-09-11T19:19:58+00:00</updated>
<author>
<name>Mitchell Horne</name>
<email>mhorne@FreeBSD.org</email>
</author>
<published>2023-06-06T17:26:46+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=5adb91c72985b840b2c7fbf3c3308619acd2b61a'/>
<id>5adb91c72985b840b2c7fbf3c3308619acd2b61a</id>
<content type='text'>
Background:

The pm_ev field of struct pmc_op_pmcallocate and struct pmc
traditionally contains the index of the chosen event, corresponding to
the __PMC_EVENTS array in pmc_events.h. This is a static list of events,
maintained by FreeBSD.

In the usual case, libpmc translates the user supplied event name
(string) into the pm_ev index, which is passed as an argument to the
allocation syscall. On the kernel side, the allocation method for the
relevant hwpmc class translates the given index into the event code that
will be written to an event selection register.

In 2018, a new source of performance event definitions was introduced:
the pmu-events json files, which are maintained by the Linux kernel. The
result was better coverage for newer Intel processors with a reduced
maintenance burden for libpmc/hwpmc. Intel and AMD CPUs were
unconditionally switched to allocate events from pmu-events instead of
the traditional scheme (959826ca1bb0a, 81eb4dcf9e0d).

Under the pmu-events scheme, the pm_ev field contains an index
corresponding to the selected event from the pmu-events table, something
which the kernel has no knowledge of. The configuration for the
performance counting registers is instead passed via class-dependent
fields (struct pmc_md_op_pmcallocate).

In 2021 I changed the allocation logic so that it would attempt to
pull from the pmu-events table first, and fall-back to the traditional
method (dfb4fb41166bc3). Later, pmu-events support for arm64 and power8
CPUs was added (28dd6730a5d6 and b48a2770d48b).

The problem that remains is that the pm_ev field is overloaded, without
a definitive way to determine whether the event allocation came from the
pmu-events table or FreeBSD's statically-defined PMC events. This
resulted in a recent fix, 21f7397a61f7.

Change:

To disambiguate these two supported but separate use-cases, add a new
flag, PMC_F_EV_PMU, to be set as part of the allocation, indicating that
the event index came from pmu-events.

This is useful in two ways:
 1. On the kernel side, we can validate the syscall arguments better.
    Some classes support only the traditional event scheme (e.g.
    hwpmc_armv7), while others support only the pmu-events method (e.g.
    hwpmc_core for Intel). We can now check for this. The hwpmc_arm64
    class supports both methods, so the new flag supersedes the existing
    MD flag, PM_MD_EVENT_RAW.

 2. The flag will be tracked in struct pmc for the duration of its
    lifetime, meaning it is communicated back to userspace. This allows
    libpmc to perform the reverse index-to-event-name translation
    without speculating about the meaning of the index value.

Adding the flag is a backwards-incompatible ABI change. We recently
bumped the major version of the hwpmc module, so this breakage is
acceptable.

Reviewed by:	jkoshy
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40753

(cherry picked from commit c190fb35f35cc163b61e582a49115680b0d49dcc)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Background:

The pm_ev field of struct pmc_op_pmcallocate and struct pmc
traditionally contains the index of the chosen event, corresponding to
the __PMC_EVENTS array in pmc_events.h. This is a static list of events,
maintained by FreeBSD.

In the usual case, libpmc translates the user supplied event name
(string) into the pm_ev index, which is passed as an argument to the
allocation syscall. On the kernel side, the allocation method for the
relevant hwpmc class translates the given index into the event code that
will be written to an event selection register.

In 2018, a new source of performance event definitions was introduced:
the pmu-events json files, which are maintained by the Linux kernel. The
result was better coverage for newer Intel processors with a reduced
maintenance burden for libpmc/hwpmc. Intel and AMD CPUs were
unconditionally switched to allocate events from pmu-events instead of
the traditional scheme (959826ca1bb0a, 81eb4dcf9e0d).

Under the pmu-events scheme, the pm_ev field contains an index
corresponding to the selected event from the pmu-events table, something
which the kernel has no knowledge of. The configuration for the
performance counting registers is instead passed via class-dependent
fields (struct pmc_md_op_pmcallocate).

In 2021 I changed the allocation logic so that it would attempt to
pull from the pmu-events table first, and fall-back to the traditional
method (dfb4fb41166bc3). Later, pmu-events support for arm64 and power8
CPUs was added (28dd6730a5d6 and b48a2770d48b).

The problem that remains is that the pm_ev field is overloaded, without
a definitive way to determine whether the event allocation came from the
pmu-events table or FreeBSD's statically-defined PMC events. This
resulted in a recent fix, 21f7397a61f7.

Change:

To disambiguate these two supported but separate use-cases, add a new
flag, PMC_F_EV_PMU, to be set as part of the allocation, indicating that
the event index came from pmu-events.

This is useful in two ways:
 1. On the kernel side, we can validate the syscall arguments better.
    Some classes support only the traditional event scheme (e.g.
    hwpmc_armv7), while others support only the pmu-events method (e.g.
    hwpmc_core for Intel). We can now check for this. The hwpmc_arm64
    class supports both methods, so the new flag supersedes the existing
    MD flag, PM_MD_EVENT_RAW.

 2. The flag will be tracked in struct pmc for the duration of its
    lifetime, meaning it is communicated back to userspace. This allows
    libpmc to perform the reverse index-to-event-name translation
    without speculating about the meaning of the index value.

Adding the flag is a backwards-incompatible ABI change. We recently
bumped the major version of the hwpmc module, so this breakage is
acceptable.

Reviewed by:	jkoshy
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40753

(cherry picked from commit c190fb35f35cc163b61e582a49115680b0d49dcc)
</pre>
</div>
</content>
</entry>
</feed>
