project.h revision 3792:57ba782523b7
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
33extern "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
44typedef 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
50typedef 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	rctl_qty_t	kpd_crypto_mem;	/* crypto_rctl_lock */
57	rctl_qty_t	kpd_crypto_mem_ctl; /* kpj_rctls->rcs_lock */
58	kstat_t		*kpd_lockedmem_kstat; /* locked memory kstat */
59
60} kproject_data_t;
61
62struct cpucap;
63
64/*
65 * The first two fields of this structure must not be reordered.
66 */
67typedef struct kproject {
68	projid_t 	kpj_id;		/* project ID		*/
69	zoneid_t	kpj_zoneid;	/* zone ID		*/
70	struct zone	*kpj_zone;	/* zone pointer		*/
71	uint_t		kpj_count;	/* reference counter	*/
72	uint32_t	kpj_shares;	/* number of shares	*/
73	rctl_set_t	*kpj_rctls;	/* resource control set */
74	struct kproject	*kpj_prev;	/* previous project	*/
75	struct kproject	*kpj_next;	/* next project		*/
76	kproject_data_t	kpj_data;	/* subsystem-specfic data */
77	kmutex_t	kpj_poolbind;	/* synchronization with pools	*/
78	rctl_qty_t	kpj_nlwps;	/* protected by project's zone's */
79					/* zone_nlwps_lock */
80	rctl_qty_t	kpj_nlwps_ctl;	/* protected by kpj_rctls->rcs_lock */
81	rctl_qty_t	kpj_ntasks;	/* protected by project's zone's */
82					/* zone_nlwps_lock */
83	rctl_qty_t	kpj_ntasks_ctl;	/* protected by kpj_rctls->rcs_lock */
84	struct cpucap	*kpj_cpucap;	/* CPU cap data			*/
85} kproject_t;
86
87#ifdef _KERNEL
88
89/*
90 * Flags for project_hold_by_id()
91 */
92#define	PROJECT_HOLD_FIND	1
93#define	PROJECT_HOLD_INSERT	2
94
95void project_init(void);
96kproject_t *project_hold(kproject_t *);
97kproject_t *project_hold_by_id(projid_t, struct zone *, int);
98void project_rele(kproject_t *);
99int project_walk_all(zoneid_t, int (*)(kproject_t *, void *), void *);
100projid_t curprojid(void);
101
102extern kproject_t *proj0p;
103extern rctl_hndl_t rc_project_nlwps;
104extern rctl_hndl_t rc_project_ntasks;
105extern rctl_hndl_t rc_project_locked_mem;
106#endif /* _KERNEL */
107
108#ifdef	__cplusplus
109}
110#endif
111
112#endif	/* _SYS_PROJECT_H */
113