13247Sgjelinek /* 23247Sgjelinek * CDDL HEADER START 33247Sgjelinek * 43247Sgjelinek * The contents of this file are subject to the terms of the 53247Sgjelinek * Common Development and Distribution License (the "License"). 63247Sgjelinek * You may not use this file except in compliance with the License. 73247Sgjelinek * 83247Sgjelinek * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 93247Sgjelinek * or http://www.opensolaris.org/os/licensing. 103247Sgjelinek * See the License for the specific language governing permissions 113247Sgjelinek * and limitations under the License. 123247Sgjelinek * 133247Sgjelinek * When distributing Covered Code, include this CDDL HEADER in each 143247Sgjelinek * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 153247Sgjelinek * If applicable, add the following below this CDDL HEADER, with the 163247Sgjelinek * fields enclosed by brackets "[]" replaced with your own identifying 173247Sgjelinek * information: Portions Copyright [yyyy] [name of copyright owner] 183247Sgjelinek * 193247Sgjelinek * CDDL HEADER END 203247Sgjelinek */ 213247Sgjelinek /* 22*7884Sgerald.jelinek@sun.com * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 233247Sgjelinek * Use is subject to license terms. 243247Sgjelinek */ 253247Sgjelinek 263247Sgjelinek #ifndef _SYS_VM_USAGE_H 273247Sgjelinek #define _SYS_VM_USAGE_H 283247Sgjelinek 293247Sgjelinek #include <sys/types.h> 303247Sgjelinek 313247Sgjelinek #ifdef __cplusplus 323247Sgjelinek extern "C" { 333247Sgjelinek #endif 343247Sgjelinek 353247Sgjelinek /* 363247Sgjelinek * The flags passed to getvmusage() request how to aggregate rss/swap results. 373247Sgjelinek * Results can be aggregated by zone, project, task, ruser, and/or euser. 383247Sgjelinek * 393247Sgjelinek * If VMUSAGE_ALL_* or VMUSAGE_COL_* are passed from a non-global-zone, the 403247Sgjelinek * flag is treated as VMUSAGE_*. For example, VMUSAGE_ALL_ZONES would be 413247Sgjelinek * treated as VMUSAGE_ZONE. 423247Sgjelinek * 433247Sgjelinek * If VMUSAGE_SYSTEM is passed from a non-global zone, a result of type 443247Sgjelinek * VMUSAGE_SYSTEM will be returned, but it will only reflect the usage 453247Sgjelinek * of the calling zone. 463247Sgjelinek * 473247Sgjelinek * VMUSAGE_* requests results for the calling zone. 483247Sgjelinek * VMUSAGE_ALL_* requests results for all zones. 493247Sgjelinek * VMUSAGE_COL_* requests results for all zones, but collapses out the zoneid. 503247Sgjelinek * For example, VMUSAGE_COL_PROJECTS requests results for all 513247Sgjelinek * projects in all zones, and project N in ANY zone is treated 523247Sgjelinek * as the same project. 533247Sgjelinek */ 543247Sgjelinek #define VMUSAGE_SYSTEM 0x1 /* rss/swap for ALL processes */ 553247Sgjelinek #define VMUSAGE_ZONE 0x2 /* rss/swap for caller's zone */ 563247Sgjelinek #define VMUSAGE_PROJECTS 0x4 /* rss/swap for all projects in */ 573247Sgjelinek /* caller's zone */ 583247Sgjelinek #define VMUSAGE_TASKS 0x8 /* rss/swap for all tasks in */ 593247Sgjelinek /* caller's zones */ 603247Sgjelinek #define VMUSAGE_RUSERS 0x10 /* rss/swap for all users (by process */ 613247Sgjelinek /* ruser) in the caller's zone */ 623247Sgjelinek #define VMUSAGE_EUSERS 0x20 /* same as VMUSAGE_RUSERS, but by */ 633247Sgjelinek /* euser */ 643247Sgjelinek 653247Sgjelinek #define VMUSAGE_ALL_ZONES 0x40 /* rss/swap for all zones */ 663247Sgjelinek #define VMUSAGE_ALL_PROJECTS 0x80 /* rss/swap for all projects in */ 673247Sgjelinek /* all zones */ 683247Sgjelinek #define VMUSAGE_ALL_TASKS 0x100 /* rss/swap for all tasks in all */ 693247Sgjelinek /* zones */ 703247Sgjelinek #define VMUSAGE_ALL_RUSERS 0x200 /* rss/swap for all users (by process */ 713247Sgjelinek /* ruser) in all zones */ 723247Sgjelinek #define VMUSAGE_ALL_EUSERS 0x400 /* same as VMUSAGE_ALL_RUSERS, but by */ 733247Sgjelinek /* euser */ 743247Sgjelinek 753247Sgjelinek #define VMUSAGE_COL_PROJECTS 0x800 /* rss/swap for all projects in */ 763247Sgjelinek /* all zones. Collapse zoneid. */ 773247Sgjelinek #define VMUSAGE_COL_RUSERS 0x1000 /* rss/swap for all users (by process */ 783247Sgjelinek /* ruser), in all zones. Collapse */ 793247Sgjelinek /* zoneid */ 803247Sgjelinek #define VMUSAGE_COL_EUSERS 0x2000 /* same as VMUSAGE_COL_RUSERS, but by */ 813247Sgjelinek /* euser */ 823247Sgjelinek 833247Sgjelinek #define VMUSAGE_MASK 0x3fff /* all valid flags for getvmusage() */ 843247Sgjelinek 853247Sgjelinek typedef struct vmusage { 863247Sgjelinek id_t vmu_zoneid; /* zoneid, or ALL_ZONES for */ 873247Sgjelinek /* VMUSAGE_COL_* results */ 883247Sgjelinek /* ALL_ZONES means that the result */ 893247Sgjelinek /* reflects swap and rss usage for */ 903247Sgjelinek /* a projid/uid across all zones */ 913247Sgjelinek uint_t vmu_type; /* Entity type of result. One of: */ 923247Sgjelinek /* VMUSAGE_(SYSTEM|ZONE|PROJECTS| */ 933247Sgjelinek /* TASKS|RUSERS|EUSERS) */ 943247Sgjelinek id_t vmu_id; /* zoneid, projid, taskid, ... */ 953247Sgjelinek size_t vmu_rss_all; /* total resident memory of entity */ 963247Sgjelinek /* in bytes */ 973247Sgjelinek size_t vmu_rss_private; /* total resident private memory */ 983247Sgjelinek size_t vmu_rss_shared; /* total resident shared memory */ 993247Sgjelinek size_t vmu_swap_all; /* total swap reserved, in bytes */ 1003247Sgjelinek size_t vmu_swap_private; /* swap reserved for private mappings */ 1013247Sgjelinek size_t vmu_swap_shared; /* swap reserved for shared mappings */ 1023247Sgjelinek 1033247Sgjelinek } vmusage_t; 1043247Sgjelinek 1053247Sgjelinek extern int getvmusage(uint_t flags, time_t age, vmusage_t *buf, size_t *nres); 1063247Sgjelinek 1073247Sgjelinek #ifdef _KERNEL 1083247Sgjelinek 109*7884Sgerald.jelinek@sun.com int vm_getusage(uint_t, time_t, vmusage_t *, size_t *, int); 1103247Sgjelinek void vm_usage_init(); 1113247Sgjelinek 1123247Sgjelinek #endif /* _KERNEL */ 1133247Sgjelinek 1143247Sgjelinek #ifdef __cplusplus 1153247Sgjelinek } 1163247Sgjelinek #endif 1173247Sgjelinek 1183247Sgjelinek #endif /* _SYS_VM_USAGE_H */ 119