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