1794a9a6cSJohn Baldwin.\" Copyright (c) 2008 Yahoo!, Inc. 2794a9a6cSJohn Baldwin.\" All rights reserved. 3794a9a6cSJohn Baldwin.\" Written by: John Baldwin <jhb@FreeBSD.org> 4794a9a6cSJohn Baldwin.\" 5794a9a6cSJohn Baldwin.\" Redistribution and use in source and binary forms, with or without 6794a9a6cSJohn Baldwin.\" modification, are permitted provided that the following conditions 7794a9a6cSJohn Baldwin.\" are met: 8794a9a6cSJohn Baldwin.\" 1. Redistributions of source code must retain the above copyright 9794a9a6cSJohn Baldwin.\" notice, this list of conditions and the following disclaimer. 10794a9a6cSJohn Baldwin.\" 2. Redistributions in binary form must reproduce the above copyright 11794a9a6cSJohn Baldwin.\" notice, this list of conditions and the following disclaimer in the 12794a9a6cSJohn Baldwin.\" documentation and/or other materials provided with the distribution. 13794a9a6cSJohn Baldwin.\" 3. Neither the name of the author nor the names of any co-contributors 14794a9a6cSJohn Baldwin.\" may be used to endorse or promote products derived from this software 15794a9a6cSJohn Baldwin.\" without specific prior written permission. 16794a9a6cSJohn Baldwin.\" 17794a9a6cSJohn Baldwin.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18794a9a6cSJohn Baldwin.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19794a9a6cSJohn Baldwin.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20794a9a6cSJohn Baldwin.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21794a9a6cSJohn Baldwin.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22794a9a6cSJohn Baldwin.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23794a9a6cSJohn Baldwin.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24794a9a6cSJohn Baldwin.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25794a9a6cSJohn Baldwin.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26794a9a6cSJohn Baldwin.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27794a9a6cSJohn Baldwin.\" SUCH DAMAGE. 28794a9a6cSJohn Baldwin.\" 29794a9a6cSJohn Baldwin.\" $FreeBSD$ 30794a9a6cSJohn Baldwin.\" 31794a9a6cSJohn Baldwin.Dd August 19, 2008 32794a9a6cSJohn Baldwin.Dt KVM_GETPCPU 3 33794a9a6cSJohn Baldwin.Os 34794a9a6cSJohn Baldwin.Sh NAME 35794a9a6cSJohn Baldwin.Nm kvm_getmaxcpu , 36794a9a6cSJohn Baldwin.Nm kvm_getpcpu 37794a9a6cSJohn Baldwin.Nd access per-CPU data 38794a9a6cSJohn Baldwin.Sh LIBRARY 39794a9a6cSJohn Baldwin.Lb libkvm 40794a9a6cSJohn Baldwin.Sh SYNOPSIS 41794a9a6cSJohn Baldwin.In sys/param.h 42794a9a6cSJohn Baldwin.In sys/pcpu.h 43794a9a6cSJohn Baldwin.In sys/sysctl.h 44794a9a6cSJohn Baldwin.In kvm.h 45794a9a6cSJohn Baldwin.Ft int 46794a9a6cSJohn Baldwin.Fn kvm_getmaxcpu "kvm_t *kd" 47794a9a6cSJohn Baldwin.Ft void * 48794a9a6cSJohn Baldwin.Fn kvm_getpcpu "kvm_t *kd" "int cpu" 49794a9a6cSJohn Baldwin.Sh DESCRIPTION 50794a9a6cSJohn BaldwinThe 51794a9a6cSJohn Baldwin.Fn kvm_getmaxcpu 52794a9a6cSJohn Baldwinand 53794a9a6cSJohn Baldwin.Fn kvm_getpcpu 54794a9a6cSJohn Baldwinfunctions are used to access the per-CPU data of active processors in the 55794a9a6cSJohn Baldwinkernel indicated by 56794a9a6cSJohn Baldwin.Fa kd . 57794a9a6cSJohn BaldwinThe 58794a9a6cSJohn Baldwin.Fn kvm_getmaxcpu 59794a9a6cSJohn Baldwinfunction returns the maximum number of CPUs supported by the kernel. 60794a9a6cSJohn BaldwinThe 61794a9a6cSJohn Baldwin.Fn kvm_getpcpu 62794a9a6cSJohn Baldwinfunction returns a buffer holding the per-CPU data for a single CPU. 63794a9a6cSJohn BaldwinThis buffer is described by the 64794a9a6cSJohn Baldwin.Vt "struct pcpu" 65794a9a6cSJohn Baldwintype. 66794a9a6cSJohn BaldwinThe caller is responsible for releasing the buffer via a call to 67794a9a6cSJohn Baldwin.Xr free 3 68794a9a6cSJohn Baldwinwhen it is no longer needed. 69794a9a6cSJohn BaldwinIf 70794a9a6cSJohn Baldwin.Fa cpu 71794a9a6cSJohn Baldwinis not active, then 72794a9a6cSJohn Baldwin.Dv NULL 73794a9a6cSJohn Baldwinis returned instead. 74794a9a6cSJohn Baldwin.Sh RETURN VALUES 75794a9a6cSJohn BaldwinOn success, the 76794a9a6cSJohn Baldwin.Fn kvm_getmaxcpu 77794a9a6cSJohn Baldwinfunction returns the maximum number of CPUs supported by the kernel. 78794a9a6cSJohn BaldwinIf an error occurs, 79794a9a6cSJohn Baldwinit returns -1 instead. 80794a9a6cSJohn Baldwin.Pp 81794a9a6cSJohn BaldwinOn success, the 82794a9a6cSJohn Baldwin.Fn kvm_getpcpu 83794a9a6cSJohn Baldwinfunction returns a pointer to an allocated buffer or 84794a9a6cSJohn Baldwin.Dv NULL. 85794a9a6cSJohn BaldwinIf an error occurs, 86794a9a6cSJohn Baldwinit returns -1 instead. 87794a9a6cSJohn Baldwin.Pp 88794a9a6cSJohn BaldwinIf either function encounters an error, 89794a9a6cSJohn Baldwinthen an error message may be retrieved via 90794a9a6cSJohn Baldwin.Xr kvm_geterr 3. 91794a9a6cSJohn Baldwin.Sh SEE ALSO 92794a9a6cSJohn Baldwin.Xr free 3 , 93794a9a6cSJohn Baldwin.Xr kvm 3 94