xref: /titanic_44/usr/src/uts/common/sys/project.h (revision 3e11238add61003086e5ff3ac68d9f8ba6233355)
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 2006 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 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #include <sys/types.h>
36 #include <sys/mutex.h>
37 #include <sys/rctl.h>
38 #include <sys/ipc_rctl.h>
39 
40 typedef struct kproject_data {		/* Datum protected by: */
41 	rctl_qty_t	kpd_shmmax;	/* shm's ipcs_lock */
42 	ipc_rqty_t	kpd_ipc;	/* shm|sem|msg's ipcs lock */
43 	rctl_qty_t	kpd_locked_mem;	 /* zone_rctl_lock */
44 	rctl_qty_t	kpd_locked_mem_ctl; /* kpj_rctls->rcs_lock */
45 	rctl_qty_t	kpd_contract;	/* contract_lock */
46 	rctl_qty_t	kpd_crypto_mem;	/* crypto_rctl_lock */
47 
48 } kproject_data_t;
49 
50 /*
51  * The first two fields of this structure must not be reordered.
52  */
53 typedef struct kproject {
54 	projid_t 	kpj_id;		/* project ID		*/
55 	zoneid_t	kpj_zoneid;	/* zone ID		*/
56 	uint_t		kpj_count;	/* reference counter	*/
57 	uint32_t	kpj_shares;	/* number of shares	*/
58 	rctl_set_t	*kpj_rctls;	/* resource control set */
59 	struct kproject	*kpj_prev;	/* previous project	*/
60 	struct kproject	*kpj_next;	/* next project		*/
61 	kproject_data_t	kpj_data;	/* subsystem-specfic data */
62 	kmutex_t	kpj_poolbind;	/* synch. with pools	*/
63 	rctl_qty_t	kpj_nlwps;	/* protected by project's zone's */
64 					/* zone_nlwps_lock */
65 	rctl_qty_t	kpj_nlwps_ctl;	/* protected by kpj_rctls->rcs_lock */
66 	rctl_qty_t	kpj_ntasks;	/* protected by project's zone's */
67 					/* zone_nlwps_lock */
68 	rctl_qty_t	kpj_ntasks_ctl;	/* protected by kpj_rctls->rcs_lock */
69 } kproject_t;
70 
71 #ifdef _KERNEL
72 
73 /*
74  * Flags for project_hold_by_id()
75  */
76 #define	PROJECT_HOLD_FIND	1
77 #define	PROJECT_HOLD_INSERT	2
78 
79 void project_init(void);
80 kproject_t *project_hold(kproject_t *);
81 kproject_t *project_hold_by_id(projid_t, zoneid_t, int);
82 void project_rele(kproject_t *);
83 int project_walk_all(zoneid_t, int (*)(kproject_t *, void *), void *);
84 projid_t curprojid(void);
85 
86 extern kproject_t *proj0p;
87 extern rctl_hndl_t rc_project_nlwps;
88 extern rctl_hndl_t rc_project_ntasks;
89 extern rctl_hndl_t rc_project_locked_mem;
90 #endif /* _KERNEL */
91 
92 #ifdef	__cplusplus
93 }
94 #endif
95 
96 #endif	/* _SYS_PROJECT_H */
97