xref: /titanic_52/usr/src/uts/common/sys/fss.h (revision 9ac8606f19e304e832a685ae7060cc3c284b9779)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
22*9ac8606fSraf 
237c478bd9Sstevel@tonic-gate /*
24*9ac8606fSraf  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
257c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #ifndef	_SYS_FSS_H
297c478bd9Sstevel@tonic-gate #define	_SYS_FSS_H
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #include <sys/types.h>
347c478bd9Sstevel@tonic-gate #include <sys/thread.h>
357c478bd9Sstevel@tonic-gate #include <sys/project.h>
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
387c478bd9Sstevel@tonic-gate extern "C" {
397c478bd9Sstevel@tonic-gate #endif
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate typedef uint64_t fsspri_t;
427c478bd9Sstevel@tonic-gate typedef	uint64_t fssusage_t;
437c478bd9Sstevel@tonic-gate struct cpupart;
447c478bd9Sstevel@tonic-gate struct zone;
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate /*
477c478bd9Sstevel@tonic-gate  * Valid arg1's for fss_allocbuf()
487c478bd9Sstevel@tonic-gate  */
497c478bd9Sstevel@tonic-gate #define	FSS_NPSET_BUF	1
507c478bd9Sstevel@tonic-gate #define	FSS_NPROJ_BUF	2
517c478bd9Sstevel@tonic-gate #define	FSS_ONE_BUF	3
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate /*
547c478bd9Sstevel@tonic-gate  * Valid arg2's for fss_allocbuf()
557c478bd9Sstevel@tonic-gate  */
567c478bd9Sstevel@tonic-gate #define	FSS_ALLOC_PROJ	1
577c478bd9Sstevel@tonic-gate #define	FSS_ALLOC_ZONE	2
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate #define	FSS_MAXSHARES	65535
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate typedef struct fssbuf {
627c478bd9Sstevel@tonic-gate 	int	fssb_size;
637c478bd9Sstevel@tonic-gate 	void	**fssb_list;
647c478bd9Sstevel@tonic-gate } fssbuf_t;
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate void *fss_allocbuf(int, int);
677c478bd9Sstevel@tonic-gate void fss_freebuf(fssbuf_t *, int);
687c478bd9Sstevel@tonic-gate void fss_changeproj(kthread_id_t, void *, void *, fssbuf_t *, fssbuf_t *);
697c478bd9Sstevel@tonic-gate void fss_changepset(kthread_id_t, void *, fssbuf_t *, fssbuf_t *);
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate /*
727c478bd9Sstevel@tonic-gate  * Fair share scheduling class specific cpu partition structure
737c478bd9Sstevel@tonic-gate  */
747c478bd9Sstevel@tonic-gate typedef struct fsspset {
757c478bd9Sstevel@tonic-gate 	kmutex_t	fssps_lock;	/* lock to protect per-pset	*/
767c478bd9Sstevel@tonic-gate 					/* list of fssproj structures	*/
777c478bd9Sstevel@tonic-gate 	disp_lock_t	fssps_displock;	/* lock for fsps_maxfspri	*/
787c478bd9Sstevel@tonic-gate 	struct cpupart	*fssps_cpupart;	/* ptr to our cpu partition	*/
797c478bd9Sstevel@tonic-gate 					/* protected by fsspsets_lock	*/
807c478bd9Sstevel@tonic-gate 	fsspri_t	fssps_maxfsspri; /* maximum fsspri value among	*/
817c478bd9Sstevel@tonic-gate 					/* all projects on this pset	*/
827c478bd9Sstevel@tonic-gate 	uint32_t	fssps_shares;	/* number of active shares	*/
837c478bd9Sstevel@tonic-gate 	uint32_t	fssps_nproj;	/* number of fssproj structures */
847c478bd9Sstevel@tonic-gate 					/* on the list			*/
857c478bd9Sstevel@tonic-gate 	struct fssproj	*fssps_list;	/* list of project parts	*/
867c478bd9Sstevel@tonic-gate 	struct fsszone	*fssps_zones;	/* list of fsszone_t's in pset	*/
877c478bd9Sstevel@tonic-gate } fsspset_t;
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate /*
907c478bd9Sstevel@tonic-gate  * One of these structures is allocated to each project running within each
917c478bd9Sstevel@tonic-gate  * active cpu partition.
927c478bd9Sstevel@tonic-gate  */
937c478bd9Sstevel@tonic-gate typedef struct fssproj {
947c478bd9Sstevel@tonic-gate 	kproject_t	*fssp_proj;	/* ptr to our project structure	*/
957c478bd9Sstevel@tonic-gate 	fsspset_t	*fssp_pset;	/* ptr to our fsspset structure	*/
967c478bd9Sstevel@tonic-gate 	uint32_t	fssp_threads;	/* total number of threads here */
977c478bd9Sstevel@tonic-gate 					/* protected by fssps_lock	*/
987c478bd9Sstevel@tonic-gate 	uint32_t	fssp_runnable;	/* number of runnable threads	*/
997c478bd9Sstevel@tonic-gate 					/* protected by fssps_lock	*/
1007c478bd9Sstevel@tonic-gate 	uint32_t	fssp_shares;	/* copy of our kpj_shares	*/
1017c478bd9Sstevel@tonic-gate 					/* protected by fssps_displock	*/
1027c478bd9Sstevel@tonic-gate 	uint32_t	fssp_ticks;	/* total of all ticks		*/
1037c478bd9Sstevel@tonic-gate 					/* protected by fssps_displock	*/
1047c478bd9Sstevel@tonic-gate 	fssusage_t	fssp_usage;	/* this project's decayed usage */
1057c478bd9Sstevel@tonic-gate 	fssusage_t	fssp_shusage;	/* normalized usage		*/
1067c478bd9Sstevel@tonic-gate 	struct fssproj	*fssp_next;	/* next project on this pset	*/
1077c478bd9Sstevel@tonic-gate 	struct fssproj	*fssp_prev;	/* prev project on this pset	*/
1087c478bd9Sstevel@tonic-gate 	struct fsszone	*fssp_fsszone;	/* fsszone_t for this fssproj	*/
1097c478bd9Sstevel@tonic-gate } fssproj_t;
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate /*
1127c478bd9Sstevel@tonic-gate  * Fair share scheduling class specific thread structure
1137c478bd9Sstevel@tonic-gate  */
1147c478bd9Sstevel@tonic-gate typedef struct fssproc {
1157c478bd9Sstevel@tonic-gate 	kthread_t *fss_tp;	/* pointer back to our thread		*/
1167c478bd9Sstevel@tonic-gate 	fssproj_t *fss_proj;	/* pointer to our project FS data	*/
1177c478bd9Sstevel@tonic-gate 	uchar_t fss_flags;	/* flags defined below			*/
1187c478bd9Sstevel@tonic-gate 	int	fss_timeleft;	/* time remaining in procs quantum	*/
1197c478bd9Sstevel@tonic-gate 	uint32_t fss_ticks;	/* ticks accumulated by this thread	*/
1207c478bd9Sstevel@tonic-gate 	pri_t	fss_upri;	/* user supplied priority (to priocntl)	*/
1217c478bd9Sstevel@tonic-gate 	pri_t	fss_uprilim;	/* user priority limit			*/
1227c478bd9Sstevel@tonic-gate 	pri_t	fss_umdpri;	/* user mode priority within fs class	*/
123*9ac8606fSraf 	pri_t	fss_scpri;	/* remembered priority, for schedctl	*/
1247c478bd9Sstevel@tonic-gate 	int	fss_nice;	/* nice value for compatibility with ts	*/
1257c478bd9Sstevel@tonic-gate 	fsspri_t fss_fsspri;	/* internal fair share priority		*/
1267c478bd9Sstevel@tonic-gate 	int	fss_runnable;	/* to indicate runnable/sleeping thread	*/
1277c478bd9Sstevel@tonic-gate 	struct fssproc *fss_next; /* pointer to next fssproc_t struct	*/
1287c478bd9Sstevel@tonic-gate 	struct fssproc *fss_prev; /* pointer to prev fssproc_t sturct	*/
1297c478bd9Sstevel@tonic-gate } fssproc_t;
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate /*
1327c478bd9Sstevel@tonic-gate  * One of these structures is allocated to each zone running within each active
1337c478bd9Sstevel@tonic-gate  * cpu partition.
1347c478bd9Sstevel@tonic-gate  */
1357c478bd9Sstevel@tonic-gate typedef struct fsszone {
1367c478bd9Sstevel@tonic-gate 	struct zone 	*fssz_zone;	/* ptr to our zone structure */
1377c478bd9Sstevel@tonic-gate 	struct fsszone	*fssz_next;	/* ptr to next fsszone in fsspset */
1387c478bd9Sstevel@tonic-gate 	struct fsszone	*fssz_prev;	/* ptr to prev fsszone in fsspset */
1397c478bd9Sstevel@tonic-gate 	uint32_t	fssz_shares;	/* total #shares for projs in zone */
1407c478bd9Sstevel@tonic-gate 	uint32_t	fssz_nproj;	/* # fssproj_t's in this fsszone */
1417c478bd9Sstevel@tonic-gate 	uint32_t	fssz_rshares;	/* "real" shares given to zone */
1427c478bd9Sstevel@tonic-gate 	uint32_t	fssz_runnable;	/* # projects with runnable threads */
1437c478bd9Sstevel@tonic-gate } fsszone_t;
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate #define	FSSPROC(tx)		((fssproc_t *)(tx->t_cldata))
1467c478bd9Sstevel@tonic-gate #define	FSSPROC2FSSPROJ(fssx)	((fssx)->fss_proj);
1477c478bd9Sstevel@tonic-gate #define	FSSPROC2FSSPSET(fssx)	(FSSPROC2FSSPROJ(fssx)->fssp_pset)
1487c478bd9Sstevel@tonic-gate #define	FSSPROJ(tx)		(FSSPROC(tx)->fss_proj)
1497c478bd9Sstevel@tonic-gate #define	FSSPROJ2FSSPSET(fssx)	((fssx)->fssp_pset)
1507c478bd9Sstevel@tonic-gate #define	FSSPROJ2KPROJ(fssx)	((fssx)->fssp_proj)
1517c478bd9Sstevel@tonic-gate #define	FSSPROJ2FSSZONE(fssx)	((fssx)->fssp_fsszone)
1527c478bd9Sstevel@tonic-gate 
1537c478bd9Sstevel@tonic-gate /*
1547c478bd9Sstevel@tonic-gate  * fss_flags
1557c478bd9Sstevel@tonic-gate  */
1567c478bd9Sstevel@tonic-gate #define	FSSKPRI		0x01	/* the thread is in kernel mode	*/
1577c478bd9Sstevel@tonic-gate #define	FSSBACKQ	0x02	/* thread should be placed at the back of */
1587c478bd9Sstevel@tonic-gate 				/* the dispatch queue if preempted */
159*9ac8606fSraf #define	FSSRESTORE	0x04	/* thread was not preempted, due to schedctl */
160*9ac8606fSraf 				/* restore priority from fss_scpri */
1617c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1627c478bd9Sstevel@tonic-gate }
1637c478bd9Sstevel@tonic-gate #endif
1647c478bd9Sstevel@tonic-gate 
1657c478bd9Sstevel@tonic-gate #endif	/* _SYS_FSS_H */
166