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