1 .\" Copyright (c) 2008 Yahoo!, Inc.
2 .\" All rights reserved.
3 .\" Written by: John Baldwin <jhb@FreeBSD.org>
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
13 .\" 3. Neither the name of the author nor the names of any co-contributors
14 .\" may be used to endorse or promote products derived from this software
15 .\" without specific prior written permission.
17 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 .Nm kvm_dpcpu_setcpu ,
38 .Nd access per-CPU data
47 .Fn kvm_dpcpu_setcpu "kvm_t *kd" "u_int cpu"
49 .Fn kvm_getmaxcpu "kvm_t *kd"
51 .Fn kvm_getncpus "kvm_t *kd"
53 .Fn kvm_getpcpu "kvm_t *kd" "int cpu"
55 .Fn kvm_read_zpcpu "kvm_t *kd" "u_long base" "void *buf" "size_t size" "int cpu"
57 .Fn kvm_counter_u64_fetch "kvm_t *kd" "u_long base"
60 .Fn kvm_dpcpu_setcpu ,
64 functions are used to access the per-CPU data of active processors in the
67 Per-CPU storage comes in two flavours: data stored directly in a
69 associated with each CPU, and dynamic per-CPU storage (DPCPU), in which a
70 single kernel symbol refers to different data depending on what CPU it is
75 function returns the maximum number of CPUs supported by the kernel.
79 function returns the current number of CPUs in the kernel.
83 function returns a buffer holding the per-CPU data for a single CPU.
84 This buffer is described by the
87 The caller is responsible for releasing the buffer via a call to
89 when it is no longer needed.
98 function is used to obtain private per-CPU copy from a
103 argument as base address of an allocation and copyies
107 from the part of allocation that is private to
111 .Fn kvm_counter_u64_fetch
112 function fetches value of a
118 Symbols for dynamic per-CPU data are accessed via
120 as with other symbols.
122 maintains a notion of the "current CPU", set by
123 .Fn kvm_dpcpu_setcpu ,
125 Once another CPU is selected,
127 will return pointers to that data on the appropriate CPU.
132 cache the nlist values for various kernel variables which are
133 reused in successive calls.
134 You may call either function with
142 function returns the maximum number of CPUs supported by the kernel.
144 it returns -1 instead.
148 function returns a pointer to an allocated buffer or
151 it returns -1 instead.
155 call returns 0; if an error occurs, it returns -1 instead.
159 function returns number of bytes copied.
160 If an error occurs, it returns -1 instead.
162 If any function encounters an error,
163 then an error message may be retrieved via