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
34 * $DragonFly: src/sys/sys/kinfo.h,v 1.10 2007/02/01 20:27:05 tgen Exp $
41 #include <sys/types.h>
44 #include <sys/param.h>
46 #include <sys/resource.h>
47 #include <sys/rtprio.h>
50 size_t f_size; /* size of struct kinfo_file */
51 pid_t f_pid; /* owning process */
52 uid_t f_uid; /* effective uid of owning process */
53 int f_fd; /* descriptor number */
54 void *f_file; /* address of struct file */
55 short f_type; /* descriptor type */
56 int f_count; /* reference count */
57 int f_msgcount; /* references from message queue */
58 off_t f_offset; /* file offset */
59 void *f_data; /* file descriptor specific data */
60 u_int f_flag; /* flags (see fcntl.h) */
66 struct kinfo_cputime {
75 * CPU system/interrupt program counter sampler
77 #define PCTRACK_ARYSIZE 32 /* must be a power of 2 */
78 #define PCTRACK_ARYMASK (PCTRACK_ARYSIZE - 1)
80 struct kinfo_pcheader {
81 int pc_ntrack; /* number of tracks per cpu (2) */
82 int pc_arysize; /* size of storage array (32) */
85 struct kinfo_pctrack {
87 void *pc_array[PCTRACK_ARYSIZE];
92 #define PCTRACK_SIZE 2
94 struct kinfo_clockinfo {
95 int ci_hz; /* clock frequency */
96 int ci_tick; /* micro-seconds per hz tick */
97 int ci_tickadj; /* clock skew rate for adjtime() */
98 int ci_stathz; /* statistics clock frequency */
99 int ci_profhz; /* profiling clock frequency */
103 * Structure definition for the lwp-specific data in struct kinfo_proc.
106 pid_t kl_pid; /* PID of our associated proc */
107 lwpid_t kl_tid; /* thread id */
109 int kl_flags; /* LWP_ flags */
110 char kl_stat; /* S* lwp status */
111 int kl_tdflags; /* thread flags */
112 int kl_mpcount; /* MP lock held count */
113 int kl_prio; /* scheduling priority */
114 int kl_tdprio; /* lwkt sched priority */
115 struct rtprio kl_rtprio; /* real-time scheduling prio */
118 uint64_t kl_uticks; /* time accounting */
121 uint64_t kl_cpticks; /* sched quantums used */
122 u_int kl_pctcpu; /* percentage cputime */
123 u_int kl_swtime; /* time swapped in or out */
124 u_int kl_slptime; /* time since last blocked */
125 int kl_origcpu; /* originally scheduled on cpu */
127 int kl_cpuid; /* CPU this lwp was last scheduled on */
129 struct rusage kl_ru; /* resource usage stats */
131 sigset_t kl_siglist; /* pending signals */
132 sigset_t kl_sigmask; /* masked signals */
134 uintptr_t kl_wchan; /* waiting channel */
135 char kl_wmesg[WMESGLEN+1]; /* waiting message */
139 * KERN_PROC subtype ops return arrays of normalized proc structures:
142 uintptr_t kp_paddr; /* address of this proc */
144 /* proc information */
148 int kp_acflag; /* accounting flags */
151 uintptr_t kp_fd; /* address of the proc's files */
154 sigset_t kp_sigignore;
155 sigset_t kp_sigcatch;
156 int kp_sigflag; /* from ps_flag */
157 struct timeval kp_start;
159 char kp_comm[MAXCOMLEN+1];
161 /* cred information */
164 gid_t kp_groups[NGROUPS];
170 pid_t kp_pid; /* process id */
171 pid_t kp_ppid; /* parent process id */
172 pid_t kp_pgid; /* process group id */
173 int kp_jobc; /* job control counter */
174 pid_t kp_sid; /* session id */
175 char kp_login[roundup(MAXLOGNAME, sizeof(long))]; /* setlogin() name */
176 dev_t kp_tdev; /* controlling tty dev */
177 pid_t kp_tpgid; /* tty process group id */
178 pid_t kp_tsid; /* tty session id */
180 u_short kp_exitstat; /* exit status information */
184 vm_size_t kp_vm_map_size; /* vmmap virtual size */
185 segsz_t kp_vm_rssize; /* resident set size */
186 segsz_t kp_vm_swrss; /* rss before last swap */
187 segsz_t kp_vm_tsize; /* text size */
188 segsz_t kp_vm_dsize; /* data size */
189 segsz_t kp_vm_ssize; /* stack size */
194 struct rusage kp_cru;
196 int kp_auxflags; /* generated flags */
200 struct kinfo_lwp kp_lwp;
209 void fill_kinfo_proc(struct proc *, struct kinfo_proc *);
210 void fill_kinfo_lwp(struct lwp *, struct kinfo_lwp *);
211 void fill_kinfo_proc_kthread(struct thread *, struct kinfo_proc *);
213 #define KINFO_NEXT(kp) ((union kinfo *)((uintptr_t)kp + kp->gen.len))
214 #define KINFO_END(kp) (kp->gen.type == KINFO_TYPE_END)
218 #define cpu_time cputime_percpu[mycpuid]
220 #define cpu_time cputime_percpu[0]
225 extern struct kinfo_cputime cputime_percpu[MAXCPU];
228 #endif /* !_SYS_KINFO_H_ */