xref: /illumos-gate/usr/src/uts/common/sys/rctl.h (revision ff19e029)
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
519f92332Sml  * Common Development and Distribution License (the "License").
619f92332Sml  * 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 /*
220fbb751dSJohn Levon  * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
237c478bd9Sstevel@tonic-gate  */
247c478bd9Sstevel@tonic-gate 
257c478bd9Sstevel@tonic-gate #ifndef	_SYS_RCTL_H
267c478bd9Sstevel@tonic-gate #define	_SYS_RCTL_H
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #include <sys/kmem.h>
297c478bd9Sstevel@tonic-gate #include <sys/resource.h>
307c478bd9Sstevel@tonic-gate #include <sys/types.h>
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
337c478bd9Sstevel@tonic-gate extern "C" {
347c478bd9Sstevel@tonic-gate #endif
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate /*
377c478bd9Sstevel@tonic-gate  * Available local actions and flags.
387c478bd9Sstevel@tonic-gate  */
397c478bd9Sstevel@tonic-gate #define	RCTL_LOCAL_NOACTION		0x00000000
407c478bd9Sstevel@tonic-gate #define	RCTL_LOCAL_SIGNAL		0x00000001
417c478bd9Sstevel@tonic-gate #define	RCTL_LOCAL_DENY			0x00000002
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate #define	RCTL_LOCAL_MAXIMAL		0x80000000
44532877c4Srd #define	RCTL_LOCAL_PROJDB		0x40000000
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate #define	RCTL_LOCAL_ACTION_MASK		0xffff0000
47532877c4Srd #define	RCTL_LOCAL_MASK			0xc0000003
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate /*
507c478bd9Sstevel@tonic-gate  * Available global actions and flags.
517c478bd9Sstevel@tonic-gate  */
527c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_NOACTION		0x00000000
537c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_SYSLOG		0x00000001
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_NOBASIC		0x80000000
567c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_LOWERABLE		0x40000000
577c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_DENY_ALWAYS		0x20000000
587c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_DENY_NEVER		0x10000000
597c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_FILE_SIZE		0x08000000
607c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_CPU_TIME		0x04000000
617c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_SIGNAL_NEVER	0x02000000
627c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_NOLOCALACTION	RCTL_GLOBAL_SIGNAL_NEVER
637c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_INFINITE		0x01000000
647c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_UNOBSERVABLE	0x00800000
6519f92332Sml #define	RCTL_GLOBAL_SYSLOG_NEVER	0x00080000
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_BYTES		0x00400000
687c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_SECONDS		0x00200000
697c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_COUNT		0x00100000
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate #define	RCTL_GLOBAL_ACTION_MASK		0xffff0000
7219f92332Sml #define	RCTL_GLOBAL_MASK		0xfff80001
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate /*
757c478bd9Sstevel@tonic-gate  * getrctl(2) flag values
767c478bd9Sstevel@tonic-gate  */
777c478bd9Sstevel@tonic-gate #define	RCTL_FIRST		0x00000000
787c478bd9Sstevel@tonic-gate #define	RCTL_NEXT		0x00000001
797c478bd9Sstevel@tonic-gate #define	RCTL_USAGE		0x00000002
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate /*
827c478bd9Sstevel@tonic-gate  * setrctl(2) flag values
837c478bd9Sstevel@tonic-gate  */
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate #define	RCTL_INSERT		0x00000000
867c478bd9Sstevel@tonic-gate #define	RCTL_DELETE		0x00000001
877c478bd9Sstevel@tonic-gate #define	RCTL_REPLACE		0x00000002
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate #define	RCTL_USE_RECIPIENT_PID	0x10000000
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate #define	RCTLSYS_ACTION_MASK 	0xffff0000
927c478bd9Sstevel@tonic-gate #define	RCTLSYS_MASK		0x10000003
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate /*
957c478bd9Sstevel@tonic-gate  * rctl_priv_t: rctl privilege defined values
967c478bd9Sstevel@tonic-gate  *   A large amount of space has been deliberately left between these privileges
977c478bd9Sstevel@tonic-gate  *   to permit future enrichment of the control privilege value.
987c478bd9Sstevel@tonic-gate  */
997c478bd9Sstevel@tonic-gate #define	RCPRIV_BASIC		0x01000000
1007c478bd9Sstevel@tonic-gate #define	RCPRIV_PRIVILEGED	0x04000000
1017c478bd9Sstevel@tonic-gate #define	RCPRIV_SYSTEM		0x07000000
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate typedef u_longlong_t rctl_qty_t; /* resource control numerical values   */
1047c478bd9Sstevel@tonic-gate typedef int rctl_priv_t;
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate typedef struct rctlblk rctlblk_t;
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate extern int setrctl(const char *, rctlblk_t *, rctlblk_t *, int);
1097c478bd9Sstevel@tonic-gate extern int getrctl(const char *, rctlblk_t *, rctlblk_t *, int);
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate typedef enum {
1127c478bd9Sstevel@tonic-gate 	RCENTITY_PROCESS,
1137c478bd9Sstevel@tonic-gate 	RCENTITY_TASK,
1147c478bd9Sstevel@tonic-gate 	RCENTITY_PROJECT,
1157c478bd9Sstevel@tonic-gate 	RCENTITY_ZONE
1167c478bd9Sstevel@tonic-gate } rctl_entity_t;
1177c478bd9Sstevel@tonic-gate #define	RC_MAX_ENTITY RCENTITY_ZONE
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate #ifndef _KERNEL
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate typedef struct rctl_set rctl_set_t;
1227c478bd9Sstevel@tonic-gate 
1237c478bd9Sstevel@tonic-gate #else /* _KERNEL */
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate #include <sys/mutex.h>
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate /*
1287c478bd9Sstevel@tonic-gate  * rctl_test return bitfield
1297c478bd9Sstevel@tonic-gate  */
1307c478bd9Sstevel@tonic-gate #define	RCT_NONE		0x00000000
1317c478bd9Sstevel@tonic-gate #define	RCT_DENY		0x00000001
1327c478bd9Sstevel@tonic-gate #define	RCT_SIGNAL		0x00000002
1337c478bd9Sstevel@tonic-gate #define	RCT_STRLOG		0x00000004
1347c478bd9Sstevel@tonic-gate 
1357c478bd9Sstevel@tonic-gate #define	RCT_LK_ABANDONED	0x80000000
1367c478bd9Sstevel@tonic-gate 
1377c478bd9Sstevel@tonic-gate /*
1387c478bd9Sstevel@tonic-gate  * rctl_set_dup flags
1397c478bd9Sstevel@tonic-gate  */
1407c478bd9Sstevel@tonic-gate #define	RCD_DUP			0x1
1417c478bd9Sstevel@tonic-gate #define	RCD_CALLBACK		0x2
1427c478bd9Sstevel@tonic-gate 
1437c478bd9Sstevel@tonic-gate /*
1447c478bd9Sstevel@tonic-gate  * rctl_action/rctl_test action safety states
1457c478bd9Sstevel@tonic-gate  */
1467c478bd9Sstevel@tonic-gate #define	RCA_SAFE		0x0 /* safe for signal and siginfo delivery */
1477c478bd9Sstevel@tonic-gate #define	RCA_UNSAFE_SIGINFO	0x1 /* not safe to allocate for siginfo */
1487c478bd9Sstevel@tonic-gate #define	RCA_UNSAFE_ALL		0x2 /* not safe to send signal */
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate typedef struct rctl_val {
1517c478bd9Sstevel@tonic-gate 	struct rctl_val *rcv_prev;		/* previous (lower) value */
1527c478bd9Sstevel@tonic-gate 	struct rctl_val *rcv_next;		/* next (higher) value */
1537c478bd9Sstevel@tonic-gate 	rctl_priv_t	rcv_privilege;		/* appropriate RCPRIV_* cst */
1547c478bd9Sstevel@tonic-gate 	rctl_qty_t	rcv_value;		/* enforced value of control */
1557c478bd9Sstevel@tonic-gate 	uint_t		rcv_flagaction;		/* properties and actions */
1567c478bd9Sstevel@tonic-gate 	int		rcv_action_signal;	/* signal to send as action */
1577c478bd9Sstevel@tonic-gate 	struct proc	*rcv_action_recipient;	/* process to receive signal */
1587c478bd9Sstevel@tonic-gate 	id_t		rcv_action_recip_pid;	/* pid of that process */
1597c478bd9Sstevel@tonic-gate 	hrtime_t	rcv_firing_time;	/* time rctl_val last fired */
1607c478bd9Sstevel@tonic-gate } rctl_val_t;
1617c478bd9Sstevel@tonic-gate 
1627c478bd9Sstevel@tonic-gate typedef int rctl_hndl_t;
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate struct rctl;
1657c478bd9Sstevel@tonic-gate struct proc;
1667c478bd9Sstevel@tonic-gate struct task;
1677c478bd9Sstevel@tonic-gate struct kproject;
1687c478bd9Sstevel@tonic-gate struct zone;
1690209230bSgjelinek struct kstat;
1707c478bd9Sstevel@tonic-gate 
1717c478bd9Sstevel@tonic-gate typedef struct rctl_entity_p_struct {
1727c478bd9Sstevel@tonic-gate 	rctl_entity_t rcep_t;
1737c478bd9Sstevel@tonic-gate 	union {
1747c478bd9Sstevel@tonic-gate 		struct proc *proc;
1757c478bd9Sstevel@tonic-gate 		struct task *task;
1767c478bd9Sstevel@tonic-gate 		struct kproject *proj;
1777c478bd9Sstevel@tonic-gate 		struct zone *zone;
1787c478bd9Sstevel@tonic-gate 	} rcep_p;
1797c478bd9Sstevel@tonic-gate } rctl_entity_p_t;
1807c478bd9Sstevel@tonic-gate 
1817c478bd9Sstevel@tonic-gate typedef struct rctl_ops {
1827c478bd9Sstevel@tonic-gate 	void		(*rco_action)(struct rctl *, struct proc *,
1837c478bd9Sstevel@tonic-gate 	    rctl_entity_p_t *);
1847c478bd9Sstevel@tonic-gate 	rctl_qty_t	(*rco_get_usage)(struct rctl *, struct proc *);
1857c478bd9Sstevel@tonic-gate 	int		(*rco_set)(struct rctl *, struct proc *,
1867c478bd9Sstevel@tonic-gate 	    rctl_entity_p_t *, rctl_qty_t);
1877c478bd9Sstevel@tonic-gate 	int		(*rco_test)(struct rctl *, struct proc *,
1887c478bd9Sstevel@tonic-gate 	    rctl_entity_p_t *, rctl_val_t *, rctl_qty_t, uint_t);
1897c478bd9Sstevel@tonic-gate } rctl_ops_t;
1907c478bd9Sstevel@tonic-gate 
1917c478bd9Sstevel@tonic-gate #define	RCTLOP_ACTION(r, p, e) (r->rc_dict_entry->rcd_ops->rco_action(r, p, e))
1927c478bd9Sstevel@tonic-gate #define	RCTLOP_GET_USAGE(r, p) (r->rc_dict_entry->rcd_ops->rco_get_usage(r, p))
1937c478bd9Sstevel@tonic-gate #define	RCTLOP_SET(r, p, e, v) (r->rc_dict_entry->rcd_ops->rco_set(r, p, e, v))
1947c478bd9Sstevel@tonic-gate #define	RCTLOP_TEST(r, p, e, v, i, f) \
1957c478bd9Sstevel@tonic-gate 	(r->rc_dict_entry->rcd_ops->rco_test(r, p, e, v, i, f))
1967c478bd9Sstevel@tonic-gate 
1977c478bd9Sstevel@tonic-gate /*
1987c478bd9Sstevel@tonic-gate  * Default resource control callback functions.
1997c478bd9Sstevel@tonic-gate  */
2007c478bd9Sstevel@tonic-gate void rcop_no_action(struct rctl *, struct proc *, rctl_entity_p_t *);
2017c478bd9Sstevel@tonic-gate rctl_qty_t rcop_no_usage(struct rctl *, struct proc *);
2027c478bd9Sstevel@tonic-gate int rcop_no_set(struct rctl *, struct proc *, rctl_entity_p_t *, rctl_qty_t);
2037c478bd9Sstevel@tonic-gate int rcop_no_test(struct rctl *, struct proc *, rctl_entity_p_t *,
2047c478bd9Sstevel@tonic-gate     struct rctl_val *, rctl_qty_t, uint_t);
2057c478bd9Sstevel@tonic-gate int rcop_absolute_test(struct rctl *, struct proc *, rctl_entity_p_t *,
2067c478bd9Sstevel@tonic-gate     struct rctl_val *, rctl_qty_t, uint_t);
2077c478bd9Sstevel@tonic-gate 
20855c01d4fSMenno Lageman #define	RCTLOP_NO_USAGE(r) \
20955c01d4fSMenno Lageman 	(r->rc_dict_entry->rcd_ops->rco_get_usage == rcop_no_usage)
21055c01d4fSMenno Lageman 
2117c478bd9Sstevel@tonic-gate extern rctl_ops_t rctl_default_ops;
2127c478bd9Sstevel@tonic-gate extern rctl_ops_t rctl_absolute_ops;
2137c478bd9Sstevel@tonic-gate 
2147c478bd9Sstevel@tonic-gate typedef struct rctl {
2157c478bd9Sstevel@tonic-gate 	struct rctl	*rc_next;		/* next in set hash chain    */
2167c478bd9Sstevel@tonic-gate 	rctl_val_t	*rc_values;		/* list of enforced value    */
2177c478bd9Sstevel@tonic-gate 	rctl_val_t	*rc_cursor;		/* currently enforced value  */
2187c478bd9Sstevel@tonic-gate 	struct rctl_dict_entry *rc_dict_entry;	/* global control properties */
2197c478bd9Sstevel@tonic-gate 	rctl_hndl_t	rc_id;			/* control handle (hash key) */
220532877c4Srd 	rctl_val_t	*rc_projdb;		/* project database rctls    */
2217c478bd9Sstevel@tonic-gate } rctl_t;
2227c478bd9Sstevel@tonic-gate 
2237c478bd9Sstevel@tonic-gate /*
2247c478bd9Sstevel@tonic-gate  * The rctl_set is the collection of resource controls associated with an
2257c478bd9Sstevel@tonic-gate  * individual entity within the system.  All of the controls are applicable to
2267c478bd9Sstevel@tonic-gate  * the same entity, which we call out explicitly in rcs_entity.
2277c478bd9Sstevel@tonic-gate  */
2287c478bd9Sstevel@tonic-gate typedef struct rctl_set {
2297c478bd9Sstevel@tonic-gate 	kmutex_t	rcs_lock;		/* global set lock	  */
2307c478bd9Sstevel@tonic-gate 	rctl_entity_t	rcs_entity;		/* entity type		  */
2317c478bd9Sstevel@tonic-gate 	rctl_t		**rcs_ctls;		/* hash table of controls */
2327c478bd9Sstevel@tonic-gate } rctl_set_t;
2337c478bd9Sstevel@tonic-gate 
2347c478bd9Sstevel@tonic-gate typedef struct rctl_dict_entry {
2357c478bd9Sstevel@tonic-gate 	struct rctl_dict_entry *rcd_next;	/* next in dict hash chain */
2367c478bd9Sstevel@tonic-gate 	char		*rcd_name;		/* resource control name */
2377c478bd9Sstevel@tonic-gate 	rctl_val_t	*rcd_default_value;	/* system control value */
2387c478bd9Sstevel@tonic-gate 	rctl_ops_t	*rcd_ops;		/* callback operations */
2397c478bd9Sstevel@tonic-gate 	rctl_hndl_t	rcd_id;			/* control handle */
2407c478bd9Sstevel@tonic-gate 	rctl_entity_t	rcd_entity;		/* entity type */
2417c478bd9Sstevel@tonic-gate 	int		rcd_flagaction;		/* global properties/actions */
2427c478bd9Sstevel@tonic-gate 	int		rcd_syslog_level;	/* event syslog level */
2437c478bd9Sstevel@tonic-gate 	int		rcd_strlog_flags;	/* derived from syslog level */
2447c478bd9Sstevel@tonic-gate 	rctl_qty_t	rcd_max_native;		/* native model "infinity" */
2457c478bd9Sstevel@tonic-gate 	rctl_qty_t	rcd_max_ilp32;		/* ILP32 model "infinity" */
2467c478bd9Sstevel@tonic-gate } rctl_dict_entry_t;
2477c478bd9Sstevel@tonic-gate 
2487c478bd9Sstevel@tonic-gate typedef struct rctl_alloc_gp {
2497c478bd9Sstevel@tonic-gate 	uint_t	rcag_nctls;	/* number of rctls needed/allocated */
2507c478bd9Sstevel@tonic-gate 	uint_t	rcag_nvals;	/* number of rctl values needed/allocated */
2517c478bd9Sstevel@tonic-gate 	rctl_t	*rcag_ctls;	/* list of allocated rctls */
2527c478bd9Sstevel@tonic-gate 	rctl_val_t *rcag_vals;	/* list of allocated rctl values */
2537c478bd9Sstevel@tonic-gate } rctl_alloc_gp_t;
2547c478bd9Sstevel@tonic-gate 
2557c478bd9Sstevel@tonic-gate extern kmem_cache_t *rctl_cache;	/* kmem cache for rctl structures */
2567c478bd9Sstevel@tonic-gate extern kmem_cache_t *rctl_val_cache;	/* kmem cache for rctl values */
2577c478bd9Sstevel@tonic-gate 
2587c478bd9Sstevel@tonic-gate extern rctl_hndl_t rctlproc_legacy[];
2597c478bd9Sstevel@tonic-gate extern uint_t rctlproc_flags[];
2607c478bd9Sstevel@tonic-gate extern int rctlproc_signals[];
2617c478bd9Sstevel@tonic-gate 
2627c478bd9Sstevel@tonic-gate void rctl_init(void);
2637c478bd9Sstevel@tonic-gate void rctlproc_init(void);
2647c478bd9Sstevel@tonic-gate void rctlproc_default_init(struct proc *, rctl_alloc_gp_t *);
2657c478bd9Sstevel@tonic-gate 
2667c478bd9Sstevel@tonic-gate rctl_hndl_t rctl_register(const char *, rctl_entity_t, int, rctl_qty_t,
2677c478bd9Sstevel@tonic-gate     rctl_qty_t, rctl_ops_t *);
2687c478bd9Sstevel@tonic-gate 
2697c478bd9Sstevel@tonic-gate rctl_hndl_t rctl_hndl_lookup(const char *);
2707c478bd9Sstevel@tonic-gate rctl_dict_entry_t *rctl_dict_lookup(const char *);
2717c478bd9Sstevel@tonic-gate rctl_dict_entry_t *rctl_dict_lookup_hndl(rctl_hndl_t);
2727c478bd9Sstevel@tonic-gate void rctl_add_default_limit(const char *, rctl_qty_t, rctl_priv_t, uint_t);
2737c478bd9Sstevel@tonic-gate void rctl_add_legacy_limit(const char *, const char *, const char *,
2747c478bd9Sstevel@tonic-gate     rctl_qty_t, rctl_qty_t);
2757c478bd9Sstevel@tonic-gate 
2767c478bd9Sstevel@tonic-gate rctl_qty_t rctl_model_maximum(rctl_dict_entry_t *, struct proc *);
2777c478bd9Sstevel@tonic-gate rctl_qty_t rctl_model_value(rctl_dict_entry_t *, struct proc *, rctl_qty_t);
2787c478bd9Sstevel@tonic-gate 
2797c478bd9Sstevel@tonic-gate int rctl_invalid_value(rctl_dict_entry_t *, rctl_val_t *);
2807c478bd9Sstevel@tonic-gate rctl_qty_t rctl_enforced_value(rctl_hndl_t, rctl_set_t *, struct proc *);
2817c478bd9Sstevel@tonic-gate 
2827c478bd9Sstevel@tonic-gate int rctl_test(rctl_hndl_t, rctl_set_t *, struct proc *, rctl_qty_t, uint_t);
2837c478bd9Sstevel@tonic-gate int rctl_action(rctl_hndl_t, rctl_set_t *, struct proc *, uint_t);
2847c478bd9Sstevel@tonic-gate 
2857c478bd9Sstevel@tonic-gate int rctl_test_entity(rctl_hndl_t, rctl_set_t *, struct proc *,
2867c478bd9Sstevel@tonic-gate     rctl_entity_p_t *, rctl_qty_t, uint_t);
2877c478bd9Sstevel@tonic-gate int rctl_action_entity(rctl_hndl_t, rctl_set_t *, struct proc *,
2887c478bd9Sstevel@tonic-gate     rctl_entity_p_t *, uint_t);
2897c478bd9Sstevel@tonic-gate 
2907c478bd9Sstevel@tonic-gate int rctl_val_cmp(rctl_val_t *, rctl_val_t *, int);
2917c478bd9Sstevel@tonic-gate int rctl_val_list_insert(rctl_val_t **, rctl_val_t *);
2927c478bd9Sstevel@tonic-gate 
2937c478bd9Sstevel@tonic-gate rctl_set_t *rctl_set_create(void);
29455c01d4fSMenno Lageman rctl_set_t *rctl_entity_obtain_rset(rctl_dict_entry_t *, struct proc *);
2957c478bd9Sstevel@tonic-gate rctl_alloc_gp_t *rctl_set_init_prealloc(rctl_entity_t);
2967c478bd9Sstevel@tonic-gate rctl_set_t *rctl_set_init(rctl_entity_t, struct proc *, rctl_entity_p_t *,
2977c478bd9Sstevel@tonic-gate     rctl_set_t *, rctl_alloc_gp_t *);
2987c478bd9Sstevel@tonic-gate rctl_alloc_gp_t *rctl_set_dup_prealloc(rctl_set_t *);
2997c478bd9Sstevel@tonic-gate int rctl_set_dup_ready(rctl_set_t *, rctl_alloc_gp_t *);
3007c478bd9Sstevel@tonic-gate rctl_set_t *rctl_set_dup(rctl_set_t *, struct proc *, struct proc *,
3017c478bd9Sstevel@tonic-gate     rctl_entity_p_t *, rctl_set_t *, rctl_alloc_gp_t *, int);
3027c478bd9Sstevel@tonic-gate void rctl_set_reset(rctl_set_t *, struct proc *, rctl_entity_p_t *);
3037c478bd9Sstevel@tonic-gate void rctl_set_tearoff(rctl_set_t *, struct proc *);
30455c01d4fSMenno Lageman int rctl_set_find(rctl_set_t *, rctl_hndl_t, rctl_t **);
3057c478bd9Sstevel@tonic-gate void rctl_set_free(rctl_set_t *);
3067c478bd9Sstevel@tonic-gate 
3077c478bd9Sstevel@tonic-gate void rctl_prealloc_destroy(rctl_alloc_gp_t *);
3087c478bd9Sstevel@tonic-gate 
3097c478bd9Sstevel@tonic-gate size_t rctl_build_name_buf(char **);
3107c478bd9Sstevel@tonic-gate 
3117c478bd9Sstevel@tonic-gate int rctl_global_get(const char *name, rctl_dict_entry_t *);
3127c478bd9Sstevel@tonic-gate int rctl_global_set(const char *name, rctl_dict_entry_t *);
3137c478bd9Sstevel@tonic-gate 
3147c478bd9Sstevel@tonic-gate int rctl_local_delete(rctl_hndl_t, rctl_val_t *, struct proc *p);
3157c478bd9Sstevel@tonic-gate int rctl_local_insert(rctl_hndl_t, rctl_val_t *, struct proc *p);
316532877c4Srd int rctl_local_insert_all(rctl_hndl_t, rctl_val_t *, rctl_val_t *,
317532877c4Srd     struct proc *p);
318532877c4Srd int rctl_local_replace_all(rctl_hndl_t, rctl_val_t *, rctl_val_t *,
319532877c4Srd     struct proc *p);
3207c478bd9Sstevel@tonic-gate int rctl_local_get(rctl_hndl_t, rctl_val_t *, rctl_val_t *, struct proc *p);
3217c478bd9Sstevel@tonic-gate int rctl_local_replace(rctl_hndl_t, rctl_val_t *, rctl_val_t *,
3227c478bd9Sstevel@tonic-gate     struct proc *p);
3237c478bd9Sstevel@tonic-gate 
3247c478bd9Sstevel@tonic-gate /* tag declaration to appease the compiler */
3257c478bd9Sstevel@tonic-gate struct cred;
3267c478bd9Sstevel@tonic-gate rctl_alloc_gp_t *rctl_rlimit_set_prealloc(uint_t);
3277c478bd9Sstevel@tonic-gate int rctl_rlimit_set(rctl_hndl_t, struct proc *, struct rlimit64 *,
3287c478bd9Sstevel@tonic-gate     rctl_alloc_gp_t *, int, int, const struct cred *);
3297c478bd9Sstevel@tonic-gate int rctl_rlimit_get(rctl_hndl_t, struct proc *, struct rlimit64 *);
3307c478bd9Sstevel@tonic-gate 
331c6939658Ssl /* specific rctl utility functions */
332c6939658Ssl int rctl_incr_locked_mem(struct proc *, struct kproject *, rctl_qty_t,
333c6939658Ssl     int);
334c6939658Ssl void rctl_decr_locked_mem(struct proc *, struct kproject *, rctl_qty_t,
335c6939658Ssl     int);
3360209230bSgjelinek int rctl_incr_swap(struct proc *, struct zone *, size_t);
3370209230bSgjelinek void rctl_decr_swap(struct zone *, size_t);
3380209230bSgjelinek 
3390fbb751dSJohn Levon int rctl_incr_lofi(struct proc *, struct zone *, size_t);
3400fbb751dSJohn Levon void rctl_decr_lofi(struct zone *, size_t);
3410fbb751dSJohn Levon 
3420209230bSgjelinek struct kstat *rctl_kstat_create_zone(struct zone *, char *, uchar_t, uint_t,
3430209230bSgjelinek     uchar_t);
3440209230bSgjelinek 
3450209230bSgjelinek struct kstat *rctl_kstat_create_project(struct kproject *, char *, uchar_t,
3460209230bSgjelinek     uint_t, uchar_t);
347c6939658Ssl 
348*ff19e029SMenno Lageman struct kstat *rctl_kstat_create_task(struct task *, char *, uchar_t,
349*ff19e029SMenno Lageman     uint_t, uchar_t);
350*ff19e029SMenno Lageman 
3517c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
3527c478bd9Sstevel@tonic-gate 
3537c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
3547c478bd9Sstevel@tonic-gate }
3557c478bd9Sstevel@tonic-gate #endif
3567c478bd9Sstevel@tonic-gate 
3577c478bd9Sstevel@tonic-gate #endif	/* _SYS_RCTL_H */
358