10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 52677Sml93401 * Common Development and Distribution License (the "License"). 62677Sml93401 * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*12725SMenno.Lageman@Sun.COM * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 230Sstevel@tonic-gate */ 240Sstevel@tonic-gate 250Sstevel@tonic-gate #ifndef _SYS_PROJECT_H 260Sstevel@tonic-gate #define _SYS_PROJECT_H 270Sstevel@tonic-gate 280Sstevel@tonic-gate #ifdef __cplusplus 290Sstevel@tonic-gate extern "C" { 300Sstevel@tonic-gate #endif 310Sstevel@tonic-gate 323247Sgjelinek 333247Sgjelinek #include <sys/kstat.h> 340Sstevel@tonic-gate #include <sys/types.h> 350Sstevel@tonic-gate #include <sys/mutex.h> 360Sstevel@tonic-gate #include <sys/rctl.h> 372677Sml93401 #include <sys/ipc_rctl.h> 383792Sakolb #include <sys/zone.h> 390Sstevel@tonic-gate 403247Sgjelinek typedef struct kproject_kstat { 413247Sgjelinek kstat_named_t kpk_zonename; 423247Sgjelinek kstat_named_t kpk_usage; 433247Sgjelinek kstat_named_t kpk_value; 443247Sgjelinek } kproject_kstat_t; 453247Sgjelinek 460Sstevel@tonic-gate typedef struct kproject_data { /* Datum protected by: */ 470Sstevel@tonic-gate rctl_qty_t kpd_shmmax; /* shm's ipcs_lock */ 482677Sml93401 ipc_rqty_t kpd_ipc; /* shm|sem|msg's ipcs lock */ 492768Ssl108498 rctl_qty_t kpd_locked_mem; /* zone_rctl_lock */ 502768Ssl108498 rctl_qty_t kpd_locked_mem_ctl; /* kpj_rctls->rcs_lock */ 510Sstevel@tonic-gate rctl_qty_t kpd_contract; /* contract_lock */ 523916Skrishna kmutex_t kpd_crypto_lock; 533916Skrishna rctl_qty_t kpd_crypto_mem; /* kpd_crypto_lock above */ 543620Skrishna rctl_qty_t kpd_crypto_mem_ctl; /* kpj_rctls->rcs_lock */ 553247Sgjelinek kstat_t *kpd_lockedmem_kstat; /* locked memory kstat */ 56*12725SMenno.Lageman@Sun.COM kstat_t *kpd_nprocs_kstat; 570Sstevel@tonic-gate } kproject_data_t; 580Sstevel@tonic-gate 593792Sakolb struct cpucap; 603792Sakolb 610Sstevel@tonic-gate /* 620Sstevel@tonic-gate * The first two fields of this structure must not be reordered. 630Sstevel@tonic-gate */ 640Sstevel@tonic-gate typedef struct kproject { 650Sstevel@tonic-gate projid_t kpj_id; /* project ID */ 660Sstevel@tonic-gate zoneid_t kpj_zoneid; /* zone ID */ 673792Sakolb struct zone *kpj_zone; /* zone pointer */ 680Sstevel@tonic-gate uint_t kpj_count; /* reference counter */ 690Sstevel@tonic-gate uint32_t kpj_shares; /* number of shares */ 700Sstevel@tonic-gate rctl_set_t *kpj_rctls; /* resource control set */ 710Sstevel@tonic-gate struct kproject *kpj_prev; /* previous project */ 720Sstevel@tonic-gate struct kproject *kpj_next; /* next project */ 730Sstevel@tonic-gate kproject_data_t kpj_data; /* subsystem-specfic data */ 743792Sakolb kmutex_t kpj_poolbind; /* synchronization with pools */ 750Sstevel@tonic-gate rctl_qty_t kpj_nlwps; /* protected by project's zone's */ 760Sstevel@tonic-gate /* zone_nlwps_lock */ 770Sstevel@tonic-gate rctl_qty_t kpj_nlwps_ctl; /* protected by kpj_rctls->rcs_lock */ 780Sstevel@tonic-gate rctl_qty_t kpj_ntasks; /* protected by project's zone's */ 790Sstevel@tonic-gate /* zone_nlwps_lock */ 800Sstevel@tonic-gate rctl_qty_t kpj_ntasks_ctl; /* protected by kpj_rctls->rcs_lock */ 813792Sakolb struct cpucap *kpj_cpucap; /* CPU cap data */ 826134Scasper struct klpd_reg *kpj_klpd; /* our extended policy */ 836134Scasper /* protected by klpd_mutex */ 84*12725SMenno.Lageman@Sun.COM rctl_qty_t kpj_nprocs; /* protected by project's zone's */ 85*12725SMenno.Lageman@Sun.COM /* zone_nlwps_lock */ 86*12725SMenno.Lageman@Sun.COM rctl_qty_t kpj_nprocs_ctl; /* protected by kpj_rctls->rcs_lock */ 870Sstevel@tonic-gate } kproject_t; 880Sstevel@tonic-gate 890Sstevel@tonic-gate #ifdef _KERNEL 900Sstevel@tonic-gate 910Sstevel@tonic-gate /* 920Sstevel@tonic-gate * Flags for project_hold_by_id() 930Sstevel@tonic-gate */ 940Sstevel@tonic-gate #define PROJECT_HOLD_FIND 1 950Sstevel@tonic-gate #define PROJECT_HOLD_INSERT 2 960Sstevel@tonic-gate 970Sstevel@tonic-gate void project_init(void); 980Sstevel@tonic-gate kproject_t *project_hold(kproject_t *); 993247Sgjelinek kproject_t *project_hold_by_id(projid_t, struct zone *, int); 1000Sstevel@tonic-gate void project_rele(kproject_t *); 1010Sstevel@tonic-gate int project_walk_all(zoneid_t, int (*)(kproject_t *, void *), void *); 1020Sstevel@tonic-gate projid_t curprojid(void); 1030Sstevel@tonic-gate 1040Sstevel@tonic-gate extern kproject_t *proj0p; 1050Sstevel@tonic-gate extern rctl_hndl_t rc_project_nlwps; 106*12725SMenno.Lageman@Sun.COM extern rctl_hndl_t rc_project_nprocs; 1070Sstevel@tonic-gate extern rctl_hndl_t rc_project_ntasks; 1082768Ssl108498 extern rctl_hndl_t rc_project_locked_mem; 1093916Skrishna extern rctl_hndl_t rc_project_crypto_mem; 1100Sstevel@tonic-gate #endif /* _KERNEL */ 1110Sstevel@tonic-gate 1120Sstevel@tonic-gate #ifdef __cplusplus 1130Sstevel@tonic-gate } 1140Sstevel@tonic-gate #endif 1150Sstevel@tonic-gate 1160Sstevel@tonic-gate #endif /* _SYS_PROJECT_H */ 117