xref: /illumos-gate/usr/src/uts/common/sys/project.h (revision 9acbbeaf2a1ffe5c14b244867d427714fab43c5c)
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_devlockmem;	/* umem_devlockmem_rctl_lock */
44 	rctl_qty_t	kpd_contract;	/* contract_lock */
45 	rctl_qty_t	kpd_crypto_mem;	/* crypto_rctl_lock */
46 } kproject_data_t;
47 
48 /*
49  * The first two fields of this structure must not be reordered.
50  */
51 typedef struct kproject {
52 	projid_t 	kpj_id;		/* project ID		*/
53 	zoneid_t	kpj_zoneid;	/* zone ID		*/
54 	uint_t		kpj_count;	/* reference counter	*/
55 	uint32_t	kpj_shares;	/* number of shares	*/
56 	rctl_set_t	*kpj_rctls;	/* resource control set */
57 	struct kproject	*kpj_prev;	/* previous project	*/
58 	struct kproject	*kpj_next;	/* next project		*/
59 	kproject_data_t	kpj_data;	/* subsystem-specfic data */
60 	kmutex_t	kpj_poolbind;	/* synch. with pools	*/
61 	rctl_qty_t	kpj_nlwps;	/* protected by project's zone's */
62 					/* zone_nlwps_lock */
63 	rctl_qty_t	kpj_nlwps_ctl;	/* protected by kpj_rctls->rcs_lock */
64 	rctl_qty_t	kpj_ntasks;	/* protected by project's zone's */
65 					/* zone_nlwps_lock */
66 	rctl_qty_t	kpj_ntasks_ctl;	/* protected by kpj_rctls->rcs_lock */
67 } kproject_t;
68 
69 #ifdef _KERNEL
70 
71 /*
72  * Flags for project_hold_by_id()
73  */
74 #define	PROJECT_HOLD_FIND	1
75 #define	PROJECT_HOLD_INSERT	2
76 
77 void project_init(void);
78 kproject_t *project_hold(kproject_t *);
79 kproject_t *project_hold_by_id(projid_t, zoneid_t, int);
80 void project_rele(kproject_t *);
81 int project_walk_all(zoneid_t, int (*)(kproject_t *, void *), void *);
82 projid_t curprojid(void);
83 
84 extern kproject_t *proj0p;
85 extern rctl_hndl_t rc_project_nlwps;
86 extern rctl_hndl_t rc_project_ntasks;
87 
88 #endif /* _KERNEL */
89 
90 #ifdef	__cplusplus
91 }
92 #endif
93 
94 #endif	/* _SYS_PROJECT_H */
95