opnsense-src/cddl
Mark Johnston 0ae0226cd1 libdtrace: Fix an off-by-one in CPU ID handling
The illumos-specific _SC_CPUID_MAX is the largest CPU ID in the system.  This
was mapped to _SC_NPROCESSORS_CONF, which is the total number of CPUs recognized
by the kernel.  If CPU IDs are contiguous, as is the case on amd64 and arm64,
this value is one greater than the maximum ID.   As a result, when consuming
per-CPU dtrace buffers, libdtrace tries to fetch from a non-existent CPU.  This
is mostly harmless in practice, but still wrong.

As we don't have a sysconf value for the maximum CPU ID, add a wrapper which
fetches it using the kern.smp.maxid sysctl.

MFC after:	2 weeks
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D49243

(cherry picked from commit 9a30c8d347bf9aaa89277b6e5a275f737be8edce)
2025-04-02 15:14:37 +00:00
..
compat/opensolaris Remove $FreeBSD$: one-line .c comment pattern 2023-08-16 11:54:29 -06:00
contrib/opensolaris libdtrace: Fix an off-by-one in CPU ID handling 2025-04-02 15:14:37 +00:00
lib zfs: merge openzfs/zfs@e269af1b3 (zfs-2.2-release) into stable/14 2024-12-12 13:22:56 +01:00
sbin zfs: merge openzfs/zfs@e269af1b3 (zfs-2.2-release) into stable/14 2024-12-12 13:22:56 +01:00
share zfs: merge openzfs/zfs@e269af1b3 (zfs-2.2-release) into stable/14 2024-12-12 13:22:56 +01:00
tests Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
usr.bin zfs: merge openzfs/zfs@e269af1b3 (zfs-2.2-release) into stable/14 2024-12-12 13:22:56 +01:00
usr.libexec zfs: merge openzfs/zfs@55dd24c4c (zfs-2.2-release) into stable/14 2023-11-22 12:43:59 +01:00
usr.sbin dtrace tests: Fix the ATF config variable name 2025-01-30 15:23:05 +00:00
Makefile Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
Makefile.inc Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00