2 * Copyright (c) 2004 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Joerg Sonnenberger <joerg@bec.de>.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 #include <sys/types.h>
42 #include <sys/param.h>
44 #include <sys/resource.h>
45 #include <sys/rtprio.h>
46 #include <sys/proc_common.h>
52 * NOTE: correct way to use this header from non kernel code is to include
53 * the <sys/user.h> first!
57 size_t f_size; /* size of struct kinfo_file */
58 pid_t f_pid; /* owning process */
59 uid_t f_uid; /* effective uid of owning process */
60 int f_fd; /* descriptor number */
61 void *f_file; /* address of struct file */
62 short f_type; /* descriptor type */
63 int f_count; /* reference count */
64 int f_msgcount; /* references from message queue */
65 off_t f_offset; /* file offset */
66 void *f_data; /* file descriptor specific data */
67 u_int f_flag; /* flags (see fcntl.h) */
73 struct kinfo_cputime {
81 uint64_t cp_sample_pc;
82 uint64_t cp_sample_sp;
83 char cp_msg[32]; /* code stall token or mplock */
87 * CPU system/interrupt program counter sampler
89 #define PCTRACK_ARYSIZE 32 /* must be a power of 2 */
90 #define PCTRACK_ARYMASK (PCTRACK_ARYSIZE - 1)
92 struct kinfo_pcheader {
93 int pc_ntrack; /* number of tracks per cpu (2) */
94 int pc_arysize; /* size of storage array (32) */
97 struct kinfo_pctrack {
99 void *pc_array[PCTRACK_ARYSIZE];
102 #define PCTRACK_SYS 0
103 #define PCTRACK_INT 1
104 #define PCTRACK_SIZE 2
106 struct kinfo_clockinfo {
107 int ci_hz; /* clock frequency */
108 int ci_tick; /* micro-seconds per hz tick */
109 int ci_tickadj; /* clock skew rate for adjtime() */
110 int ci_stathz; /* statistics clock frequency */
111 int ci_profhz; /* profiling clock frequency */
115 * Structure definition for the lwp-specific data in struct kinfo_proc.
118 pid_t kl_pid; /* PID of our associated proc */
119 lwpid_t kl_tid; /* thread id */
121 int kl_flags; /* LWP_ flags */
122 enum lwpstat kl_stat; /* LS* lwp status */
123 int kl_lock; /* lwp lock (prevent destruct) count */
124 int kl_tdflags; /* thread flags */
125 int kl_mpcount; /* MP lock held count */
126 int kl_prio; /* scheduling priority */
127 int kl_tdprio; /* lwkt sched priority */
128 struct rtprio kl_rtprio; /* real-time scheduling prio */
131 uint64_t kl_uticks; /* time accounting */
134 uint64_t kl_cpticks; /* sched quantums used */
135 u_int kl_pctcpu; /* percentage cputime */
136 u_int kl_slptime; /* time since last blocked */
137 int kl_origcpu; /* originally scheduled on cpu */
139 int kl_cpuid; /* CPU this lwp was last scheduled on */
141 struct rusage kl_ru; /* resource usage stats */
143 sigset_t kl_siglist; /* pending signals */
144 sigset_t kl_sigmask; /* masked signals */
146 uintptr_t kl_wchan; /* waiting channel */
147 char kl_wmesg[WMESGLEN+1]; /* waiting message */
149 char kl_comm[MAXCOMLEN+1]; /* lwp name */
153 * KERN_PROC subtype ops return arrays of normalized proc structures:
156 uintptr_t kp_paddr; /* address of this proc */
158 /* proc information */
160 enum procstat kp_stat;
162 int kp_acflag; /* accounting flags */
165 uintptr_t kp_fd; /* address of the proc's files */
168 sigset_t kp_sigignore;
169 sigset_t kp_sigcatch;
170 int kp_sigflag; /* from ps_flag */
171 struct timeval kp_start;
173 char kp_comm[MAXCOMLEN+1];
175 /* cred information */
178 gid_t kp_groups[NGROUPS];
184 pid_t kp_pid; /* process id */
185 pid_t kp_ppid; /* parent process id */
186 pid_t kp_pgid; /* process group id */
187 int kp_jobc; /* job control counter */
188 pid_t kp_sid; /* session id */
189 char kp_login[roundup(MAXLOGNAME, sizeof(long))];
190 /* setlogin() name */
191 dev_t kp_tdev; /* controlling tty dev */
192 pid_t kp_tpgid; /* tty process group id */
193 pid_t kp_tsid; /* tty session id */
195 u_short kp_exitstat; /* exit status information */
198 unsigned int kp_swtime;
200 size_t kp_vm_map_size; /* vmmap virtual size in bytes */
201 segsz_t kp_vm_rssize; /* resident set size in pages */
202 segsz_t kp_vm_swrss; /* rss before last swap in pages */
203 segsz_t kp_vm_tsize; /* text size in pages */
204 segsz_t kp_vm_dsize; /* data size in pages */
205 segsz_t kp_vm_ssize; /* stack size in pages */
206 u_int kp_vm_prssize; /* proportional rss in pages */
211 struct rusage kp_cru;
213 int kp_auxflags; /* generated flags */
217 struct kinfo_lwp kp_lwp;
219 uintptr_t kp_ktaddr; /* address of this kernel thread */
224 * KERN_SIGTRAMP, public, KERN_PROC_SIGTRAMP used in external codes
226 struct kinfo_sigtramp {
227 void *ksigtramp_start;
229 void *ksigtramp_spare[4];
232 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
238 void fill_kinfo_proc(struct proc *, struct kinfo_proc *);
239 void fill_kinfo_lwp(struct lwp *, struct kinfo_lwp *);
240 void fill_kinfo_proc_kthread(struct thread *, struct kinfo_proc *);
242 #endif /* defined(_KERNEL) || defined(_KERNEL_STRUCTURES) */
245 #define cpu_time cputime_percpu[mycpuid]
246 extern struct kinfo_cputime cputime_percpu[MAXCPU];
249 #endif /* !_SYS_KINFO_H_ */