Print this page
OS-5192 need faster clock_gettime
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Joshua M. Clulow <jmc@joyent.com>
Reviewed by: Ryan Zezeski <ryan@zinascii.com>
OS-5209 __KERN_NAUXV_IMPL needs to be increased for OS-5202
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/sys/user.h
+++ new/usr/src/uts/common/sys/user.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
|
↓ open down ↓ |
18 lines elided |
↑ open up ↑ |
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 26 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
27 27 /* All Rights Reserved */
28 28 /*
29 - * Copyright (c) 2012 Joyent, Inc. All rights reserved.
29 + * Copyright 2016 Joyent, Inc.
30 30 */
31 31
32 32
33 33 #ifndef _SYS_USER_H
34 34 #define _SYS_USER_H
35 35
36 36 #include <sys/types.h>
37 37 #include <sys/signal.h>
38 38
39 39 #ifdef __cplusplus
40 40 extern "C" {
41 41 #endif
42 42
43 43 /*
44 44 * struct exdata is visible in and out of the kernel. This is because it
45 45 * is referenced in <sys/core.h> which doesn't have this kind of magic.
46 46 */
47 47 struct exdata {
48 48 struct vnode *vp;
49 49 size_t ux_tsize; /* text size */
50 50 size_t ux_dsize; /* data size */
51 51 size_t ux_bsize; /* bss size */
52 52 size_t ux_lsize; /* lib size */
53 53 long ux_nshlibs; /* number of shared libs needed */
54 54 short ux_mach; /* machine type */
55 55 short ux_mag; /* magic number MUST be here */
56 56 off_t ux_toffset; /* file offset to raw text */
57 57 off_t ux_doffset; /* file offset to raw data */
58 58 off_t ux_loffset; /* file offset to lib sctn */
59 59 caddr_t ux_txtorg; /* start addr of text in mem */
60 60 caddr_t ux_datorg; /* start addr of data in mem */
61 61 caddr_t ux_entloc; /* entry location */
62 62 };
63 63
64 64 #ifdef __cplusplus
65 65 }
66 66 #endif
67 67
68 68 #if defined(_KERNEL) || defined(_KMEMUSER)
69 69
70 70 #include <sys/param.h>
71 71 #include <sys/pcb.h>
72 72 #include <sys/siginfo.h>
73 73 #include <sys/resource.h>
74 74 #include <sys/time.h>
75 75 #include <sys/auxv.h>
76 76 #include <sys/errno.h>
77 77 #include <sys/t_lock.h>
78 78 #include <sys/refstr.h>
79 79
80 80 #ifdef __cplusplus
81 81 extern "C" {
82 82 #endif
83 83
84 84 /*
85 85 * Entry in the per-process list of open files.
86 86 * Note: only certain fields are copied in flist_grow() and flist_fork().
87 87 * This is indicated in brackets in the structure member comments.
88 88 */
89 89 typedef struct uf_entry {
90 90 kmutex_t uf_lock; /* per-fd lock [never copied] */
91 91 struct file *uf_file; /* file pointer [grow, fork] */
92 92 struct fpollinfo *uf_fpollinfo; /* poll state [grow] */
93 93 int uf_refcnt; /* LWPs accessing this file [grow] */
94 94 int uf_alloc; /* right subtree allocs [grow, fork] */
95 95 short uf_flag; /* fcntl F_GETFD flags [grow, fork] */
96 96 short uf_busy; /* file is allocated [grow, fork] */
97 97 kcondvar_t uf_wanted_cv; /* waiting for setf() [never copied] */
98 98 kcondvar_t uf_closing_cv; /* waiting for close() [never copied] */
99 99 struct portfd *uf_portfd; /* associated with port [grow] */
100 100 /* Avoid false sharing - pad to coherency granularity (64 bytes) */
101 101 char uf_pad[64 - sizeof (kmutex_t) - 2 * sizeof (void*) -
102 102 2 * sizeof (int) - 2 * sizeof (short) -
103 103 2 * sizeof (kcondvar_t) - sizeof (struct portfd *)];
104 104 } uf_entry_t;
105 105
106 106 /*
107 107 * Retired file lists -- see flist_grow() for details.
108 108 */
109 109 typedef struct uf_rlist {
110 110 struct uf_rlist *ur_next;
111 111 uf_entry_t *ur_list;
112 112 int ur_nfiles;
113 113 } uf_rlist_t;
114 114
115 115 /*
116 116 * Per-process file information.
117 117 */
118 118 typedef struct uf_info {
119 119 kmutex_t fi_lock; /* see below */
120 120 int fi_badfd; /* bad file descriptor # */
121 121 int fi_action; /* action to take on bad fd use */
122 122 int fi_nfiles; /* number of entries in fi_list[] */
123 123 uf_entry_t *volatile fi_list; /* current file list */
124 124 uf_rlist_t *fi_rlist; /* retired file lists */
125 125 } uf_info_t;
126 126
127 127 /*
128 128 * File list locking.
129 129 *
130 130 * Each process has a list of open files, fi_list, indexed by fd.
131 131 * fi_list is an array of uf_entry_t structures, each with its own lock.
132 132 * One might think that the correct way to lock a file descriptor would be:
133 133 *
134 134 * ufp = fip->fi_list[fd];
135 135 * mutex_enter(&ufp->uf_lock);
136 136 *
137 137 * However, that construct is only safe if fi_lock is already held. If not,
138 138 * fi_list can change in the window between loading ufp and entering uf_lock.
139 139 * The UF_ENTER() macro deals with this possibility. UF_ENTER(ufp, fip, fd)
140 140 * locks fd and sets ufp to fd's uf_entry. The locking rules are as follows:
141 141 *
142 142 * (1) fi_lock protects fi_list and fi_nfiles. It also protects the
143 143 * uf_alloc and uf_busy fields of every fd's ufp; see fd_find() for
144 144 * details on file descriptor allocation.
145 145 *
146 146 * (2) UF_ENTER(ufp, fip, fd) locks descriptor fd and sets ufp to point
147 147 * to the uf_entry_t for fd. UF_ENTER() protects all fields in ufp
148 148 * except uf_alloc and uf_busy. UF_ENTER(ufp, fip, fd) also prevents
149 149 * ufp->uf_alloc, ufp->uf_busy, fip->fi_list and fip->fi_nfiles from
150 150 * changing.
151 151 *
152 152 * (3) The lock ordering is (1), (2).
153 153 *
154 154 * (4) Note that fip->fi_list and fip->fi_nfiles cannot change while *any*
155 155 * file list lock is held. Thus flist_grow() must acquire all such
156 156 * locks -- fi_lock and every fd's uf_lock -- to install a new file list.
157 157 */
158 158 #define UF_ENTER(ufp, fip, fd) \
159 159 for (;;) { \
160 160 uf_entry_t *_flist = (fip)->fi_list; \
161 161 ufp = &_flist[fd]; \
162 162 ASSERT((fd) < (fip)->fi_nfiles); \
163 163 mutex_enter(&ufp->uf_lock); \
164 164 if (_flist == (fip)->fi_list) \
165 165 break; \
166 166 mutex_exit(&ufp->uf_lock); \
167 167 }
168 168
169 169 #define UF_EXIT(ufp) mutex_exit(&ufp->uf_lock)
170 170
171 171 #define PSARGSZ 80 /* Space for exec arguments (used by ps(1)) */
172 172 #define MAXCOMLEN 16 /* <= MAXNAMLEN, >= sizeof (ac_comm) */
173 173
174 174 typedef struct { /* kernel syscall set type */
175 175 uint_t word[9]; /* space for syscall numbers [1..288] */
176 176 } k_sysset_t;
177 177
|
↓ open down ↓ |
138 lines elided |
↑ open up ↑ |
178 178 /*
179 179 * __KERN_NAUXV_IMPL is defined as a convenience sizing mechanism
180 180 * for the portions of the kernel that care about aux vectors.
181 181 *
182 182 * Applications that need to know how many aux vectors the kernel
183 183 * supplies should use the proc(4) interface to read /proc/PID/auxv.
184 184 *
185 185 * This value should not be changed in a patch.
186 186 */
187 187 #if defined(__sparc)
188 -#define __KERN_NAUXV_IMPL 20
188 +#define __KERN_NAUXV_IMPL 24
189 189 #elif defined(__i386) || defined(__amd64)
190 -#define __KERN_NAUXV_IMPL 22
190 +#define __KERN_NAUXV_IMPL 26
191 191 #endif
192 192
193 193 struct execsw;
194 194
195 195 /*
196 196 * The user structure; one allocated per process. Contains all the
197 197 * per-process data that doesn't need to be referenced while the
198 198 * process is swapped.
199 199 */
200 200 typedef struct user {
201 201 /*
202 202 * These fields are initialized at process creation time and never
203 203 * modified. They can be accessed without acquiring locks.
|
↓ open down ↓ |
3 lines elided |
↑ open up ↑ |
204 204 */
205 205 struct execsw *u_execsw; /* pointer to exec switch entry */
206 206 auxv_t u_auxv[__KERN_NAUXV_IMPL]; /* aux vector from exec */
207 207 timestruc_t u_start; /* hrestime at process start */
208 208 clock_t u_ticks; /* lbolt at process start */
209 209 char u_comm[MAXCOMLEN + 1]; /* executable file name from exec */
210 210 char u_psargs[PSARGSZ]; /* arguments from exec */
211 211 int u_argc; /* value of argc passed to main() */
212 212 uintptr_t u_argv; /* value of argv passed to main() */
213 213 uintptr_t u_envp; /* value of envp passed to main() */
214 + uintptr_t u_commpagep; /* address of mapped comm page */
214 215
215 216 /*
216 217 * These fields are protected by p_lock:
217 218 */
218 219 struct vnode *u_cdir; /* current directory */
219 220 struct vnode *u_rdir; /* root directory */
220 221 uint64_t u_mem; /* accumulated memory usage */
221 222 size_t u_mem_max; /* peak RSS (K) */
222 223 mode_t u_cmask; /* mask for file creation */
223 224 char u_acflag; /* accounting flag */
224 225 char u_systrap; /* /proc: any syscall mask bits set? */
225 226 refstr_t *u_cwd; /* cached string for cwd */
226 227
227 228 k_sysset_t u_entrymask; /* /proc syscall stop-on-entry mask */
228 229 k_sysset_t u_exitmask; /* /proc syscall stop-on-exit mask */
229 230 k_sigset_t u_signodefer; /* signals defered when caught */
230 231 k_sigset_t u_sigonstack; /* signals taken on alternate stack */
231 232 k_sigset_t u_sigresethand; /* signals reset when caught */
232 233 k_sigset_t u_sigrestart; /* signals that restart system calls */
233 234 k_sigset_t u_sigmask[MAXSIG]; /* signals held while in catcher */
234 235 void (*u_signal[MAXSIG])(); /* Disposition of signals */
235 236
236 237 /*
237 238 * Resource controls provide the backend for process resource limits,
238 239 * the interfaces for which are maintained for compatibility. To
239 240 * preserve the behaviour associated with the RLIM_SAVED_CUR and
240 241 * RLIM_SAVED_MAX tokens, we retain the "saved" rlimits.
241 242 */
242 243 struct rlimit64 u_saved_rlimit[RLIM_NSAVED];
243 244
244 245 uf_info_t u_finfo; /* open file information */
245 246 } user_t;
246 247
247 248 #include <sys/proc.h> /* cannot include before user defined */
248 249
249 250 #ifdef _KERNEL
250 251 #define P_FINFO(p) (&(p)->p_user.u_finfo)
251 252 #endif /* _KERNEL */
252 253
253 254 #ifdef __cplusplus
254 255 }
255 256 #endif
256 257
257 258 #else /* defined(_KERNEL) || defined(_KMEMUSER) */
258 259
259 260 /*
260 261 * Here, we define a fake version of struct user for programs
261 262 * (debuggers) that use ptrace() to read and modify the saved
262 263 * registers directly in the u-area. ptrace() has been removed
263 264 * from the operating system and now exists as a library function
264 265 * in libc, built on the /proc process filesystem. The ptrace()
265 266 * library function provides access only to the members of the
266 267 * fake struct user defined here.
267 268 *
268 269 * User-level programs that must know the real contents of struct
269 270 * user will have to define _KMEMUSER before including <sys/user.h>.
270 271 * Such programs also become machine specific. Carefully consider
271 272 * the consequences of your actions.
272 273 */
273 274
274 275 #include <sys/regset.h>
275 276
276 277 #ifdef __cplusplus
277 278 extern "C" {
278 279 #endif
279 280
280 281 #define PSARGSZ 80 /* Space for exec arguments (used by ps(1)) */
281 282
282 283 typedef struct user {
283 284 gregset_t u_reg; /* user's saved registers */
284 285 greg_t *u_ar0; /* address of user's saved R0 */
285 286 char u_psargs[PSARGSZ]; /* arguments from exec */
286 287 void (*u_signal[MAXSIG])(); /* Disposition of signals */
287 288 int u_code; /* fault code on trap */
288 289 caddr_t u_addr; /* fault PC on trap */
289 290 } user_t;
290 291
291 292 #ifdef __cplusplus
292 293 }
293 294 #endif
294 295
295 296 #endif /* defined(_KERNEL) || defined(_KMEMUSER) */
296 297
297 298 #endif /* _SYS_USER_H */
|
↓ open down ↓ |
74 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX