FreeBSD/Linux Kernel Cross Reference
sys/sys/resourcevar.h
1 /* $NetBSD: resourcevar.h,v 1.46 2008/10/11 13:40:58 pooka Exp $ */
2
3 /*
4 * Copyright (c) 1991, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * @(#)resourcevar.h 8.4 (Berkeley) 1/9/95
32 */
33
34 #ifndef _SYS_RESOURCEVAR_H_
35 #define _SYS_RESOURCEVAR_H_
36
37 #include <sys/mutex.h>
38
39 /*
40 * Kernel per-process accounting / statistics
41 */
42 struct pstats {
43 #define pstat_startzero p_ru
44 struct rusage p_ru; /* stats for this proc */
45 struct rusage p_cru; /* sum of stats for reaped children */
46 #define pstat_endzero pstat_startcopy
47
48 #define pstat_startcopy p_timer
49 struct itimerval p_timer[3]; /* virtual-time timers */
50
51 struct uprof { /* profile arguments */
52 char * pr_base; /* buffer base */
53 size_t pr_size; /* buffer size */
54 u_long pr_off; /* pc offset */
55 u_int pr_scale; /* pc scaling */
56 u_long pr_addr; /* temp storage for addr until AST */
57 u_long pr_ticks; /* temp storage for ticks until AST */
58 } p_prof;
59 #define pstat_endcopy p_start
60 struct timeval p_start; /* starting time */
61 };
62
63 /*
64 * Kernel shareable process resource limits. Because this structure
65 * is moderately large but changes infrequently, it is normally
66 * shared copy-on-write after forks. If a group of processes
67 * ("threads") share modifications, the PL_SHAREMOD flag is set,
68 * and a copy must be made for the child of a new fork that isn't
69 * sharing modifications to the limits.
70 *
71 * The PL_xxx flags are never cleared, once either is set p->p_limit
72 * will never be changed again.
73 */
74 struct plimit {
75 struct rlimit pl_rlimit[RLIM_NLIMITS];
76 char *pl_corename;
77 #define PL_SHAREMOD 0x01 /* modifications are shared */
78 #define PL_WRITEABLE 0x02 /* private to this process */
79 int pl_flags;
80 int pl_refcnt; /* number of references */
81 kmutex_t pl_lock; /* mutex for pl_refcnt */
82 struct plimit *pl_sv_limit; /* saved when PL_WRITEABLE set */
83 };
84
85 /* add user profiling from AST XXXSMP */
86 #define ADDUPROF(p) \
87 do { \
88 struct proc *_p = l->l_proc; \
89 addupc_task(l, \
90 (_p)->p_stats->p_prof.pr_addr, \
91 (_p)->p_stats->p_prof.pr_ticks); \
92 (_p)->p_stats->p_prof.pr_ticks = 0; \
93 } while (/* CONSTCOND */ 0)
94
95 #ifdef _KERNEL
96 extern char defcorename[];
97
98 extern int security_setidcore_dump;
99 extern char security_setidcore_path[];
100 extern uid_t security_setidcore_owner;
101 extern gid_t security_setidcore_group;
102 extern mode_t security_setidcore_mode;
103
104 void addupc_intr(struct lwp *, u_long);
105 void addupc_task(struct lwp *, u_long, u_int);
106 void calcru(struct proc *, struct timeval *, struct timeval *,
107 struct timeval *, struct timeval *);
108
109 struct plimit *lim_copy(struct plimit *lim);
110 void lim_addref(struct plimit *lim);
111 void lim_privatise(struct proc *p, bool set_shared);
112 void limfree(struct plimit *);
113
114 void resource_init(void);
115 void ruadd(struct rusage *, struct rusage *);
116 void rulwps(proc_t *, struct rusage *);
117 struct pstats *pstatscopy(struct pstats *);
118 void pstatsfree(struct pstats *);
119 extern rlim_t maxdmap;
120 extern rlim_t maxsmap;
121 #endif
122 #endif /* !_SYS_RESOURCEVAR_H_ */
Cache object: cfaa388d38bc1d00c8384ea6112ab86c
|