FreeBSD/Linux Kernel Cross Reference
sys/sys/resourcevar.h
1 /* $NetBSD: resourcevar.h,v 1.32 2006/07/17 11:38:56 martin 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/lock.h>
38
39 /*
40 * Kernel per-process accounting / statistics
41 * (not necessarily resident except when running).
42 */
43 struct pstats {
44 #define pstat_startzero p_ru
45 struct rusage p_ru; /* stats for this proc */
46 struct rusage p_cru; /* sum of stats for reaped children */
47 #define pstat_endzero pstat_startcopy
48
49 #define pstat_startcopy p_timer
50 struct itimerval p_timer[3]; /* virtual-time timers */
51
52 struct uprof { /* profile arguments */
53 caddr_t pr_base; /* buffer base */
54 size_t pr_size; /* buffer size */
55 u_long pr_off; /* pc offset */
56 u_int pr_scale; /* pc scaling */
57 u_long pr_addr; /* temp storage for addr until AST */
58 u_long pr_ticks; /* temp storage for ticks until AST */
59 } p_prof;
60 #define pstat_endcopy p_start
61 struct timeval p_start; /* starting time */
62 };
63
64 /*
65 * Kernel shareable process resource limits. Because this structure
66 * is moderately large but changes infrequently, it is normally
67 * shared copy-on-write after forks. If a group of processes
68 * ("threads") share modifications, the PL_SHAREMOD flag is set,
69 * and a copy must be made for the child of a new fork that isn't
70 * sharing modifications to the limits.
71 */
72 struct plimit {
73 struct rlimit pl_rlimit[RLIM_NLIMITS];
74 char *pl_corename;
75 #define PL_SHAREMOD 0x01 /* modifications are shared */
76 int p_lflags;
77 int p_refcnt; /* number of references */
78 struct simplelock p_slock; /* mutex for p_refcnt */
79 };
80
81 /* add user profiling from AST */
82 #define ADDUPROF(p) \
83 do { \
84 addupc_task(p, \
85 (p)->p_stats->p_prof.pr_addr, \
86 (p)->p_stats->p_prof.pr_ticks); \
87 (p)->p_stats->p_prof.pr_ticks = 0; \
88 } while (/* CONSTCOND */ 0)
89
90 #ifdef _KERNEL
91 /*
92 * Structure associated with user caching.
93 */
94 struct uidinfo {
95 LIST_ENTRY(uidinfo) ui_hash;
96 uid_t ui_uid;
97 long ui_proccnt; /* Number of processes */
98 long ui_lockcnt; /* Number of locks */
99 rlim_t ui_sbsize; /* socket buffer size */
100 struct simplelock ui_slock; /* mutex for everything */
101
102 };
103 #define UIHASH(uid) (&uihashtbl[(uid) & uihash])
104 #define UILOCK(uip, s) \
105 do { \
106 s = splsoftnet(); \
107 simple_lock(&uip->ui_slock); \
108 } while (/*CONSTCOND*/0)
109 #define UIUNLOCK(uip, s) \
110 do { \
111 simple_unlock(&uip->ui_slock); \
112 splx(s); \
113 } while (/*CONSTCOND*/0)
114
115 extern LIST_HEAD(uihashhead, uidinfo) *uihashtbl;
116 extern u_long uihash; /* size of hash table - 1 */
117 int chgproccnt(uid_t, int);
118 int chgsbsize(struct uidinfo *, u_long *, u_long, rlim_t);
119 struct uidinfo *uid_find(uid_t);
120
121 extern char defcorename[];
122
123 extern int security_setidcore_dump;
124 extern char security_setidcore_path[];
125 extern uid_t security_setidcore_owner;
126 extern gid_t security_setidcore_group;
127 extern mode_t security_setidcore_mode;
128
129 void addupc_intr(struct proc *, u_long);
130 void addupc_task(struct proc *, u_long, u_int);
131 void calcru(struct proc *, struct timeval *, struct timeval *,
132 struct timeval *);
133 struct plimit *limcopy(struct plimit *);
134 void limfree(struct plimit *);
135 void ruadd(struct rusage *, struct rusage *);
136 struct pstats *pstatscopy(struct pstats *);
137 void pstatsfree(struct pstats *);
138 extern rlim_t maxdmap;
139 extern rlim_t maxsmap;
140 #endif
141 #endif /* !_SYS_RESOURCEVAR_H_ */
Cache object: b8baa4eee60815df80f6bd2a12a8cd34
|