xref: /titanic_52/usr/src/uts/common/sys/project.h (revision 28406508b3a9fa1994317b410fa4afd93b3f8cc4)
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 2007 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 
43 typedef struct kproject_kstat {
44 	kstat_named_t kpk_zonename;
45 	kstat_named_t kpk_usage;
46 	kstat_named_t kpk_value;
47 } kproject_kstat_t;
48 
49 typedef struct kproject_data {		/* Datum protected by: */
50 	rctl_qty_t	kpd_shmmax;	/* shm's ipcs_lock */
51 	ipc_rqty_t	kpd_ipc;	/* shm|sem|msg's ipcs lock */
52 	rctl_qty_t	kpd_locked_mem;	 /* zone_rctl_lock */
53 	rctl_qty_t	kpd_locked_mem_ctl; /* kpj_rctls->rcs_lock */
54 	rctl_qty_t	kpd_contract;	/* contract_lock */
55 	rctl_qty_t	kpd_crypto_mem;	/* crypto_rctl_lock */
56 	rctl_qty_t	kpd_crypto_mem_ctl; /* kpj_rctls->rcs_lock */
57 	kstat_t		*kpd_lockedmem_kstat; /* locked memory kstat */
58 
59 } kproject_data_t;
60 
61 /*
62  * The first two fields of this structure must not be reordered.
63  */
64 typedef struct kproject {
65 	projid_t 	kpj_id;		/* project ID		*/
66 	zoneid_t	kpj_zoneid;	/* zone ID		*/
67 	uint_t		kpj_count;	/* reference counter	*/
68 	uint32_t	kpj_shares;	/* number of shares	*/
69 	rctl_set_t	*kpj_rctls;	/* resource control set */
70 	struct kproject	*kpj_prev;	/* previous project	*/
71 	struct kproject	*kpj_next;	/* next project		*/
72 	kproject_data_t	kpj_data;	/* subsystem-specfic data */
73 	kmutex_t	kpj_poolbind;	/* synch. with pools	*/
74 	rctl_qty_t	kpj_nlwps;	/* protected by project's zone's */
75 					/* zone_nlwps_lock */
76 	rctl_qty_t	kpj_nlwps_ctl;	/* protected by kpj_rctls->rcs_lock */
77 	rctl_qty_t	kpj_ntasks;	/* protected by project's zone's */
78 					/* zone_nlwps_lock */
79 	rctl_qty_t	kpj_ntasks_ctl;	/* protected by kpj_rctls->rcs_lock */
80 } kproject_t;
81 
82 #ifdef _KERNEL
83 
84 /*
85  * Flags for project_hold_by_id()
86  */
87 #define	PROJECT_HOLD_FIND	1
88 #define	PROJECT_HOLD_INSERT	2
89 
90 struct zone;
91 
92 void project_init(void);
93 kproject_t *project_hold(kproject_t *);
94 kproject_t *project_hold_by_id(projid_t, struct zone *, int);
95 void project_rele(kproject_t *);
96 int project_walk_all(zoneid_t, int (*)(kproject_t *, void *), void *);
97 projid_t curprojid(void);
98 
99 extern kproject_t *proj0p;
100 extern rctl_hndl_t rc_project_nlwps;
101 extern rctl_hndl_t rc_project_ntasks;
102 extern rctl_hndl_t rc_project_locked_mem;
103 #endif /* _KERNEL */
104 
105 #ifdef	__cplusplus
106 }
107 #endif
108 
109 #endif	/* _SYS_PROJECT_H */
110