xref: /illumos-gate/usr/src/uts/common/sys/rctl.h (revision 0209230b)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
519f92332Sml93401  * Common Development and Distribution License (the "License").
619f92332Sml93401  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
2219f92332Sml93401  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_SYS_RCTL_H
277c478bd9Sstevel@tonic-gate #define	_SYS_RCTL_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #include <sys/kmem.h>
327c478bd9Sstevel@tonic-gate #include <sys/resource.h>
337c478bd9Sstevel@tonic-gate #include <sys/types.h>
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
367c478bd9Sstevel@tonic-gate extern "C" {
377c478bd9Sstevel@tonic-gate #endif
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate /*
407c478bd9Sstevel@tonic-gate  * Available local actions and flags.
417c478bd9Sstevel@tonic-gate  */
427c478bd9Sstevel@tonic-gate #define	RCTL_LOCAL_NOACTION		0x00000000
437c478bd9Sstevel@tonic-gate #define	RCTL_LOCAL_SIGNAL		0x00000001
447c478bd9Sstevel@tonic-gate #define	RCTL_LOCAL_DENY			0x00000002
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate #define	RCTL_LOCAL_MAXIMAL		0x80000000
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate #define	RCTL_LOCAL_ACTION_MASK		0xffff0000
497c478bd9Sstevel@tonic-gate #define	RCTL_LOCAL_MASK			0x80000003
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate /*
527c478bd9Sstevel@tonic-gate  * Available global actions and flags.
537c478bd9Sstevel@tonic-gate  */
547c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_NOACTION		0x00000000
557c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_SYSLOG		0x00000001
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_NOBASIC		0x80000000
587c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_LOWERABLE		0x40000000
597c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_DENY_ALWAYS		0x20000000
607c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_DENY_NEVER		0x10000000
617c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_FILE_SIZE		0x08000000
627c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_CPU_TIME		0x04000000
637c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_SIGNAL_NEVER	0x02000000
647c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_NOLOCALACTION	RCTL_GLOBAL_SIGNAL_NEVER
657c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_INFINITE		0x01000000
667c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_UNOBSERVABLE	0x00800000
6719f92332Sml93401 #define	RCTL_GLOBAL_SYSLOG_NEVER	0x00080000
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_BYTES		0x00400000
707c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_SECONDS		0x00200000
717c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_COUNT		0x00100000
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_ACTION_MASK		0xffff0000
7419f92332Sml93401 #define	RCTL_GLOBAL_MASK		0xfff80001
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate /*
777c478bd9Sstevel@tonic-gate  * getrctl(2) flag values
787c478bd9Sstevel@tonic-gate  */
797c478bd9Sstevel@tonic-gate #define	RCTL_FIRST		0x00000000
807c478bd9Sstevel@tonic-gate #define	RCTL_NEXT		0x00000001
817c478bd9Sstevel@tonic-gate #define	RCTL_USAGE		0x00000002
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate /*
847c478bd9Sstevel@tonic-gate  * setrctl(2) flag values
857c478bd9Sstevel@tonic-gate  */
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate #define	RCTL_INSERT		0x00000000
887c478bd9Sstevel@tonic-gate #define	RCTL_DELETE		0x00000001
897c478bd9Sstevel@tonic-gate #define	RCTL_REPLACE		0x00000002
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate #define	RCTL_USE_RECIPIENT_PID	0x10000000
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate #define	RCTLSYS_ACTION_MASK 	0xffff0000
947c478bd9Sstevel@tonic-gate #define	RCTLSYS_MASK		0x10000003
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate /*
977c478bd9Sstevel@tonic-gate  * rctl_priv_t: rctl privilege defined values
987c478bd9Sstevel@tonic-gate  *   A large amount of space has been deliberately left between these privileges
997c478bd9Sstevel@tonic-gate  *   to permit future enrichment of the control privilege value.
1007c478bd9Sstevel@tonic-gate  */
1017c478bd9Sstevel@tonic-gate #define	RCPRIV_BASIC		0x01000000
1027c478bd9Sstevel@tonic-gate #define	RCPRIV_PRIVILEGED	0x04000000
1037c478bd9Sstevel@tonic-gate #define	RCPRIV_SYSTEM		0x07000000
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate typedef u_longlong_t rctl_qty_t; /* resource control numerical values   */
1067c478bd9Sstevel@tonic-gate typedef int rctl_priv_t;
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate typedef struct rctlblk rctlblk_t;
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate extern int setrctl(const char *, rctlblk_t *, rctlblk_t *, int);
1117c478bd9Sstevel@tonic-gate extern int getrctl(const char *, rctlblk_t *, rctlblk_t *, int);
1127c478bd9Sstevel@tonic-gate 
1137c478bd9Sstevel@tonic-gate typedef enum {
1147c478bd9Sstevel@tonic-gate 	RCENTITY_PROCESS,
1157c478bd9Sstevel@tonic-gate 	RCENTITY_TASK,
1167c478bd9Sstevel@tonic-gate 	RCENTITY_PROJECT,
1177c478bd9Sstevel@tonic-gate 	RCENTITY_ZONE
1187c478bd9Sstevel@tonic-gate } rctl_entity_t;
1197c478bd9Sstevel@tonic-gate #define	RC_MAX_ENTITY RCENTITY_ZONE
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate #ifndef _KERNEL
1227c478bd9Sstevel@tonic-gate 
1237c478bd9Sstevel@tonic-gate typedef struct rctl_set rctl_set_t;
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate #else /* _KERNEL */
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate #include <sys/mutex.h>
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate /*
1307c478bd9Sstevel@tonic-gate  * rctl_test return bitfield
1317c478bd9Sstevel@tonic-gate  */
1327c478bd9Sstevel@tonic-gate #define	RCT_NONE		0x00000000
1337c478bd9Sstevel@tonic-gate #define	RCT_DENY		0x00000001
1347c478bd9Sstevel@tonic-gate #define	RCT_SIGNAL		0x00000002
1357c478bd9Sstevel@tonic-gate #define	RCT_STRLOG		0x00000004
1367c478bd9Sstevel@tonic-gate 
1377c478bd9Sstevel@tonic-gate #define	RCT_LK_ABANDONED	0x80000000
1387c478bd9Sstevel@tonic-gate 
1397c478bd9Sstevel@tonic-gate /*
1407c478bd9Sstevel@tonic-gate  * rctl_set_dup flags
1417c478bd9Sstevel@tonic-gate  */
1427c478bd9Sstevel@tonic-gate #define	RCD_DUP			0x1
1437c478bd9Sstevel@tonic-gate #define	RCD_CALLBACK		0x2
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate /*
1467c478bd9Sstevel@tonic-gate  * rctl_action/rctl_test action safety states
1477c478bd9Sstevel@tonic-gate  */
1487c478bd9Sstevel@tonic-gate #define	RCA_SAFE		0x0 /* safe for signal and siginfo delivery */
1497c478bd9Sstevel@tonic-gate #define	RCA_UNSAFE_SIGINFO	0x1 /* not safe to allocate for siginfo */
1507c478bd9Sstevel@tonic-gate #define	RCA_UNSAFE_ALL		0x2 /* not safe to send signal */
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate typedef struct rctl_val {
1537c478bd9Sstevel@tonic-gate 	struct rctl_val *rcv_prev;		/* previous (lower) value */
1547c478bd9Sstevel@tonic-gate 	struct rctl_val *rcv_next;		/* next (higher) value */
1557c478bd9Sstevel@tonic-gate 	rctl_priv_t	rcv_privilege;		/* appropriate RCPRIV_* cst */
1567c478bd9Sstevel@tonic-gate 	rctl_qty_t	rcv_value;		/* enforced value of control */
1577c478bd9Sstevel@tonic-gate 	uint_t		rcv_flagaction;		/* properties and actions */
1587c478bd9Sstevel@tonic-gate 	int		rcv_action_signal;	/* signal to send as action */
1597c478bd9Sstevel@tonic-gate 	struct proc	*rcv_action_recipient;	/* process to receive signal */
1607c478bd9Sstevel@tonic-gate 	id_t		rcv_action_recip_pid;	/* pid of that process */
1617c478bd9Sstevel@tonic-gate 	hrtime_t	rcv_firing_time;	/* time rctl_val last fired */
1627c478bd9Sstevel@tonic-gate } rctl_val_t;
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate typedef int rctl_hndl_t;
1657c478bd9Sstevel@tonic-gate 
1667c478bd9Sstevel@tonic-gate struct rctl;
1677c478bd9Sstevel@tonic-gate struct proc;
1687c478bd9Sstevel@tonic-gate struct task;
1697c478bd9Sstevel@tonic-gate struct kproject;
1707c478bd9Sstevel@tonic-gate struct zone;
171*0209230bSgjelinek struct kstat;
1727c478bd9Sstevel@tonic-gate 
1737c478bd9Sstevel@tonic-gate typedef struct rctl_entity_p_struct {
1747c478bd9Sstevel@tonic-gate 	rctl_entity_t rcep_t;
1757c478bd9Sstevel@tonic-gate 	union {
1767c478bd9Sstevel@tonic-gate 		struct proc *proc;
1777c478bd9Sstevel@tonic-gate 		struct task *task;
1787c478bd9Sstevel@tonic-gate 		struct kproject *proj;
1797c478bd9Sstevel@tonic-gate 		struct zone *zone;
1807c478bd9Sstevel@tonic-gate 	} rcep_p;
1817c478bd9Sstevel@tonic-gate } rctl_entity_p_t;
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate typedef struct rctl_ops {
1847c478bd9Sstevel@tonic-gate 	void		(*rco_action)(struct rctl *, struct proc *,
1857c478bd9Sstevel@tonic-gate 	    rctl_entity_p_t *);
1867c478bd9Sstevel@tonic-gate 	rctl_qty_t	(*rco_get_usage)(struct rctl *, struct proc *);
1877c478bd9Sstevel@tonic-gate 	int		(*rco_set)(struct rctl *, struct proc *,
1887c478bd9Sstevel@tonic-gate 	    rctl_entity_p_t *, rctl_qty_t);
1897c478bd9Sstevel@tonic-gate 	int		(*rco_test)(struct rctl *, struct proc *,
1907c478bd9Sstevel@tonic-gate 	    rctl_entity_p_t *, rctl_val_t *, rctl_qty_t, uint_t);
1917c478bd9Sstevel@tonic-gate } rctl_ops_t;
1927c478bd9Sstevel@tonic-gate 
1937c478bd9Sstevel@tonic-gate #define	RCTLOP_ACTION(r, p, e) (r->rc_dict_entry->rcd_ops->rco_action(r, p, e))
1947c478bd9Sstevel@tonic-gate #define	RCTLOP_GET_USAGE(r, p) (r->rc_dict_entry->rcd_ops->rco_get_usage(r, p))
1957c478bd9Sstevel@tonic-gate #define	RCTLOP_SET(r, p, e, v) (r->rc_dict_entry->rcd_ops->rco_set(r, p, e, v))
1967c478bd9Sstevel@tonic-gate #define	RCTLOP_TEST(r, p, e, v, i, f) \
1977c478bd9Sstevel@tonic-gate 	(r->rc_dict_entry->rcd_ops->rco_test(r, p, e, v, i, f))
1987c478bd9Sstevel@tonic-gate 
1997c478bd9Sstevel@tonic-gate /*
2007c478bd9Sstevel@tonic-gate  * Default resource control callback functions.
2017c478bd9Sstevel@tonic-gate  */
2027c478bd9Sstevel@tonic-gate void rcop_no_action(struct rctl *, struct proc *, rctl_entity_p_t *);
2037c478bd9Sstevel@tonic-gate rctl_qty_t rcop_no_usage(struct rctl *, struct proc *);
2047c478bd9Sstevel@tonic-gate int rcop_no_set(struct rctl *, struct proc *, rctl_entity_p_t *, rctl_qty_t);
2057c478bd9Sstevel@tonic-gate int rcop_no_test(struct rctl *, struct proc *, rctl_entity_p_t *,
2067c478bd9Sstevel@tonic-gate     struct rctl_val *, rctl_qty_t, uint_t);
2077c478bd9Sstevel@tonic-gate int rcop_absolute_test(struct rctl *, struct proc *, rctl_entity_p_t *,
2087c478bd9Sstevel@tonic-gate     struct rctl_val *, rctl_qty_t, uint_t);
2097c478bd9Sstevel@tonic-gate 
2107c478bd9Sstevel@tonic-gate extern rctl_ops_t rctl_default_ops;
2117c478bd9Sstevel@tonic-gate extern rctl_ops_t rctl_absolute_ops;
2127c478bd9Sstevel@tonic-gate 
2137c478bd9Sstevel@tonic-gate typedef struct rctl {
2147c478bd9Sstevel@tonic-gate 	struct rctl	*rc_next;		/* next in set hash chain    */
2157c478bd9Sstevel@tonic-gate 	rctl_val_t	*rc_values;		/* list of enforced value    */
2167c478bd9Sstevel@tonic-gate 	rctl_val_t	*rc_cursor;		/* currently enforced value  */
2177c478bd9Sstevel@tonic-gate 	struct rctl_dict_entry *rc_dict_entry;	/* global control properties */
2187c478bd9Sstevel@tonic-gate 	rctl_hndl_t	rc_id;			/* control handle (hash key) */
2197c478bd9Sstevel@tonic-gate } rctl_t;
2207c478bd9Sstevel@tonic-gate 
2217c478bd9Sstevel@tonic-gate /*
2227c478bd9Sstevel@tonic-gate  * The rctl_set is the collection of resource controls associated with an
2237c478bd9Sstevel@tonic-gate  * individual entity within the system.  All of the controls are applicable to
2247c478bd9Sstevel@tonic-gate  * the same entity, which we call out explicitly in rcs_entity.
2257c478bd9Sstevel@tonic-gate  */
2267c478bd9Sstevel@tonic-gate typedef struct rctl_set {
2277c478bd9Sstevel@tonic-gate 	kmutex_t	rcs_lock;		/* global set lock	  */
2287c478bd9Sstevel@tonic-gate 	rctl_entity_t	rcs_entity;		/* entity type		  */
2297c478bd9Sstevel@tonic-gate 	rctl_t		**rcs_ctls;		/* hash table of controls */
2307c478bd9Sstevel@tonic-gate } rctl_set_t;
2317c478bd9Sstevel@tonic-gate 
2327c478bd9Sstevel@tonic-gate typedef struct rctl_dict_entry {
2337c478bd9Sstevel@tonic-gate 	struct rctl_dict_entry *rcd_next;	/* next in dict hash chain */
2347c478bd9Sstevel@tonic-gate 	char		*rcd_name;		/* resource control name */
2357c478bd9Sstevel@tonic-gate 	rctl_val_t	*rcd_default_value;	/* system control value */
2367c478bd9Sstevel@tonic-gate 	rctl_ops_t	*rcd_ops;		/* callback operations */
2377c478bd9Sstevel@tonic-gate 	rctl_hndl_t	rcd_id;			/* control handle */
2387c478bd9Sstevel@tonic-gate 	rctl_entity_t	rcd_entity;		/* entity type */
2397c478bd9Sstevel@tonic-gate 	int		rcd_flagaction;		/* global properties/actions */
2407c478bd9Sstevel@tonic-gate 	int		rcd_syslog_level;	/* event syslog level */
2417c478bd9Sstevel@tonic-gate 	int		rcd_strlog_flags;	/* derived from syslog level */
2427c478bd9Sstevel@tonic-gate 	rctl_qty_t	rcd_max_native;		/* native model "infinity" */
2437c478bd9Sstevel@tonic-gate 	rctl_qty_t	rcd_max_ilp32;		/* ILP32 model "infinity" */
2447c478bd9Sstevel@tonic-gate } rctl_dict_entry_t;
2457c478bd9Sstevel@tonic-gate 
2467c478bd9Sstevel@tonic-gate typedef struct rctl_alloc_gp {
2477c478bd9Sstevel@tonic-gate 	uint_t	rcag_nctls;	/* number of rctls needed/allocated */
2487c478bd9Sstevel@tonic-gate 	uint_t	rcag_nvals;	/* number of rctl values needed/allocated */
2497c478bd9Sstevel@tonic-gate 	rctl_t	*rcag_ctls;	/* list of allocated rctls */
2507c478bd9Sstevel@tonic-gate 	rctl_val_t *rcag_vals;	/* list of allocated rctl values */
2517c478bd9Sstevel@tonic-gate } rctl_alloc_gp_t;
2527c478bd9Sstevel@tonic-gate 
2537c478bd9Sstevel@tonic-gate extern kmem_cache_t *rctl_cache;	/* kmem cache for rctl structures */
2547c478bd9Sstevel@tonic-gate extern kmem_cache_t *rctl_val_cache;	/* kmem cache for rctl values */
2557c478bd9Sstevel@tonic-gate 
2567c478bd9Sstevel@tonic-gate extern rctl_hndl_t rctlproc_legacy[];
2577c478bd9Sstevel@tonic-gate extern uint_t rctlproc_flags[];
2587c478bd9Sstevel@tonic-gate extern int rctlproc_signals[];
2597c478bd9Sstevel@tonic-gate 
2607c478bd9Sstevel@tonic-gate void rctl_init(void);
2617c478bd9Sstevel@tonic-gate void rctlproc_init(void);
2627c478bd9Sstevel@tonic-gate void rctlproc_default_init(struct proc *, rctl_alloc_gp_t *);
2637c478bd9Sstevel@tonic-gate 
2647c478bd9Sstevel@tonic-gate rctl_hndl_t rctl_register(const char *, rctl_entity_t, int, rctl_qty_t,
2657c478bd9Sstevel@tonic-gate     rctl_qty_t, rctl_ops_t *);
2667c478bd9Sstevel@tonic-gate 
2677c478bd9Sstevel@tonic-gate rctl_hndl_t rctl_hndl_lookup(const char *);
2687c478bd9Sstevel@tonic-gate rctl_dict_entry_t *rctl_dict_lookup(const char *);
2697c478bd9Sstevel@tonic-gate rctl_dict_entry_t *rctl_dict_lookup_hndl(rctl_hndl_t);
2707c478bd9Sstevel@tonic-gate void rctl_add_default_limit(const char *, rctl_qty_t, rctl_priv_t, uint_t);
2717c478bd9Sstevel@tonic-gate void rctl_add_legacy_limit(const char *, const char *, const char *,
2727c478bd9Sstevel@tonic-gate     rctl_qty_t, rctl_qty_t);
2737c478bd9Sstevel@tonic-gate 
2747c478bd9Sstevel@tonic-gate rctl_qty_t rctl_model_maximum(rctl_dict_entry_t *, struct proc *);
2757c478bd9Sstevel@tonic-gate rctl_qty_t rctl_model_value(rctl_dict_entry_t *, struct proc *, rctl_qty_t);
2767c478bd9Sstevel@tonic-gate 
2777c478bd9Sstevel@tonic-gate int rctl_invalid_value(rctl_dict_entry_t *, rctl_val_t *);
2787c478bd9Sstevel@tonic-gate rctl_qty_t rctl_enforced_value(rctl_hndl_t, rctl_set_t *, struct proc *);
2797c478bd9Sstevel@tonic-gate 
2807c478bd9Sstevel@tonic-gate int rctl_test(rctl_hndl_t, rctl_set_t *, struct proc *, rctl_qty_t, uint_t);
2817c478bd9Sstevel@tonic-gate int rctl_action(rctl_hndl_t, rctl_set_t *, struct proc *, uint_t);
2827c478bd9Sstevel@tonic-gate 
2837c478bd9Sstevel@tonic-gate int rctl_test_entity(rctl_hndl_t, rctl_set_t *, struct proc *,
2847c478bd9Sstevel@tonic-gate     rctl_entity_p_t *, rctl_qty_t, uint_t);
2857c478bd9Sstevel@tonic-gate int rctl_action_entity(rctl_hndl_t, rctl_set_t *, struct proc *,
2867c478bd9Sstevel@tonic-gate     rctl_entity_p_t *, uint_t);
2877c478bd9Sstevel@tonic-gate 
2887c478bd9Sstevel@tonic-gate int rctl_val_cmp(rctl_val_t *, rctl_val_t *, int);
2897c478bd9Sstevel@tonic-gate int rctl_val_list_insert(rctl_val_t **, rctl_val_t *);
2907c478bd9Sstevel@tonic-gate 
2917c478bd9Sstevel@tonic-gate rctl_set_t *rctl_set_create(void);
2927c478bd9Sstevel@tonic-gate rctl_alloc_gp_t *rctl_set_init_prealloc(rctl_entity_t);
2937c478bd9Sstevel@tonic-gate rctl_set_t *rctl_set_init(rctl_entity_t, struct proc *, rctl_entity_p_t *,
2947c478bd9Sstevel@tonic-gate     rctl_set_t *, rctl_alloc_gp_t *);
2957c478bd9Sstevel@tonic-gate rctl_alloc_gp_t *rctl_set_dup_prealloc(rctl_set_t *);
2967c478bd9Sstevel@tonic-gate int rctl_set_dup_ready(rctl_set_t *, rctl_alloc_gp_t *);
2977c478bd9Sstevel@tonic-gate rctl_set_t *rctl_set_dup(rctl_set_t *, struct proc *, struct proc *,
2987c478bd9Sstevel@tonic-gate     rctl_entity_p_t *, rctl_set_t *, rctl_alloc_gp_t *, int);
2997c478bd9Sstevel@tonic-gate void rctl_set_reset(rctl_set_t *, struct proc *, rctl_entity_p_t *);
3007c478bd9Sstevel@tonic-gate void rctl_set_tearoff(rctl_set_t *, struct proc *);
3017c478bd9Sstevel@tonic-gate void rctl_set_free(rctl_set_t *);
3027c478bd9Sstevel@tonic-gate 
3037c478bd9Sstevel@tonic-gate void rctl_prealloc_destroy(rctl_alloc_gp_t *);
3047c478bd9Sstevel@tonic-gate 
3057c478bd9Sstevel@tonic-gate size_t rctl_build_name_buf(char **);
3067c478bd9Sstevel@tonic-gate 
3077c478bd9Sstevel@tonic-gate int rctl_global_get(const char *name, rctl_dict_entry_t *);
3087c478bd9Sstevel@tonic-gate int rctl_global_set(const char *name, rctl_dict_entry_t *);
3097c478bd9Sstevel@tonic-gate 
3107c478bd9Sstevel@tonic-gate int rctl_local_delete(rctl_hndl_t, rctl_val_t *, struct proc *p);
3117c478bd9Sstevel@tonic-gate int rctl_local_insert(rctl_hndl_t, rctl_val_t *, struct proc *p);
3127c478bd9Sstevel@tonic-gate int rctl_local_get(rctl_hndl_t, rctl_val_t *, rctl_val_t *, struct proc *p);
3137c478bd9Sstevel@tonic-gate int rctl_local_replace(rctl_hndl_t, rctl_val_t *, rctl_val_t *,
3147c478bd9Sstevel@tonic-gate     struct proc *p);
3157c478bd9Sstevel@tonic-gate 
3167c478bd9Sstevel@tonic-gate /* tag declaration to appease the compiler */
3177c478bd9Sstevel@tonic-gate struct cred;
3187c478bd9Sstevel@tonic-gate rctl_alloc_gp_t *rctl_rlimit_set_prealloc(uint_t);
3197c478bd9Sstevel@tonic-gate int rctl_rlimit_set(rctl_hndl_t, struct proc *, struct rlimit64 *,
3207c478bd9Sstevel@tonic-gate     rctl_alloc_gp_t *, int, int, const struct cred *);
3217c478bd9Sstevel@tonic-gate int rctl_rlimit_get(rctl_hndl_t, struct proc *, struct rlimit64 *);
3227c478bd9Sstevel@tonic-gate 
323c6939658Ssl108498 /* specific rctl utility functions */
324c6939658Ssl108498 int rctl_incr_locked_mem(struct proc *, struct kproject *, rctl_qty_t,
325c6939658Ssl108498     int);
326c6939658Ssl108498 void rctl_decr_locked_mem(struct proc *, struct kproject *, rctl_qty_t,
327c6939658Ssl108498     int);
328*0209230bSgjelinek int rctl_incr_swap(struct proc *, struct zone *, size_t);
329*0209230bSgjelinek void rctl_decr_swap(struct zone *, size_t);
330*0209230bSgjelinek 
331*0209230bSgjelinek struct kstat *rctl_kstat_create_zone(struct zone *, char *, uchar_t, uint_t,
332*0209230bSgjelinek     uchar_t);
333*0209230bSgjelinek 
334*0209230bSgjelinek struct kstat *rctl_kstat_create_project(struct kproject *, char *, uchar_t,
335*0209230bSgjelinek     uint_t, uchar_t);
336c6939658Ssl108498 
3377c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
3387c478bd9Sstevel@tonic-gate 
3397c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
3407c478bd9Sstevel@tonic-gate }
3417c478bd9Sstevel@tonic-gate #endif
3427c478bd9Sstevel@tonic-gate 
3437c478bd9Sstevel@tonic-gate #endif	/* _SYS_RCTL_H */
344