xref: /onnv-gate/usr/src/uts/common/sys/fss.h (revision 3792:57ba782523b7)
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
5*3792Sakolb  * Common Development and Distribution License (the "License").
6*3792Sakolb  * 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  */
21951Sraf 
220Sstevel@tonic-gate /*
23*3792Sakolb  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #ifndef	_SYS_FSS_H
280Sstevel@tonic-gate #define	_SYS_FSS_H
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #include <sys/types.h>
330Sstevel@tonic-gate #include <sys/thread.h>
340Sstevel@tonic-gate #include <sys/project.h>
35*3792Sakolb #include <sys/cpucaps.h>
360Sstevel@tonic-gate 
370Sstevel@tonic-gate #ifdef	__cplusplus
380Sstevel@tonic-gate extern "C" {
390Sstevel@tonic-gate #endif
400Sstevel@tonic-gate 
41*3792Sakolb #ifdef	_KERNEL
42*3792Sakolb 
430Sstevel@tonic-gate typedef uint64_t fsspri_t;
440Sstevel@tonic-gate typedef	uint64_t fssusage_t;
450Sstevel@tonic-gate struct cpupart;
460Sstevel@tonic-gate struct zone;
470Sstevel@tonic-gate 
480Sstevel@tonic-gate /*
490Sstevel@tonic-gate  * Valid arg1's for fss_allocbuf()
500Sstevel@tonic-gate  */
510Sstevel@tonic-gate #define	FSS_NPSET_BUF	1
520Sstevel@tonic-gate #define	FSS_NPROJ_BUF	2
530Sstevel@tonic-gate #define	FSS_ONE_BUF	3
540Sstevel@tonic-gate 
550Sstevel@tonic-gate /*
560Sstevel@tonic-gate  * Valid arg2's for fss_allocbuf()
570Sstevel@tonic-gate  */
580Sstevel@tonic-gate #define	FSS_ALLOC_PROJ	1
590Sstevel@tonic-gate #define	FSS_ALLOC_ZONE	2
600Sstevel@tonic-gate 
610Sstevel@tonic-gate #define	FSS_MAXSHARES	65535
620Sstevel@tonic-gate 
630Sstevel@tonic-gate typedef struct fssbuf {
640Sstevel@tonic-gate 	int	fssb_size;
650Sstevel@tonic-gate 	void	**fssb_list;
660Sstevel@tonic-gate } fssbuf_t;
670Sstevel@tonic-gate 
680Sstevel@tonic-gate void *fss_allocbuf(int, int);
690Sstevel@tonic-gate void fss_freebuf(fssbuf_t *, int);
700Sstevel@tonic-gate void fss_changeproj(kthread_id_t, void *, void *, fssbuf_t *, fssbuf_t *);
710Sstevel@tonic-gate void fss_changepset(kthread_id_t, void *, fssbuf_t *, fssbuf_t *);
720Sstevel@tonic-gate 
730Sstevel@tonic-gate /*
740Sstevel@tonic-gate  * Fair share scheduling class specific cpu partition structure
750Sstevel@tonic-gate  */
760Sstevel@tonic-gate typedef struct fsspset {
770Sstevel@tonic-gate 	kmutex_t	fssps_lock;	/* lock to protect per-pset	*/
780Sstevel@tonic-gate 					/* list of fssproj structures	*/
79*3792Sakolb 	disp_lock_t	fssps_displock;	/* lock for fsps_maxfsspri	*/
800Sstevel@tonic-gate 	struct cpupart	*fssps_cpupart;	/* ptr to our cpu partition	*/
810Sstevel@tonic-gate 					/* protected by fsspsets_lock	*/
820Sstevel@tonic-gate 	fsspri_t	fssps_maxfsspri; /* maximum fsspri value among	*/
830Sstevel@tonic-gate 					/* all projects on this pset	*/
840Sstevel@tonic-gate 	uint32_t	fssps_shares;	/* number of active shares	*/
850Sstevel@tonic-gate 	uint32_t	fssps_nproj;	/* number of fssproj structures */
860Sstevel@tonic-gate 					/* on the list			*/
870Sstevel@tonic-gate 	struct fssproj	*fssps_list;	/* list of project parts	*/
880Sstevel@tonic-gate 	struct fsszone	*fssps_zones;	/* list of fsszone_t's in pset	*/
890Sstevel@tonic-gate } fsspset_t;
900Sstevel@tonic-gate 
910Sstevel@tonic-gate /*
920Sstevel@tonic-gate  * One of these structures is allocated to each project running within each
930Sstevel@tonic-gate  * active cpu partition.
940Sstevel@tonic-gate  */
950Sstevel@tonic-gate typedef struct fssproj {
960Sstevel@tonic-gate 	kproject_t	*fssp_proj;	/* ptr to our project structure	*/
970Sstevel@tonic-gate 	fsspset_t	*fssp_pset;	/* ptr to our fsspset structure	*/
980Sstevel@tonic-gate 	uint32_t	fssp_threads;	/* total number of threads here */
990Sstevel@tonic-gate 					/* protected by fssps_lock	*/
1000Sstevel@tonic-gate 	uint32_t	fssp_runnable;	/* number of runnable threads	*/
1010Sstevel@tonic-gate 					/* protected by fssps_lock	*/
1020Sstevel@tonic-gate 	uint32_t	fssp_shares;	/* copy of our kpj_shares	*/
1030Sstevel@tonic-gate 					/* protected by fssps_displock	*/
1040Sstevel@tonic-gate 	uint32_t	fssp_ticks;	/* total of all ticks		*/
1050Sstevel@tonic-gate 					/* protected by fssps_displock	*/
1060Sstevel@tonic-gate 	fssusage_t	fssp_usage;	/* this project's decayed usage */
1070Sstevel@tonic-gate 	fssusage_t	fssp_shusage;	/* normalized usage		*/
1080Sstevel@tonic-gate 	struct fssproj	*fssp_next;	/* next project on this pset	*/
1090Sstevel@tonic-gate 	struct fssproj	*fssp_prev;	/* prev project on this pset	*/
1100Sstevel@tonic-gate 	struct fsszone	*fssp_fsszone;	/* fsszone_t for this fssproj	*/
1110Sstevel@tonic-gate } fssproj_t;
1120Sstevel@tonic-gate 
1130Sstevel@tonic-gate /*
1140Sstevel@tonic-gate  * Fair share scheduling class specific thread structure
1150Sstevel@tonic-gate  */
1160Sstevel@tonic-gate typedef struct fssproc {
1170Sstevel@tonic-gate 	kthread_t *fss_tp;	/* pointer back to our thread		*/
118*3792Sakolb 	fssproj_t *fss_proj;	/* pointer to our project FSS data	*/
1190Sstevel@tonic-gate 	uchar_t fss_flags;	/* flags defined below			*/
1200Sstevel@tonic-gate 	int	fss_timeleft;	/* time remaining in procs quantum	*/
1210Sstevel@tonic-gate 	uint32_t fss_ticks;	/* ticks accumulated by this thread	*/
1220Sstevel@tonic-gate 	pri_t	fss_upri;	/* user supplied priority (to priocntl)	*/
1230Sstevel@tonic-gate 	pri_t	fss_uprilim;	/* user priority limit			*/
1240Sstevel@tonic-gate 	pri_t	fss_umdpri;	/* user mode priority within fs class	*/
125951Sraf 	pri_t	fss_scpri;	/* remembered priority, for schedctl	*/
1260Sstevel@tonic-gate 	int	fss_nice;	/* nice value for compatibility with ts	*/
1270Sstevel@tonic-gate 	fsspri_t fss_fsspri;	/* internal fair share priority		*/
1280Sstevel@tonic-gate 	int	fss_runnable;	/* to indicate runnable/sleeping thread	*/
1290Sstevel@tonic-gate 	struct fssproc *fss_next; /* pointer to next fssproc_t struct	*/
1300Sstevel@tonic-gate 	struct fssproc *fss_prev; /* pointer to prev fssproc_t sturct	*/
131*3792Sakolb 	caps_sc_t fss_caps;	/* CPU caps specific data		*/
1320Sstevel@tonic-gate } fssproc_t;
1330Sstevel@tonic-gate 
1340Sstevel@tonic-gate /*
135*3792Sakolb  * One of these structures is allocated to each zone running within
136*3792Sakolb  * each active cpu partition.  This means that if a zone spans more
137*3792Sakolb  * than one cpu partition then it will have a few of these structures.
1380Sstevel@tonic-gate  */
1390Sstevel@tonic-gate typedef struct fsszone {
140*3792Sakolb 	struct zone 	*fssz_zone;	/* ptr to our zone structure	*/
141*3792Sakolb 	struct fsszone	*fssz_next;	/* next fsszone_t in fsspset_t	*/
142*3792Sakolb 	struct fsszone	*fssz_prev;	/* prev fsszone_t in fsspset_t	*/
143*3792Sakolb 	uint32_t	fssz_shares;	/* sum of all project shares	*/
144*3792Sakolb 	uint32_t	fssz_nproj;	/* # of projects		*/
145*3792Sakolb 	uint32_t	fssz_rshares;	/* "real" shares given to zone	*/
146*3792Sakolb 	uint32_t	fssz_runnable;	/* # of runnable projects	*/
1470Sstevel@tonic-gate } fsszone_t;
1480Sstevel@tonic-gate 
1490Sstevel@tonic-gate #define	FSSPROC(tx)		((fssproc_t *)(tx->t_cldata))
1500Sstevel@tonic-gate #define	FSSPROC2FSSPROJ(fssx)	((fssx)->fss_proj);
1510Sstevel@tonic-gate #define	FSSPROC2FSSPSET(fssx)	(FSSPROC2FSSPROJ(fssx)->fssp_pset)
1520Sstevel@tonic-gate #define	FSSPROJ(tx)		(FSSPROC(tx)->fss_proj)
1530Sstevel@tonic-gate #define	FSSPROJ2FSSPSET(fssx)	((fssx)->fssp_pset)
1540Sstevel@tonic-gate #define	FSSPROJ2KPROJ(fssx)	((fssx)->fssp_proj)
1550Sstevel@tonic-gate #define	FSSPROJ2FSSZONE(fssx)	((fssx)->fssp_fsszone)
1560Sstevel@tonic-gate 
1570Sstevel@tonic-gate /*
1580Sstevel@tonic-gate  * fss_flags
1590Sstevel@tonic-gate  */
1600Sstevel@tonic-gate #define	FSSKPRI		0x01	/* the thread is in kernel mode	*/
1610Sstevel@tonic-gate #define	FSSBACKQ	0x02	/* thread should be placed at the back of */
1620Sstevel@tonic-gate 				/* the dispatch queue if preempted */
163951Sraf #define	FSSRESTORE	0x04	/* thread was not preempted, due to schedctl */
164951Sraf 				/* restore priority from fss_scpri */
165*3792Sakolb 
166*3792Sakolb #endif	/* _KERNEL */
167*3792Sakolb 
1680Sstevel@tonic-gate #ifdef	__cplusplus
1690Sstevel@tonic-gate }
1700Sstevel@tonic-gate #endif
1710Sstevel@tonic-gate 
1720Sstevel@tonic-gate #endif	/* _SYS_FSS_H */
173