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