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