xref: /illumos-gate/usr/src/uts/common/sys/vm_usage.h (revision 00792c0b)
10209230bSgjelinek /*
20209230bSgjelinek  * CDDL HEADER START
30209230bSgjelinek  *
40209230bSgjelinek  * The contents of this file are subject to the terms of the
50209230bSgjelinek  * Common Development and Distribution License (the "License").
60209230bSgjelinek  * You may not use this file except in compliance with the License.
70209230bSgjelinek  *
80209230bSgjelinek  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90209230bSgjelinek  * or http://www.opensolaris.org/os/licensing.
100209230bSgjelinek  * See the License for the specific language governing permissions
110209230bSgjelinek  * and limitations under the License.
120209230bSgjelinek  *
130209230bSgjelinek  * When distributing Covered Code, include this CDDL HEADER in each
140209230bSgjelinek  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150209230bSgjelinek  * If applicable, add the following below this CDDL HEADER, with the
160209230bSgjelinek  * fields enclosed by brackets "[]" replaced with your own identifying
170209230bSgjelinek  * information: Portions Copyright [yyyy] [name of copyright owner]
180209230bSgjelinek  *
190209230bSgjelinek  * CDDL HEADER END
200209230bSgjelinek  */
210209230bSgjelinek /*
22*00792c0bS  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
230209230bSgjelinek  * Use is subject to license terms.
240209230bSgjelinek  */
250209230bSgjelinek 
260209230bSgjelinek #ifndef	_SYS_VM_USAGE_H
270209230bSgjelinek #define	_SYS_VM_USAGE_H
280209230bSgjelinek 
290209230bSgjelinek #include <sys/types.h>
300209230bSgjelinek 
310209230bSgjelinek #ifdef	__cplusplus
320209230bSgjelinek extern "C" {
330209230bSgjelinek #endif
340209230bSgjelinek 
350209230bSgjelinek /*
360209230bSgjelinek  * The flags passed to getvmusage() request how to aggregate rss/swap results.
370209230bSgjelinek  * Results can be aggregated by zone, project, task, ruser, and/or euser.
380209230bSgjelinek  *
390209230bSgjelinek  * If VMUSAGE_ALL_* or VMUSAGE_COL_* are passed from a non-global-zone, the
400209230bSgjelinek  * flag is treated as VMUSAGE_*.  For example, VMUSAGE_ALL_ZONES would be
410209230bSgjelinek  * treated as VMUSAGE_ZONE.
420209230bSgjelinek  *
430209230bSgjelinek  * If VMUSAGE_SYSTEM is passed from a non-global zone, a result of type
440209230bSgjelinek  * VMUSAGE_SYSTEM will be returned, but it will only reflect the usage
450209230bSgjelinek  * of the calling zone.
460209230bSgjelinek  *
470209230bSgjelinek  * VMUSAGE_*	 requests results for the calling zone.
480209230bSgjelinek  * VMUSAGE_ALL_* requests results for all zones.
490209230bSgjelinek  * VMUSAGE_COL_* requests results for all zones, but collapses out the zoneid.
500209230bSgjelinek  *		 For example, VMUSAGE_COL_PROJECTS requests results for all
510209230bSgjelinek  *		 projects in all zones, and project N in ANY zone is treated
520209230bSgjelinek  *		 as the same project.
530209230bSgjelinek  */
540209230bSgjelinek #define	VMUSAGE_SYSTEM		0x1	/* rss/swap for ALL processes */
550209230bSgjelinek #define	VMUSAGE_ZONE		0x2	/* rss/swap for caller's zone */
560209230bSgjelinek #define	VMUSAGE_PROJECTS	0x4	/* rss/swap for all projects in */
570209230bSgjelinek 					/* caller's zone */
580209230bSgjelinek #define	VMUSAGE_TASKS		0x8	/* rss/swap for all tasks in */
590209230bSgjelinek 					/* caller's zones */
600209230bSgjelinek #define	VMUSAGE_RUSERS		0x10	/* rss/swap for all users (by process */
610209230bSgjelinek 					/* ruser) in the caller's zone */
620209230bSgjelinek #define	VMUSAGE_EUSERS		0x20	/* same as VMUSAGE_RUSERS, but by */
630209230bSgjelinek 					/* euser */
640209230bSgjelinek 
650209230bSgjelinek #define	VMUSAGE_ALL_ZONES	0x40	/* rss/swap for all zones */
660209230bSgjelinek #define	VMUSAGE_ALL_PROJECTS	0x80	/* rss/swap for all projects in */
670209230bSgjelinek 					/* all zones */
680209230bSgjelinek #define	VMUSAGE_ALL_TASKS	0x100	/* rss/swap for all tasks in all */
690209230bSgjelinek 					/* zones */
700209230bSgjelinek #define	VMUSAGE_ALL_RUSERS	0x200	/* rss/swap for all users (by process */
710209230bSgjelinek 					/* ruser) in all zones */
720209230bSgjelinek #define	VMUSAGE_ALL_EUSERS	0x400	/* same as VMUSAGE_ALL_RUSERS, but by */
730209230bSgjelinek 					/* euser */
740209230bSgjelinek 
750209230bSgjelinek #define	VMUSAGE_COL_PROJECTS	0x800	/* rss/swap for all projects in */
760209230bSgjelinek 					/* all zones.  Collapse zoneid. */
770209230bSgjelinek #define	VMUSAGE_COL_RUSERS	0x1000	/* rss/swap for all users (by process */
780209230bSgjelinek 					/* ruser), in all zones.  Collapse */
790209230bSgjelinek 					/* zoneid */
800209230bSgjelinek #define	VMUSAGE_COL_EUSERS	0x2000	/* same as VMUSAGE_COL_RUSERS, but by */
810209230bSgjelinek 					/* euser */
820209230bSgjelinek 
830209230bSgjelinek #define	VMUSAGE_MASK		0x3fff  /* all valid flags for getvmusage() */
840209230bSgjelinek 
850209230bSgjelinek typedef struct vmusage {
860209230bSgjelinek 	id_t	vmu_zoneid;		/* zoneid, or ALL_ZONES for */
870209230bSgjelinek 					/* VMUSAGE_COL_* results */
880209230bSgjelinek 					/* ALL_ZONES means that the result */
890209230bSgjelinek 					/* reflects swap and rss usage for */
900209230bSgjelinek 					/* a projid/uid across all zones */
910209230bSgjelinek 	uint_t	vmu_type;		/* Entity type of result.  One of:  */
920209230bSgjelinek 					/* VMUSAGE_(SYSTEM|ZONE|PROJECTS| */
930209230bSgjelinek 					/* TASKS|RUSERS|EUSERS) */
940209230bSgjelinek 	id_t	vmu_id;			/* zoneid, projid, taskid, ... */
950209230bSgjelinek 	size_t	vmu_rss_all;		/* total resident memory of entity */
960209230bSgjelinek 					/* in bytes */
970209230bSgjelinek 	size_t	vmu_rss_private;	/* total resident private memory */
980209230bSgjelinek 	size_t	vmu_rss_shared;		/* total resident shared memory */
990209230bSgjelinek 	size_t	vmu_swap_all;		/* total swap reserved, in bytes */
1000209230bSgjelinek 	size_t	vmu_swap_private;	/* swap reserved for private mappings */
1010209230bSgjelinek 	size_t	vmu_swap_shared;	/* swap reserved for shared mappings */
1020209230bSgjelinek 
1030209230bSgjelinek } vmusage_t;
1040209230bSgjelinek 
1050209230bSgjelinek extern int getvmusage(uint_t flags, time_t age, vmusage_t *buf, size_t *nres);
1060209230bSgjelinek 
1070209230bSgjelinek #ifdef	_KERNEL
1080209230bSgjelinek 
109*00792c0bS int vm_getusage(uint_t, time_t, vmusage_t *, size_t *, int);
1100209230bSgjelinek void vm_usage_init();
1110209230bSgjelinek 
1120209230bSgjelinek #endif	/* _KERNEL */
1130209230bSgjelinek 
1140209230bSgjelinek #ifdef	__cplusplus
1150209230bSgjelinek }
1160209230bSgjelinek #endif
1170209230bSgjelinek 
1180209230bSgjelinek #endif	/* _SYS_VM_USAGE_H */
119