xref: /titanic_50/usr/src/uts/common/sys/project.h (revision 9cd5efbcf26e476412d4fc76a77babc607089c55)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_PROJECT_H
27 #define	_SYS_PROJECT_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 
37 #include <sys/kstat.h>
38 #include <sys/types.h>
39 #include <sys/mutex.h>
40 #include <sys/rctl.h>
41 #include <sys/ipc_rctl.h>
42 #include <sys/zone.h>
43 
44 typedef struct kproject_kstat {
45 	kstat_named_t kpk_zonename;
46 	kstat_named_t kpk_usage;
47 	kstat_named_t kpk_value;
48 } kproject_kstat_t;
49 
50 typedef struct kproject_data {		/* Datum protected by: */
51 	rctl_qty_t	kpd_shmmax;	/* shm's ipcs_lock */
52 	ipc_rqty_t	kpd_ipc;	/* shm|sem|msg's ipcs lock */
53 	rctl_qty_t	kpd_locked_mem;	 /* zone_rctl_lock */
54 	rctl_qty_t	kpd_locked_mem_ctl; /* kpj_rctls->rcs_lock */
55 	rctl_qty_t	kpd_contract;	/* contract_lock */
56 	kmutex_t	kpd_crypto_lock;
57 	rctl_qty_t	kpd_crypto_mem;	/* kpd_crypto_lock above */
58 	rctl_qty_t	kpd_crypto_mem_ctl; /* kpj_rctls->rcs_lock */
59 	kstat_t		*kpd_lockedmem_kstat; /* locked memory kstat */
60 
61 } kproject_data_t;
62 
63 struct cpucap;
64 
65 /*
66  * The first two fields of this structure must not be reordered.
67  */
68 typedef struct kproject {
69 	projid_t 	kpj_id;		/* project ID		*/
70 	zoneid_t	kpj_zoneid;	/* zone ID		*/
71 	struct zone	*kpj_zone;	/* zone pointer		*/
72 	uint_t		kpj_count;	/* reference counter	*/
73 	uint32_t	kpj_shares;	/* number of shares	*/
74 	rctl_set_t	*kpj_rctls;	/* resource control set */
75 	struct kproject	*kpj_prev;	/* previous project	*/
76 	struct kproject	*kpj_next;	/* next project		*/
77 	kproject_data_t	kpj_data;	/* subsystem-specfic data */
78 	kmutex_t	kpj_poolbind;	/* synchronization with pools	*/
79 	rctl_qty_t	kpj_nlwps;	/* protected by project's zone's */
80 					/* zone_nlwps_lock */
81 	rctl_qty_t	kpj_nlwps_ctl;	/* protected by kpj_rctls->rcs_lock */
82 	rctl_qty_t	kpj_ntasks;	/* protected by project's zone's */
83 					/* zone_nlwps_lock */
84 	rctl_qty_t	kpj_ntasks_ctl;	/* protected by kpj_rctls->rcs_lock */
85 	struct cpucap	*kpj_cpucap;	/* CPU cap data			*/
86 	struct klpd_reg	*kpj_klpd;	/* our extended policy */
87 					/* protected by klpd_mutex */
88 } kproject_t;
89 
90 #ifdef _KERNEL
91 
92 /*
93  * Flags for project_hold_by_id()
94  */
95 #define	PROJECT_HOLD_FIND	1
96 #define	PROJECT_HOLD_INSERT	2
97 
98 void project_init(void);
99 kproject_t *project_hold(kproject_t *);
100 kproject_t *project_hold_by_id(projid_t, struct zone *, int);
101 void project_rele(kproject_t *);
102 int project_walk_all(zoneid_t, int (*)(kproject_t *, void *), void *);
103 projid_t curprojid(void);
104 
105 extern kproject_t *proj0p;
106 extern rctl_hndl_t rc_project_nlwps;
107 extern rctl_hndl_t rc_project_ntasks;
108 extern rctl_hndl_t rc_project_locked_mem;
109 extern rctl_hndl_t rc_project_crypto_mem;
110 #endif /* _KERNEL */
111 
112 #ifdef	__cplusplus
113 }
114 #endif
115 
116 #endif	/* _SYS_PROJECT_H */
117