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 /* 23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _SYS_FSS_H 28 #define _SYS_FSS_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #include <sys/types.h> 33 #include <sys/thread.h> 34 #include <sys/project.h> 35 #include <sys/cpucaps.h> 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 #ifdef _KERNEL 42 43 typedef uint64_t fsspri_t; 44 typedef uint64_t fssusage_t; 45 struct cpupart; 46 struct zone; 47 48 /* 49 * Valid arg1's for fss_allocbuf() 50 */ 51 #define FSS_NPSET_BUF 1 52 #define FSS_NPROJ_BUF 2 53 #define FSS_ONE_BUF 3 54 55 /* 56 * Valid arg2's for fss_allocbuf() 57 */ 58 #define FSS_ALLOC_PROJ 1 59 #define FSS_ALLOC_ZONE 2 60 61 #define FSS_MAXSHARES 65535 62 63 typedef struct fssbuf { 64 int fssb_size; 65 void **fssb_list; 66 } fssbuf_t; 67 68 void *fss_allocbuf(int, int); 69 void fss_freebuf(fssbuf_t *, int); 70 void fss_changeproj(kthread_id_t, void *, void *, fssbuf_t *, fssbuf_t *); 71 void fss_changepset(kthread_id_t, void *, fssbuf_t *, fssbuf_t *); 72 73 /* 74 * Fair share scheduling class specific cpu partition structure 75 */ 76 typedef struct fsspset { 77 kmutex_t fssps_lock; /* lock to protect per-pset */ 78 /* list of fssproj structures */ 79 disp_lock_t fssps_displock; /* lock for fsps_maxfsspri */ 80 struct cpupart *fssps_cpupart; /* ptr to our cpu partition */ 81 /* protected by fsspsets_lock */ 82 fsspri_t fssps_maxfsspri; /* maximum fsspri value among */ 83 /* all projects on this pset */ 84 uint32_t fssps_shares; /* number of active shares */ 85 uint32_t fssps_nproj; /* number of fssproj structures */ 86 /* on the list */ 87 struct fssproj *fssps_list; /* list of project parts */ 88 struct fsszone *fssps_zones; /* list of fsszone_t's in pset */ 89 } fsspset_t; 90 91 /* 92 * One of these structures is allocated to each project running within each 93 * active cpu partition. 94 */ 95 typedef struct fssproj { 96 kproject_t *fssp_proj; /* ptr to our project structure */ 97 fsspset_t *fssp_pset; /* ptr to our fsspset structure */ 98 uint32_t fssp_threads; /* total number of threads here */ 99 /* protected by fssps_lock */ 100 uint32_t fssp_runnable; /* number of runnable threads */ 101 /* protected by fssps_lock */ 102 uint32_t fssp_shares; /* copy of our kpj_shares */ 103 /* protected by fssps_displock */ 104 uint32_t fssp_ticks; /* total of all ticks */ 105 /* protected by fssps_displock */ 106 fssusage_t fssp_usage; /* this project's decayed usage */ 107 fssusage_t fssp_shusage; /* normalized usage */ 108 struct fssproj *fssp_next; /* next project on this pset */ 109 struct fssproj *fssp_prev; /* prev project on this pset */ 110 struct fsszone *fssp_fsszone; /* fsszone_t for this fssproj */ 111 } fssproj_t; 112 113 /* 114 * Fair share scheduling class specific thread structure 115 */ 116 typedef struct fssproc { 117 kthread_t *fss_tp; /* pointer back to our thread */ 118 fssproj_t *fss_proj; /* pointer to our project FSS data */ 119 uchar_t fss_flags; /* flags defined below */ 120 int fss_timeleft; /* time remaining in procs quantum */ 121 uint32_t fss_ticks; /* ticks accumulated by this thread */ 122 pri_t fss_upri; /* user supplied priority (to priocntl) */ 123 pri_t fss_uprilim; /* user priority limit */ 124 pri_t fss_umdpri; /* user mode priority within fs class */ 125 pri_t fss_scpri; /* remembered priority, for schedctl */ 126 int fss_nice; /* nice value for compatibility with ts */ 127 fsspri_t fss_fsspri; /* internal fair share priority */ 128 int fss_runnable; /* to indicate runnable/sleeping thread */ 129 struct fssproc *fss_next; /* pointer to next fssproc_t struct */ 130 struct fssproc *fss_prev; /* pointer to prev fssproc_t sturct */ 131 caps_sc_t fss_caps; /* CPU caps specific data */ 132 } fssproc_t; 133 134 /* 135 * One of these structures is allocated to each zone running within 136 * each active cpu partition. This means that if a zone spans more 137 * than one cpu partition then it will have a few of these structures. 138 */ 139 typedef struct fsszone { 140 struct zone *fssz_zone; /* ptr to our zone structure */ 141 struct fsszone *fssz_next; /* next fsszone_t in fsspset_t */ 142 struct fsszone *fssz_prev; /* prev fsszone_t in fsspset_t */ 143 uint32_t fssz_shares; /* sum of all project shares */ 144 uint32_t fssz_nproj; /* # of projects */ 145 uint32_t fssz_rshares; /* "real" shares given to zone */ 146 uint32_t fssz_runnable; /* # of runnable projects */ 147 } fsszone_t; 148 149 #define FSSPROC(tx) ((fssproc_t *)(tx->t_cldata)) 150 #define FSSPROC2FSSPROJ(fssx) ((fssx)->fss_proj); 151 #define FSSPROC2FSSPSET(fssx) (FSSPROC2FSSPROJ(fssx)->fssp_pset) 152 #define FSSPROJ(tx) (FSSPROC(tx)->fss_proj) 153 #define FSSPROJ2FSSPSET(fssx) ((fssx)->fssp_pset) 154 #define FSSPROJ2KPROJ(fssx) ((fssx)->fssp_proj) 155 #define FSSPROJ2FSSZONE(fssx) ((fssx)->fssp_fsszone) 156 157 /* 158 * fss_flags 159 */ 160 #define FSSKPRI 0x01 /* the thread is in kernel mode */ 161 #define FSSBACKQ 0x02 /* thread should be placed at the back of */ 162 /* the dispatch queue if preempted */ 163 #define FSSRESTORE 0x04 /* thread was not preempted, due to schedctl */ 164 /* restore priority from fss_scpri */ 165 166 #endif /* _KERNEL */ 167 168 #ifdef __cplusplus 169 } 170 #endif 171 172 #endif /* _SYS_FSS_H */ 173