1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_FSS_H 28*7c478bd9Sstevel@tonic-gate #define _SYS_FSS_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 33*7c478bd9Sstevel@tonic-gate #include <sys/thread.h> 34*7c478bd9Sstevel@tonic-gate #include <sys/project.h> 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 37*7c478bd9Sstevel@tonic-gate extern "C" { 38*7c478bd9Sstevel@tonic-gate #endif 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate typedef uint64_t fsspri_t; 41*7c478bd9Sstevel@tonic-gate typedef uint64_t fssusage_t; 42*7c478bd9Sstevel@tonic-gate struct cpupart; 43*7c478bd9Sstevel@tonic-gate struct zone; 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate /* 46*7c478bd9Sstevel@tonic-gate * Valid arg1's for fss_allocbuf() 47*7c478bd9Sstevel@tonic-gate */ 48*7c478bd9Sstevel@tonic-gate #define FSS_NPSET_BUF 1 49*7c478bd9Sstevel@tonic-gate #define FSS_NPROJ_BUF 2 50*7c478bd9Sstevel@tonic-gate #define FSS_ONE_BUF 3 51*7c478bd9Sstevel@tonic-gate 52*7c478bd9Sstevel@tonic-gate /* 53*7c478bd9Sstevel@tonic-gate * Valid arg2's for fss_allocbuf() 54*7c478bd9Sstevel@tonic-gate */ 55*7c478bd9Sstevel@tonic-gate #define FSS_ALLOC_PROJ 1 56*7c478bd9Sstevel@tonic-gate #define FSS_ALLOC_ZONE 2 57*7c478bd9Sstevel@tonic-gate 58*7c478bd9Sstevel@tonic-gate #define FSS_MAXSHARES 65535 59*7c478bd9Sstevel@tonic-gate 60*7c478bd9Sstevel@tonic-gate typedef struct fssbuf { 61*7c478bd9Sstevel@tonic-gate int fssb_size; 62*7c478bd9Sstevel@tonic-gate void **fssb_list; 63*7c478bd9Sstevel@tonic-gate } fssbuf_t; 64*7c478bd9Sstevel@tonic-gate 65*7c478bd9Sstevel@tonic-gate void *fss_allocbuf(int, int); 66*7c478bd9Sstevel@tonic-gate void fss_freebuf(fssbuf_t *, int); 67*7c478bd9Sstevel@tonic-gate void fss_changeproj(kthread_id_t, void *, void *, fssbuf_t *, fssbuf_t *); 68*7c478bd9Sstevel@tonic-gate void fss_changepset(kthread_id_t, void *, fssbuf_t *, fssbuf_t *); 69*7c478bd9Sstevel@tonic-gate 70*7c478bd9Sstevel@tonic-gate /* 71*7c478bd9Sstevel@tonic-gate * Fair share scheduling class specific cpu partition structure 72*7c478bd9Sstevel@tonic-gate */ 73*7c478bd9Sstevel@tonic-gate typedef struct fsspset { 74*7c478bd9Sstevel@tonic-gate kmutex_t fssps_lock; /* lock to protect per-pset */ 75*7c478bd9Sstevel@tonic-gate /* list of fssproj structures */ 76*7c478bd9Sstevel@tonic-gate disp_lock_t fssps_displock; /* lock for fsps_maxfspri */ 77*7c478bd9Sstevel@tonic-gate struct cpupart *fssps_cpupart; /* ptr to our cpu partition */ 78*7c478bd9Sstevel@tonic-gate /* protected by fsspsets_lock */ 79*7c478bd9Sstevel@tonic-gate fsspri_t fssps_maxfsspri; /* maximum fsspri value among */ 80*7c478bd9Sstevel@tonic-gate /* all projects on this pset */ 81*7c478bd9Sstevel@tonic-gate uint32_t fssps_shares; /* number of active shares */ 82*7c478bd9Sstevel@tonic-gate uint32_t fssps_nproj; /* number of fssproj structures */ 83*7c478bd9Sstevel@tonic-gate /* on the list */ 84*7c478bd9Sstevel@tonic-gate struct fssproj *fssps_list; /* list of project parts */ 85*7c478bd9Sstevel@tonic-gate struct fsszone *fssps_zones; /* list of fsszone_t's in pset */ 86*7c478bd9Sstevel@tonic-gate } fsspset_t; 87*7c478bd9Sstevel@tonic-gate 88*7c478bd9Sstevel@tonic-gate /* 89*7c478bd9Sstevel@tonic-gate * One of these structures is allocated to each project running within each 90*7c478bd9Sstevel@tonic-gate * active cpu partition. 91*7c478bd9Sstevel@tonic-gate */ 92*7c478bd9Sstevel@tonic-gate typedef struct fssproj { 93*7c478bd9Sstevel@tonic-gate kproject_t *fssp_proj; /* ptr to our project structure */ 94*7c478bd9Sstevel@tonic-gate fsspset_t *fssp_pset; /* ptr to our fsspset structure */ 95*7c478bd9Sstevel@tonic-gate uint32_t fssp_threads; /* total number of threads here */ 96*7c478bd9Sstevel@tonic-gate /* protected by fssps_lock */ 97*7c478bd9Sstevel@tonic-gate uint32_t fssp_runnable; /* number of runnable threads */ 98*7c478bd9Sstevel@tonic-gate /* protected by fssps_lock */ 99*7c478bd9Sstevel@tonic-gate uint32_t fssp_shares; /* copy of our kpj_shares */ 100*7c478bd9Sstevel@tonic-gate /* protected by fssps_displock */ 101*7c478bd9Sstevel@tonic-gate uint32_t fssp_ticks; /* total of all ticks */ 102*7c478bd9Sstevel@tonic-gate /* protected by fssps_displock */ 103*7c478bd9Sstevel@tonic-gate fssusage_t fssp_usage; /* this project's decayed usage */ 104*7c478bd9Sstevel@tonic-gate fssusage_t fssp_shusage; /* normalized usage */ 105*7c478bd9Sstevel@tonic-gate struct fssproj *fssp_next; /* next project on this pset */ 106*7c478bd9Sstevel@tonic-gate struct fssproj *fssp_prev; /* prev project on this pset */ 107*7c478bd9Sstevel@tonic-gate struct fsszone *fssp_fsszone; /* fsszone_t for this fssproj */ 108*7c478bd9Sstevel@tonic-gate } fssproj_t; 109*7c478bd9Sstevel@tonic-gate 110*7c478bd9Sstevel@tonic-gate /* 111*7c478bd9Sstevel@tonic-gate * Fair share scheduling class specific thread structure 112*7c478bd9Sstevel@tonic-gate */ 113*7c478bd9Sstevel@tonic-gate typedef struct fssproc { 114*7c478bd9Sstevel@tonic-gate kthread_t *fss_tp; /* pointer back to our thread */ 115*7c478bd9Sstevel@tonic-gate fssproj_t *fss_proj; /* pointer to our project FS data */ 116*7c478bd9Sstevel@tonic-gate uchar_t fss_flags; /* flags defined below */ 117*7c478bd9Sstevel@tonic-gate int fss_timeleft; /* time remaining in procs quantum */ 118*7c478bd9Sstevel@tonic-gate uint32_t fss_ticks; /* ticks accumulated by this thread */ 119*7c478bd9Sstevel@tonic-gate pri_t fss_upri; /* user supplied priority (to priocntl) */ 120*7c478bd9Sstevel@tonic-gate pri_t fss_uprilim; /* user priority limit */ 121*7c478bd9Sstevel@tonic-gate pri_t fss_umdpri; /* user mode priority within fs class */ 122*7c478bd9Sstevel@tonic-gate int fss_nice; /* nice value for compatibility with ts */ 123*7c478bd9Sstevel@tonic-gate fsspri_t fss_fsspri; /* internal fair share priority */ 124*7c478bd9Sstevel@tonic-gate int fss_runnable; /* to indicate runnable/sleeping thread */ 125*7c478bd9Sstevel@tonic-gate struct fssproc *fss_next; /* pointer to next fssproc_t struct */ 126*7c478bd9Sstevel@tonic-gate struct fssproc *fss_prev; /* pointer to prev fssproc_t sturct */ 127*7c478bd9Sstevel@tonic-gate } fssproc_t; 128*7c478bd9Sstevel@tonic-gate 129*7c478bd9Sstevel@tonic-gate /* 130*7c478bd9Sstevel@tonic-gate * One of these structures is allocated to each zone running within each active 131*7c478bd9Sstevel@tonic-gate * cpu partition. 132*7c478bd9Sstevel@tonic-gate */ 133*7c478bd9Sstevel@tonic-gate typedef struct fsszone { 134*7c478bd9Sstevel@tonic-gate struct zone *fssz_zone; /* ptr to our zone structure */ 135*7c478bd9Sstevel@tonic-gate struct fsszone *fssz_next; /* ptr to next fsszone in fsspset */ 136*7c478bd9Sstevel@tonic-gate struct fsszone *fssz_prev; /* ptr to prev fsszone in fsspset */ 137*7c478bd9Sstevel@tonic-gate uint32_t fssz_shares; /* total #shares for projs in zone */ 138*7c478bd9Sstevel@tonic-gate uint32_t fssz_nproj; /* # fssproj_t's in this fsszone */ 139*7c478bd9Sstevel@tonic-gate uint32_t fssz_rshares; /* "real" shares given to zone */ 140*7c478bd9Sstevel@tonic-gate uint32_t fssz_runnable; /* # projects with runnable threads */ 141*7c478bd9Sstevel@tonic-gate } fsszone_t; 142*7c478bd9Sstevel@tonic-gate 143*7c478bd9Sstevel@tonic-gate #define FSSPROC(tx) ((fssproc_t *)(tx->t_cldata)) 144*7c478bd9Sstevel@tonic-gate #define FSSPROC2FSSPROJ(fssx) ((fssx)->fss_proj); 145*7c478bd9Sstevel@tonic-gate #define FSSPROC2FSSPSET(fssx) (FSSPROC2FSSPROJ(fssx)->fssp_pset) 146*7c478bd9Sstevel@tonic-gate #define FSSPROJ(tx) (FSSPROC(tx)->fss_proj) 147*7c478bd9Sstevel@tonic-gate #define FSSPROJ2FSSPSET(fssx) ((fssx)->fssp_pset) 148*7c478bd9Sstevel@tonic-gate #define FSSPROJ2KPROJ(fssx) ((fssx)->fssp_proj) 149*7c478bd9Sstevel@tonic-gate #define FSSPROJ2FSSZONE(fssx) ((fssx)->fssp_fsszone) 150*7c478bd9Sstevel@tonic-gate 151*7c478bd9Sstevel@tonic-gate /* 152*7c478bd9Sstevel@tonic-gate * fss_flags 153*7c478bd9Sstevel@tonic-gate */ 154*7c478bd9Sstevel@tonic-gate #define FSSKPRI 0x01 /* the thread is in kernel mode */ 155*7c478bd9Sstevel@tonic-gate #define FSSBACKQ 0x02 /* thread should be placed at the back of */ 156*7c478bd9Sstevel@tonic-gate /* the dispatch queue if preempted */ 157*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 158*7c478bd9Sstevel@tonic-gate } 159*7c478bd9Sstevel@tonic-gate #endif 160*7c478bd9Sstevel@tonic-gate 161*7c478bd9Sstevel@tonic-gate #endif /* _SYS_FSS_H */ 162