mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-25 11:37:56 +00:00
cd11f01e4a
and the ability to clear that cache.
102 lines
3.1 KiB
Groff
102 lines
3.1 KiB
Groff
.\" Copyright (c) 2008 Yahoo!, Inc.
|
|
.\" All rights reserved.
|
|
.\" Written by: John Baldwin <jhb@FreeBSD.org>
|
|
.\"
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
.\" modification, are permitted provided that the following conditions
|
|
.\" are met:
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
.\" 3. Neither the name of the author nor the names of any co-contributors
|
|
.\" may be used to endorse or promote products derived from this software
|
|
.\" without specific prior written permission.
|
|
.\"
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
.\" SUCH DAMAGE.
|
|
.\"
|
|
.\" $FreeBSD$
|
|
.\"
|
|
.Dd August 19, 2008
|
|
.Dt KVM_GETPCPU 3
|
|
.Os
|
|
.Sh NAME
|
|
.Nm kvm_getmaxcpu ,
|
|
.Nm kvm_getpcpu
|
|
.Nd access per-CPU data
|
|
.Sh LIBRARY
|
|
.Lb libkvm
|
|
.Sh SYNOPSIS
|
|
.In sys/param.h
|
|
.In sys/pcpu.h
|
|
.In sys/sysctl.h
|
|
.In kvm.h
|
|
.Ft int
|
|
.Fn kvm_getmaxcpu "kvm_t *kd"
|
|
.Ft void *
|
|
.Fn kvm_getpcpu "kvm_t *kd" "int cpu"
|
|
.Sh DESCRIPTION
|
|
The
|
|
.Fn kvm_getmaxcpu
|
|
and
|
|
.Fn kvm_getpcpu
|
|
functions are used to access the per-CPU data of active processors in the
|
|
kernel indicated by
|
|
.Fa kd .
|
|
The
|
|
.Fn kvm_getmaxcpu
|
|
function returns the maximum number of CPUs supported by the kernel.
|
|
The
|
|
.Fn kvm_getpcpu
|
|
function returns a buffer holding the per-CPU data for a single CPU.
|
|
This buffer is described by the
|
|
.Vt "struct pcpu"
|
|
type.
|
|
The caller is responsible for releasing the buffer via a call to
|
|
.Xr free 3
|
|
when it is no longer needed.
|
|
If
|
|
.Fa cpu
|
|
is not active, then
|
|
.Dv NULL
|
|
is returned instead.
|
|
.Sh CACHING
|
|
These functions cache the nlist values for various kernel variables which are
|
|
reused in successive calls.
|
|
You may call either function with
|
|
.Fa kd
|
|
set to
|
|
.Dv NULL
|
|
to clear this cache.
|
|
.Sh RETURN VALUES
|
|
On success, the
|
|
.Fn kvm_getmaxcpu
|
|
function returns the maximum number of CPUs supported by the kernel.
|
|
If an error occurs,
|
|
it returns -1 instead.
|
|
.Pp
|
|
On success, the
|
|
.Fn kvm_getpcpu
|
|
function returns a pointer to an allocated buffer or
|
|
.Dv NULL.
|
|
If an error occurs,
|
|
it returns -1 instead.
|
|
.Pp
|
|
If either function encounters an error,
|
|
then an error message may be retrieved via
|
|
.Xr kvm_geterr 3.
|
|
.Sh SEE ALSO
|
|
.Xr free 3 ,
|
|
.Xr kvm 3
|