xref: /onnv-gate/usr/src/uts/common/sys/vm_usage.h (revision 3247:e05001c14ea2)
1*3247Sgjelinek /*
2*3247Sgjelinek  * CDDL HEADER START
3*3247Sgjelinek  *
4*3247Sgjelinek  * The contents of this file are subject to the terms of the
5*3247Sgjelinek  * Common Development and Distribution License (the "License").
6*3247Sgjelinek  * You may not use this file except in compliance with the License.
7*3247Sgjelinek  *
8*3247Sgjelinek  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*3247Sgjelinek  * or http://www.opensolaris.org/os/licensing.
10*3247Sgjelinek  * See the License for the specific language governing permissions
11*3247Sgjelinek  * and limitations under the License.
12*3247Sgjelinek  *
13*3247Sgjelinek  * When distributing Covered Code, include this CDDL HEADER in each
14*3247Sgjelinek  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*3247Sgjelinek  * If applicable, add the following below this CDDL HEADER, with the
16*3247Sgjelinek  * fields enclosed by brackets "[]" replaced with your own identifying
17*3247Sgjelinek  * information: Portions Copyright [yyyy] [name of copyright owner]
18*3247Sgjelinek  *
19*3247Sgjelinek  * CDDL HEADER END
20*3247Sgjelinek  */
21*3247Sgjelinek /*
22*3247Sgjelinek  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23*3247Sgjelinek  * Use is subject to license terms.
24*3247Sgjelinek  */
25*3247Sgjelinek 
26*3247Sgjelinek #ifndef	_SYS_VM_USAGE_H
27*3247Sgjelinek #define	_SYS_VM_USAGE_H
28*3247Sgjelinek 
29*3247Sgjelinek #pragma ident	"%Z%%M%	%I%	%E% SMI"
30*3247Sgjelinek 
31*3247Sgjelinek #include <sys/types.h>
32*3247Sgjelinek 
33*3247Sgjelinek #ifdef	__cplusplus
34*3247Sgjelinek extern "C" {
35*3247Sgjelinek #endif
36*3247Sgjelinek 
37*3247Sgjelinek /*
38*3247Sgjelinek  * The flags passed to getvmusage() request how to aggregate rss/swap results.
39*3247Sgjelinek  * Results can be aggregated by zone, project, task, ruser, and/or euser.
40*3247Sgjelinek  *
41*3247Sgjelinek  * If VMUSAGE_ALL_* or VMUSAGE_COL_* are passed from a non-global-zone, the
42*3247Sgjelinek  * flag is treated as VMUSAGE_*.  For example, VMUSAGE_ALL_ZONES would be
43*3247Sgjelinek  * treated as VMUSAGE_ZONE.
44*3247Sgjelinek  *
45*3247Sgjelinek  * If VMUSAGE_SYSTEM is passed from a non-global zone, a result of type
46*3247Sgjelinek  * VMUSAGE_SYSTEM will be returned, but it will only reflect the usage
47*3247Sgjelinek  * of the calling zone.
48*3247Sgjelinek  *
49*3247Sgjelinek  * VMUSAGE_*	 requests results for the calling zone.
50*3247Sgjelinek  * VMUSAGE_ALL_* requests results for all zones.
51*3247Sgjelinek  * VMUSAGE_COL_* requests results for all zones, but collapses out the zoneid.
52*3247Sgjelinek  *		 For example, VMUSAGE_COL_PROJECTS requests results for all
53*3247Sgjelinek  *		 projects in all zones, and project N in ANY zone is treated
54*3247Sgjelinek  *		 as the same project.
55*3247Sgjelinek  */
56*3247Sgjelinek #define	VMUSAGE_SYSTEM		0x1	/* rss/swap for ALL processes */
57*3247Sgjelinek #define	VMUSAGE_ZONE		0x2	/* rss/swap for caller's zone */
58*3247Sgjelinek #define	VMUSAGE_PROJECTS	0x4	/* rss/swap for all projects in */
59*3247Sgjelinek 					/* caller's zone */
60*3247Sgjelinek #define	VMUSAGE_TASKS		0x8	/* rss/swap for all tasks in */
61*3247Sgjelinek 					/* caller's zones */
62*3247Sgjelinek #define	VMUSAGE_RUSERS		0x10	/* rss/swap for all users (by process */
63*3247Sgjelinek 					/* ruser) in the caller's zone */
64*3247Sgjelinek #define	VMUSAGE_EUSERS		0x20	/* same as VMUSAGE_RUSERS, but by */
65*3247Sgjelinek 					/* euser */
66*3247Sgjelinek 
67*3247Sgjelinek #define	VMUSAGE_ALL_ZONES	0x40	/* rss/swap for all zones */
68*3247Sgjelinek #define	VMUSAGE_ALL_PROJECTS	0x80	/* rss/swap for all projects in */
69*3247Sgjelinek 					/* all zones */
70*3247Sgjelinek #define	VMUSAGE_ALL_TASKS	0x100	/* rss/swap for all tasks in all */
71*3247Sgjelinek 					/* zones */
72*3247Sgjelinek #define	VMUSAGE_ALL_RUSERS	0x200	/* rss/swap for all users (by process */
73*3247Sgjelinek 					/* ruser) in all zones */
74*3247Sgjelinek #define	VMUSAGE_ALL_EUSERS	0x400	/* same as VMUSAGE_ALL_RUSERS, but by */
75*3247Sgjelinek 					/* euser */
76*3247Sgjelinek 
77*3247Sgjelinek #define	VMUSAGE_COL_PROJECTS	0x800	/* rss/swap for all projects in */
78*3247Sgjelinek 					/* all zones.  Collapse zoneid. */
79*3247Sgjelinek #define	VMUSAGE_COL_RUSERS	0x1000	/* rss/swap for all users (by process */
80*3247Sgjelinek 					/* ruser), in all zones.  Collapse */
81*3247Sgjelinek 					/* zoneid */
82*3247Sgjelinek #define	VMUSAGE_COL_EUSERS	0x2000	/* same as VMUSAGE_COL_RUSERS, but by */
83*3247Sgjelinek 					/* euser */
84*3247Sgjelinek 
85*3247Sgjelinek #define	VMUSAGE_MASK		0x3fff  /* all valid flags for getvmusage() */
86*3247Sgjelinek 
87*3247Sgjelinek typedef struct vmusage {
88*3247Sgjelinek 	id_t	vmu_zoneid;		/* zoneid, or ALL_ZONES for */
89*3247Sgjelinek 					/* VMUSAGE_COL_* results */
90*3247Sgjelinek 					/* ALL_ZONES means that the result */
91*3247Sgjelinek 					/* reflects swap and rss usage for */
92*3247Sgjelinek 					/* a projid/uid across all zones */
93*3247Sgjelinek 	uint_t	vmu_type;		/* Entity type of result.  One of:  */
94*3247Sgjelinek 					/* VMUSAGE_(SYSTEM|ZONE|PROJECTS| */
95*3247Sgjelinek 					/* TASKS|RUSERS|EUSERS) */
96*3247Sgjelinek 	id_t	vmu_id;			/* zoneid, projid, taskid, ... */
97*3247Sgjelinek 	size_t	vmu_rss_all;		/* total resident memory of entity */
98*3247Sgjelinek 					/* in bytes */
99*3247Sgjelinek 	size_t	vmu_rss_private;	/* total resident private memory */
100*3247Sgjelinek 	size_t	vmu_rss_shared;		/* total resident shared memory */
101*3247Sgjelinek 	size_t	vmu_swap_all;		/* total swap reserved, in bytes */
102*3247Sgjelinek 	size_t	vmu_swap_private;	/* swap reserved for private mappings */
103*3247Sgjelinek 	size_t	vmu_swap_shared;	/* swap reserved for shared mappings */
104*3247Sgjelinek 
105*3247Sgjelinek } vmusage_t;
106*3247Sgjelinek 
107*3247Sgjelinek extern int getvmusage(uint_t flags, time_t age, vmusage_t *buf, size_t *nres);
108*3247Sgjelinek 
109*3247Sgjelinek #ifdef	_KERNEL
110*3247Sgjelinek 
111*3247Sgjelinek int vm_getusage(uint_t, time_t, vmusage_t *, size_t *);
112*3247Sgjelinek void vm_usage_init();
113*3247Sgjelinek 
114*3247Sgjelinek #endif	/* _KERNEL */
115*3247Sgjelinek 
116*3247Sgjelinek #ifdef	__cplusplus
117*3247Sgjelinek }
118*3247Sgjelinek #endif
119*3247Sgjelinek 
120*3247Sgjelinek #endif	/* _SYS_VM_USAGE_H */
121