1*2fc1284fSAndy Fiddaman.\" 2*2fc1284fSAndy Fiddaman.\" This file and its contents are supplied under the terms of the 3*2fc1284fSAndy Fiddaman.\" Common Development and Distribution License ("CDDL"), version 1.0. 4*2fc1284fSAndy Fiddaman.\" You may only use this file in accordance with the terms of version 5*2fc1284fSAndy Fiddaman.\" 1.0 of the CDDL. 6*2fc1284fSAndy Fiddaman.\" 7*2fc1284fSAndy Fiddaman.\" A full copy of the text of the CDDL should have accompanied this 8*2fc1284fSAndy Fiddaman.\" source. A copy of the CDDL is also available via the Internet at 9*2fc1284fSAndy Fiddaman.\" http://www.illumos.org/license/CDDL. 10*2fc1284fSAndy Fiddaman.\" 11*2fc1284fSAndy Fiddaman.\" 12*2fc1284fSAndy Fiddaman.\" Copyright 2026 Oxide Computer Company 13*2fc1284fSAndy Fiddaman.\" 14*2fc1284fSAndy Fiddaman.Dd August 4, 2026 15*2fc1284fSAndy Fiddaman.Dt DDI_NCPUS_EXPECTED 9F 16*2fc1284fSAndy Fiddaman.Os 17*2fc1284fSAndy Fiddaman.Sh NAME 18*2fc1284fSAndy Fiddaman.Nm ddi_ncpus_expected 19*2fc1284fSAndy Fiddaman.Nd obtain the expected number of CPUs in the system 20*2fc1284fSAndy Fiddaman.Sh SYNOPSIS 21*2fc1284fSAndy Fiddaman.In sys/sunddi.h 22*2fc1284fSAndy Fiddaman.Ft uint_t 23*2fc1284fSAndy Fiddaman.Fo ddi_ncpus_expected 24*2fc1284fSAndy Fiddaman.Fa void 25*2fc1284fSAndy Fiddaman.Fc 26*2fc1284fSAndy Fiddaman.Sh INTERFACE LEVEL 27*2fc1284fSAndy Fiddamanillumos DDI specific 28*2fc1284fSAndy Fiddaman.Pq illumos DDI . 29*2fc1284fSAndy Fiddaman.Sh DESCRIPTION 30*2fc1284fSAndy FiddamanThe 31*2fc1284fSAndy Fiddaman.Fn ddi_ncpus_expected 32*2fc1284fSAndy Fiddamanfunction returns the number of CPUs that the system is expected to have 33*2fc1284fSAndy Fiddamanonce it has finished booting. 34*2fc1284fSAndy Fiddaman.Pp 35*2fc1284fSAndy FiddamanDevice drivers commonly size resources such as interrupt vectors, queues, 36*2fc1284fSAndy Fiddamanand worker threads based on the number of CPUs in the system. 37*2fc1284fSAndy FiddamanA driver that attaches while the system is booting, such as the driver for 38*2fc1284fSAndy Fiddamana boot device, may attach before the additional processors have been 39*2fc1284fSAndy Fiddamanstarted, at a time when only the boot processor is running. 40*2fc1284fSAndy FiddamanCounting the running CPUs at that point would size such resources for a 41*2fc1284fSAndy Fiddamansingle CPU. 42*2fc1284fSAndy FiddamanWhile only the boot processor is running, the 43*2fc1284fSAndy Fiddaman.Fn ddi_ncpus_expected 44*2fc1284fSAndy Fiddamanfunction therefore returns the number of processors that the system is 45*2fc1284fSAndy Fiddamanexpected to start during boot. 46*2fc1284fSAndy FiddamanOnce further processors are running, it returns the number of CPUs that 47*2fc1284fSAndy Fiddamanare present. 48*2fc1284fSAndy Fiddaman.Pp 49*2fc1284fSAndy FiddamanThe returned value is an estimate that is intended for sizing purposes. 50*2fc1284fSAndy FiddamanThe number of CPUs that are present can change over the lifetime of the 51*2fc1284fSAndy Fiddamansystem 52*2fc1284fSAndy Fiddaman.Pq for example, through processor hotplug , 53*2fc1284fSAndy Fiddamanand not every CPU that is present is necessarily online. 54*2fc1284fSAndy Fiddaman.Sh CONTEXT 55*2fc1284fSAndy FiddamanThe 56*2fc1284fSAndy Fiddaman.Fn ddi_ncpus_expected 57*2fc1284fSAndy Fiddamanfunction may be called from 58*2fc1284fSAndy Fiddaman.Sy user , 59*2fc1284fSAndy Fiddaman.Sy kernel , 60*2fc1284fSAndy Fiddamanor 61*2fc1284fSAndy Fiddaman.Sy interrupt 62*2fc1284fSAndy Fiddamancontext. 63*2fc1284fSAndy Fiddaman.Sh RETURN VALUES 64*2fc1284fSAndy FiddamanThe 65*2fc1284fSAndy Fiddaman.Fn ddi_ncpus_expected 66*2fc1284fSAndy Fiddamanfunction always succeeds. 67*2fc1284fSAndy FiddamanIt returns the expected number of CPUs, which is never less than 1. 68*2fc1284fSAndy Fiddaman.Sh SEE ALSO 69*2fc1284fSAndy Fiddaman.Xr attach 9E , 70*2fc1284fSAndy Fiddaman.Xr ddi_intr_get_navail 9F 71