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