xref: /illumos-gate/usr/src/uts/common/sys/rctl.h (revision 7c478bd9)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef	_SYS_RCTL_H
28*7c478bd9Sstevel@tonic-gate #define	_SYS_RCTL_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #include <sys/kmem.h>
33*7c478bd9Sstevel@tonic-gate #include <sys/resource.h>
34*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
37*7c478bd9Sstevel@tonic-gate extern "C" {
38*7c478bd9Sstevel@tonic-gate #endif
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate /*
41*7c478bd9Sstevel@tonic-gate  * Available local actions and flags.
42*7c478bd9Sstevel@tonic-gate  */
43*7c478bd9Sstevel@tonic-gate #define	RCTL_LOCAL_NOACTION		0x00000000
44*7c478bd9Sstevel@tonic-gate #define	RCTL_LOCAL_SIGNAL		0x00000001
45*7c478bd9Sstevel@tonic-gate #define	RCTL_LOCAL_DENY			0x00000002
46*7c478bd9Sstevel@tonic-gate 
47*7c478bd9Sstevel@tonic-gate #define	RCTL_LOCAL_MAXIMAL		0x80000000
48*7c478bd9Sstevel@tonic-gate 
49*7c478bd9Sstevel@tonic-gate #define	RCTL_LOCAL_ACTION_MASK		0xffff0000
50*7c478bd9Sstevel@tonic-gate #define	RCTL_LOCAL_MASK			0x80000003
51*7c478bd9Sstevel@tonic-gate 
52*7c478bd9Sstevel@tonic-gate /*
53*7c478bd9Sstevel@tonic-gate  * Available global actions and flags.
54*7c478bd9Sstevel@tonic-gate  */
55*7c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_NOACTION		0x00000000
56*7c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_SYSLOG		0x00000001
57*7c478bd9Sstevel@tonic-gate 
58*7c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_NOBASIC		0x80000000
59*7c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_LOWERABLE		0x40000000
60*7c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_DENY_ALWAYS		0x20000000
61*7c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_DENY_NEVER		0x10000000
62*7c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_FILE_SIZE		0x08000000
63*7c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_CPU_TIME		0x04000000
64*7c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_SIGNAL_NEVER	0x02000000
65*7c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_NOLOCALACTION	RCTL_GLOBAL_SIGNAL_NEVER
66*7c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_INFINITE		0x01000000
67*7c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_UNOBSERVABLE	0x00800000
68*7c478bd9Sstevel@tonic-gate 
69*7c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_BYTES		0x00400000
70*7c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_SECONDS		0x00200000
71*7c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_COUNT		0x00100000
72*7c478bd9Sstevel@tonic-gate 
73*7c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_ACTION_MASK		0xffff0000
74*7c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_MASK		0xff700001
75*7c478bd9Sstevel@tonic-gate 
76*7c478bd9Sstevel@tonic-gate /*
77*7c478bd9Sstevel@tonic-gate  * getrctl(2) flag values
78*7c478bd9Sstevel@tonic-gate  */
79*7c478bd9Sstevel@tonic-gate #define	RCTL_FIRST		0x00000000
80*7c478bd9Sstevel@tonic-gate #define	RCTL_NEXT		0x00000001
81*7c478bd9Sstevel@tonic-gate #define	RCTL_USAGE		0x00000002
82*7c478bd9Sstevel@tonic-gate 
83*7c478bd9Sstevel@tonic-gate /*
84*7c478bd9Sstevel@tonic-gate  * setrctl(2) flag values
85*7c478bd9Sstevel@tonic-gate  */
86*7c478bd9Sstevel@tonic-gate 
87*7c478bd9Sstevel@tonic-gate #define	RCTL_INSERT		0x00000000
88*7c478bd9Sstevel@tonic-gate #define	RCTL_DELETE		0x00000001
89*7c478bd9Sstevel@tonic-gate #define	RCTL_REPLACE		0x00000002
90*7c478bd9Sstevel@tonic-gate 
91*7c478bd9Sstevel@tonic-gate #define	RCTL_USE_RECIPIENT_PID	0x10000000
92*7c478bd9Sstevel@tonic-gate 
93*7c478bd9Sstevel@tonic-gate #define	RCTLSYS_ACTION_MASK 	0xffff0000
94*7c478bd9Sstevel@tonic-gate #define	RCTLSYS_MASK		0x10000003
95*7c478bd9Sstevel@tonic-gate 
96*7c478bd9Sstevel@tonic-gate /*
97*7c478bd9Sstevel@tonic-gate  * rctl_priv_t: rctl privilege defined values
98*7c478bd9Sstevel@tonic-gate  *   A large amount of space has been deliberately left between these privileges
99*7c478bd9Sstevel@tonic-gate  *   to permit future enrichment of the control privilege value.
100*7c478bd9Sstevel@tonic-gate  */
101*7c478bd9Sstevel@tonic-gate #define	RCPRIV_BASIC		0x01000000
102*7c478bd9Sstevel@tonic-gate #define	RCPRIV_PRIVILEGED	0x04000000
103*7c478bd9Sstevel@tonic-gate #define	RCPRIV_SYSTEM		0x07000000
104*7c478bd9Sstevel@tonic-gate 
105*7c478bd9Sstevel@tonic-gate typedef u_longlong_t rctl_qty_t; /* resource control numerical values   */
106*7c478bd9Sstevel@tonic-gate typedef int rctl_priv_t;
107*7c478bd9Sstevel@tonic-gate 
108*7c478bd9Sstevel@tonic-gate typedef struct rctlblk rctlblk_t;
109*7c478bd9Sstevel@tonic-gate 
110*7c478bd9Sstevel@tonic-gate extern int setrctl(const char *, rctlblk_t *, rctlblk_t *, int);
111*7c478bd9Sstevel@tonic-gate extern int getrctl(const char *, rctlblk_t *, rctlblk_t *, int);
112*7c478bd9Sstevel@tonic-gate 
113*7c478bd9Sstevel@tonic-gate typedef enum {
114*7c478bd9Sstevel@tonic-gate 	RCENTITY_PROCESS,
115*7c478bd9Sstevel@tonic-gate 	RCENTITY_TASK,
116*7c478bd9Sstevel@tonic-gate 	RCENTITY_PROJECT,
117*7c478bd9Sstevel@tonic-gate 	RCENTITY_ZONE
118*7c478bd9Sstevel@tonic-gate } rctl_entity_t;
119*7c478bd9Sstevel@tonic-gate #define	RC_MAX_ENTITY RCENTITY_ZONE
120*7c478bd9Sstevel@tonic-gate 
121*7c478bd9Sstevel@tonic-gate #ifndef _KERNEL
122*7c478bd9Sstevel@tonic-gate 
123*7c478bd9Sstevel@tonic-gate typedef struct rctl_set rctl_set_t;
124*7c478bd9Sstevel@tonic-gate 
125*7c478bd9Sstevel@tonic-gate #else /* _KERNEL */
126*7c478bd9Sstevel@tonic-gate 
127*7c478bd9Sstevel@tonic-gate #include <sys/mutex.h>
128*7c478bd9Sstevel@tonic-gate 
129*7c478bd9Sstevel@tonic-gate /*
130*7c478bd9Sstevel@tonic-gate  * rctl_test return bitfield
131*7c478bd9Sstevel@tonic-gate  */
132*7c478bd9Sstevel@tonic-gate #define	RCT_NONE		0x00000000
133*7c478bd9Sstevel@tonic-gate #define	RCT_DENY		0x00000001
134*7c478bd9Sstevel@tonic-gate #define	RCT_SIGNAL		0x00000002
135*7c478bd9Sstevel@tonic-gate #define	RCT_STRLOG		0x00000004
136*7c478bd9Sstevel@tonic-gate 
137*7c478bd9Sstevel@tonic-gate #define	RCT_LK_ABANDONED	0x80000000
138*7c478bd9Sstevel@tonic-gate 
139*7c478bd9Sstevel@tonic-gate /*
140*7c478bd9Sstevel@tonic-gate  * rctl_set_dup flags
141*7c478bd9Sstevel@tonic-gate  */
142*7c478bd9Sstevel@tonic-gate #define	RCD_DUP			0x1
143*7c478bd9Sstevel@tonic-gate #define	RCD_CALLBACK		0x2
144*7c478bd9Sstevel@tonic-gate 
145*7c478bd9Sstevel@tonic-gate /*
146*7c478bd9Sstevel@tonic-gate  * rctl_action/rctl_test action safety states
147*7c478bd9Sstevel@tonic-gate  */
148*7c478bd9Sstevel@tonic-gate #define	RCA_SAFE		0x0 /* safe for signal and siginfo delivery */
149*7c478bd9Sstevel@tonic-gate #define	RCA_UNSAFE_SIGINFO	0x1 /* not safe to allocate for siginfo */
150*7c478bd9Sstevel@tonic-gate #define	RCA_UNSAFE_ALL		0x2 /* not safe to send signal */
151*7c478bd9Sstevel@tonic-gate 
152*7c478bd9Sstevel@tonic-gate typedef struct rctl_val {
153*7c478bd9Sstevel@tonic-gate 	struct rctl_val *rcv_prev;		/* previous (lower) value */
154*7c478bd9Sstevel@tonic-gate 	struct rctl_val *rcv_next;		/* next (higher) value */
155*7c478bd9Sstevel@tonic-gate 	rctl_priv_t	rcv_privilege;		/* appropriate RCPRIV_* cst */
156*7c478bd9Sstevel@tonic-gate 	rctl_qty_t	rcv_value;		/* enforced value of control */
157*7c478bd9Sstevel@tonic-gate 	uint_t		rcv_flagaction;		/* properties and actions */
158*7c478bd9Sstevel@tonic-gate 	int		rcv_action_signal;	/* signal to send as action */
159*7c478bd9Sstevel@tonic-gate 	struct proc	*rcv_action_recipient;	/* process to receive signal */
160*7c478bd9Sstevel@tonic-gate 	id_t		rcv_action_recip_pid;	/* pid of that process */
161*7c478bd9Sstevel@tonic-gate 	hrtime_t	rcv_firing_time;	/* time rctl_val last fired */
162*7c478bd9Sstevel@tonic-gate } rctl_val_t;
163*7c478bd9Sstevel@tonic-gate 
164*7c478bd9Sstevel@tonic-gate typedef int rctl_hndl_t;
165*7c478bd9Sstevel@tonic-gate 
166*7c478bd9Sstevel@tonic-gate struct rctl;
167*7c478bd9Sstevel@tonic-gate struct proc;
168*7c478bd9Sstevel@tonic-gate struct task;
169*7c478bd9Sstevel@tonic-gate struct kproject;
170*7c478bd9Sstevel@tonic-gate struct zone;
171*7c478bd9Sstevel@tonic-gate 
172*7c478bd9Sstevel@tonic-gate typedef struct rctl_entity_p_struct {
173*7c478bd9Sstevel@tonic-gate 	rctl_entity_t rcep_t;
174*7c478bd9Sstevel@tonic-gate 	union {
175*7c478bd9Sstevel@tonic-gate 		struct proc *proc;
176*7c478bd9Sstevel@tonic-gate 		struct task *task;
177*7c478bd9Sstevel@tonic-gate 		struct kproject *proj;
178*7c478bd9Sstevel@tonic-gate 		struct zone *zone;
179*7c478bd9Sstevel@tonic-gate 	} rcep_p;
180*7c478bd9Sstevel@tonic-gate } rctl_entity_p_t;
181*7c478bd9Sstevel@tonic-gate 
182*7c478bd9Sstevel@tonic-gate typedef struct rctl_ops {
183*7c478bd9Sstevel@tonic-gate 	void		(*rco_action)(struct rctl *, struct proc *,
184*7c478bd9Sstevel@tonic-gate 	    rctl_entity_p_t *);
185*7c478bd9Sstevel@tonic-gate 	rctl_qty_t	(*rco_get_usage)(struct rctl *, struct proc *);
186*7c478bd9Sstevel@tonic-gate 	int		(*rco_set)(struct rctl *, struct proc *,
187*7c478bd9Sstevel@tonic-gate 	    rctl_entity_p_t *, rctl_qty_t);
188*7c478bd9Sstevel@tonic-gate 	int		(*rco_test)(struct rctl *, struct proc *,
189*7c478bd9Sstevel@tonic-gate 	    rctl_entity_p_t *, rctl_val_t *, rctl_qty_t, uint_t);
190*7c478bd9Sstevel@tonic-gate } rctl_ops_t;
191*7c478bd9Sstevel@tonic-gate 
192*7c478bd9Sstevel@tonic-gate #define	RCTLOP_ACTION(r, p, e) (r->rc_dict_entry->rcd_ops->rco_action(r, p, e))
193*7c478bd9Sstevel@tonic-gate #define	RCTLOP_GET_USAGE(r, p) (r->rc_dict_entry->rcd_ops->rco_get_usage(r, p))
194*7c478bd9Sstevel@tonic-gate #define	RCTLOP_SET(r, p, e, v) (r->rc_dict_entry->rcd_ops->rco_set(r, p, e, v))
195*7c478bd9Sstevel@tonic-gate #define	RCTLOP_TEST(r, p, e, v, i, f) \
196*7c478bd9Sstevel@tonic-gate 	(r->rc_dict_entry->rcd_ops->rco_test(r, p, e, v, i, f))
197*7c478bd9Sstevel@tonic-gate 
198*7c478bd9Sstevel@tonic-gate /*
199*7c478bd9Sstevel@tonic-gate  * Default resource control callback functions.
200*7c478bd9Sstevel@tonic-gate  */
201*7c478bd9Sstevel@tonic-gate void rcop_no_action(struct rctl *, struct proc *, rctl_entity_p_t *);
202*7c478bd9Sstevel@tonic-gate rctl_qty_t rcop_no_usage(struct rctl *, struct proc *);
203*7c478bd9Sstevel@tonic-gate int rcop_no_set(struct rctl *, struct proc *, rctl_entity_p_t *, rctl_qty_t);
204*7c478bd9Sstevel@tonic-gate int rcop_no_test(struct rctl *, struct proc *, rctl_entity_p_t *,
205*7c478bd9Sstevel@tonic-gate     struct rctl_val *, rctl_qty_t, uint_t);
206*7c478bd9Sstevel@tonic-gate int rcop_absolute_test(struct rctl *, struct proc *, rctl_entity_p_t *,
207*7c478bd9Sstevel@tonic-gate     struct rctl_val *, rctl_qty_t, uint_t);
208*7c478bd9Sstevel@tonic-gate 
209*7c478bd9Sstevel@tonic-gate extern rctl_ops_t rctl_default_ops;
210*7c478bd9Sstevel@tonic-gate extern rctl_ops_t rctl_absolute_ops;
211*7c478bd9Sstevel@tonic-gate 
212*7c478bd9Sstevel@tonic-gate typedef struct rctl {
213*7c478bd9Sstevel@tonic-gate 	struct rctl	*rc_next;		/* next in set hash chain    */
214*7c478bd9Sstevel@tonic-gate 	rctl_val_t	*rc_values;		/* list of enforced value    */
215*7c478bd9Sstevel@tonic-gate 	rctl_val_t	*rc_cursor;		/* currently enforced value  */
216*7c478bd9Sstevel@tonic-gate 	struct rctl_dict_entry *rc_dict_entry;	/* global control properties */
217*7c478bd9Sstevel@tonic-gate 	rctl_hndl_t	rc_id;			/* control handle (hash key) */
218*7c478bd9Sstevel@tonic-gate } rctl_t;
219*7c478bd9Sstevel@tonic-gate 
220*7c478bd9Sstevel@tonic-gate /*
221*7c478bd9Sstevel@tonic-gate  * The rctl_set is the collection of resource controls associated with an
222*7c478bd9Sstevel@tonic-gate  * individual entity within the system.  All of the controls are applicable to
223*7c478bd9Sstevel@tonic-gate  * the same entity, which we call out explicitly in rcs_entity.
224*7c478bd9Sstevel@tonic-gate  */
225*7c478bd9Sstevel@tonic-gate typedef struct rctl_set {
226*7c478bd9Sstevel@tonic-gate 	kmutex_t	rcs_lock;		/* global set lock	  */
227*7c478bd9Sstevel@tonic-gate 	rctl_entity_t	rcs_entity;		/* entity type		  */
228*7c478bd9Sstevel@tonic-gate 	rctl_t		**rcs_ctls;		/* hash table of controls */
229*7c478bd9Sstevel@tonic-gate } rctl_set_t;
230*7c478bd9Sstevel@tonic-gate 
231*7c478bd9Sstevel@tonic-gate typedef struct rctl_dict_entry {
232*7c478bd9Sstevel@tonic-gate 	struct rctl_dict_entry *rcd_next;	/* next in dict hash chain */
233*7c478bd9Sstevel@tonic-gate 	char		*rcd_name;		/* resource control name */
234*7c478bd9Sstevel@tonic-gate 	rctl_val_t	*rcd_default_value;	/* system control value */
235*7c478bd9Sstevel@tonic-gate 	rctl_ops_t	*rcd_ops;		/* callback operations */
236*7c478bd9Sstevel@tonic-gate 	rctl_hndl_t	rcd_id;			/* control handle */
237*7c478bd9Sstevel@tonic-gate 	rctl_entity_t	rcd_entity;		/* entity type */
238*7c478bd9Sstevel@tonic-gate 	int		rcd_flagaction;		/* global properties/actions */
239*7c478bd9Sstevel@tonic-gate 	int		rcd_syslog_level;	/* event syslog level */
240*7c478bd9Sstevel@tonic-gate 	int		rcd_strlog_flags;	/* derived from syslog level */
241*7c478bd9Sstevel@tonic-gate 	rctl_qty_t	rcd_max_native;		/* native model "infinity" */
242*7c478bd9Sstevel@tonic-gate 	rctl_qty_t	rcd_max_ilp32;		/* ILP32 model "infinity" */
243*7c478bd9Sstevel@tonic-gate } rctl_dict_entry_t;
244*7c478bd9Sstevel@tonic-gate 
245*7c478bd9Sstevel@tonic-gate typedef struct rctl_alloc_gp {
246*7c478bd9Sstevel@tonic-gate 	uint_t	rcag_nctls;	/* number of rctls needed/allocated */
247*7c478bd9Sstevel@tonic-gate 	uint_t	rcag_nvals;	/* number of rctl values needed/allocated */
248*7c478bd9Sstevel@tonic-gate 	rctl_t	*rcag_ctls;	/* list of allocated rctls */
249*7c478bd9Sstevel@tonic-gate 	rctl_val_t *rcag_vals;	/* list of allocated rctl values */
250*7c478bd9Sstevel@tonic-gate } rctl_alloc_gp_t;
251*7c478bd9Sstevel@tonic-gate 
252*7c478bd9Sstevel@tonic-gate extern kmem_cache_t *rctl_cache;	/* kmem cache for rctl structures */
253*7c478bd9Sstevel@tonic-gate extern kmem_cache_t *rctl_val_cache;	/* kmem cache for rctl values */
254*7c478bd9Sstevel@tonic-gate 
255*7c478bd9Sstevel@tonic-gate extern rctl_hndl_t rctlproc_legacy[];
256*7c478bd9Sstevel@tonic-gate extern uint_t rctlproc_flags[];
257*7c478bd9Sstevel@tonic-gate extern int rctlproc_signals[];
258*7c478bd9Sstevel@tonic-gate 
259*7c478bd9Sstevel@tonic-gate void rctl_init(void);
260*7c478bd9Sstevel@tonic-gate void rctlproc_init(void);
261*7c478bd9Sstevel@tonic-gate void rctlproc_default_init(struct proc *, rctl_alloc_gp_t *);
262*7c478bd9Sstevel@tonic-gate 
263*7c478bd9Sstevel@tonic-gate rctl_hndl_t rctl_register(const char *, rctl_entity_t, int, rctl_qty_t,
264*7c478bd9Sstevel@tonic-gate     rctl_qty_t, rctl_ops_t *);
265*7c478bd9Sstevel@tonic-gate 
266*7c478bd9Sstevel@tonic-gate rctl_hndl_t rctl_hndl_lookup(const char *);
267*7c478bd9Sstevel@tonic-gate rctl_dict_entry_t *rctl_dict_lookup(const char *);
268*7c478bd9Sstevel@tonic-gate rctl_dict_entry_t *rctl_dict_lookup_hndl(rctl_hndl_t);
269*7c478bd9Sstevel@tonic-gate void rctl_add_default_limit(const char *, rctl_qty_t, rctl_priv_t, uint_t);
270*7c478bd9Sstevel@tonic-gate void rctl_add_legacy_limit(const char *, const char *, const char *,
271*7c478bd9Sstevel@tonic-gate     rctl_qty_t, rctl_qty_t);
272*7c478bd9Sstevel@tonic-gate 
273*7c478bd9Sstevel@tonic-gate rctl_qty_t rctl_model_maximum(rctl_dict_entry_t *, struct proc *);
274*7c478bd9Sstevel@tonic-gate rctl_qty_t rctl_model_value(rctl_dict_entry_t *, struct proc *, rctl_qty_t);
275*7c478bd9Sstevel@tonic-gate 
276*7c478bd9Sstevel@tonic-gate int rctl_invalid_value(rctl_dict_entry_t *, rctl_val_t *);
277*7c478bd9Sstevel@tonic-gate rctl_qty_t rctl_enforced_value(rctl_hndl_t, rctl_set_t *, struct proc *);
278*7c478bd9Sstevel@tonic-gate 
279*7c478bd9Sstevel@tonic-gate int rctl_test(rctl_hndl_t, rctl_set_t *, struct proc *, rctl_qty_t, uint_t);
280*7c478bd9Sstevel@tonic-gate int rctl_action(rctl_hndl_t, rctl_set_t *, struct proc *, uint_t);
281*7c478bd9Sstevel@tonic-gate 
282*7c478bd9Sstevel@tonic-gate int rctl_test_entity(rctl_hndl_t, rctl_set_t *, struct proc *,
283*7c478bd9Sstevel@tonic-gate     rctl_entity_p_t *, rctl_qty_t, uint_t);
284*7c478bd9Sstevel@tonic-gate int rctl_action_entity(rctl_hndl_t, rctl_set_t *, struct proc *,
285*7c478bd9Sstevel@tonic-gate     rctl_entity_p_t *, uint_t);
286*7c478bd9Sstevel@tonic-gate 
287*7c478bd9Sstevel@tonic-gate int rctl_val_cmp(rctl_val_t *, rctl_val_t *, int);
288*7c478bd9Sstevel@tonic-gate int rctl_val_list_insert(rctl_val_t **, rctl_val_t *);
289*7c478bd9Sstevel@tonic-gate 
290*7c478bd9Sstevel@tonic-gate rctl_set_t *rctl_set_create(void);
291*7c478bd9Sstevel@tonic-gate rctl_alloc_gp_t *rctl_set_init_prealloc(rctl_entity_t);
292*7c478bd9Sstevel@tonic-gate rctl_set_t *rctl_set_init(rctl_entity_t, struct proc *, rctl_entity_p_t *,
293*7c478bd9Sstevel@tonic-gate     rctl_set_t *, rctl_alloc_gp_t *);
294*7c478bd9Sstevel@tonic-gate rctl_alloc_gp_t *rctl_set_dup_prealloc(rctl_set_t *);
295*7c478bd9Sstevel@tonic-gate int rctl_set_dup_ready(rctl_set_t *, rctl_alloc_gp_t *);
296*7c478bd9Sstevel@tonic-gate rctl_set_t *rctl_set_dup(rctl_set_t *, struct proc *, struct proc *,
297*7c478bd9Sstevel@tonic-gate     rctl_entity_p_t *, rctl_set_t *, rctl_alloc_gp_t *, int);
298*7c478bd9Sstevel@tonic-gate void rctl_set_reset(rctl_set_t *, struct proc *, rctl_entity_p_t *);
299*7c478bd9Sstevel@tonic-gate void rctl_set_tearoff(rctl_set_t *, struct proc *);
300*7c478bd9Sstevel@tonic-gate void rctl_set_free(rctl_set_t *);
301*7c478bd9Sstevel@tonic-gate 
302*7c478bd9Sstevel@tonic-gate void rctl_prealloc_destroy(rctl_alloc_gp_t *);
303*7c478bd9Sstevel@tonic-gate 
304*7c478bd9Sstevel@tonic-gate size_t rctl_build_name_buf(char **);
305*7c478bd9Sstevel@tonic-gate 
306*7c478bd9Sstevel@tonic-gate int rctl_global_get(const char *name, rctl_dict_entry_t *);
307*7c478bd9Sstevel@tonic-gate int rctl_global_set(const char *name, rctl_dict_entry_t *);
308*7c478bd9Sstevel@tonic-gate 
309*7c478bd9Sstevel@tonic-gate int rctl_local_delete(rctl_hndl_t, rctl_val_t *, struct proc *p);
310*7c478bd9Sstevel@tonic-gate int rctl_local_insert(rctl_hndl_t, rctl_val_t *, struct proc *p);
311*7c478bd9Sstevel@tonic-gate int rctl_local_get(rctl_hndl_t, rctl_val_t *, rctl_val_t *, struct proc *p);
312*7c478bd9Sstevel@tonic-gate int rctl_local_replace(rctl_hndl_t, rctl_val_t *, rctl_val_t *,
313*7c478bd9Sstevel@tonic-gate     struct proc *p);
314*7c478bd9Sstevel@tonic-gate 
315*7c478bd9Sstevel@tonic-gate /* tag declaration to appease the compiler */
316*7c478bd9Sstevel@tonic-gate struct cred;
317*7c478bd9Sstevel@tonic-gate rctl_alloc_gp_t *rctl_rlimit_set_prealloc(uint_t);
318*7c478bd9Sstevel@tonic-gate int rctl_rlimit_set(rctl_hndl_t, struct proc *, struct rlimit64 *,
319*7c478bd9Sstevel@tonic-gate     rctl_alloc_gp_t *, int, int, const struct cred *);
320*7c478bd9Sstevel@tonic-gate int rctl_rlimit_get(rctl_hndl_t, struct proc *, struct rlimit64 *);
321*7c478bd9Sstevel@tonic-gate 
322*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
323*7c478bd9Sstevel@tonic-gate 
324*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
325*7c478bd9Sstevel@tonic-gate }
326*7c478bd9Sstevel@tonic-gate #endif
327*7c478bd9Sstevel@tonic-gate 
328*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_RCTL_H */
329