man pages section 3: Extended Library Functions, Volume 4

Exit Print View

Updated: July 2014



zs_pset, zs_pset_list, zs_pset_walk, zs_pset_property, zs_pset_total_time, zs_pset_total_cpus, zs_pset_used_time, zs_pset_used_cpus, zs_pset_used_pct - libzonestat pset accessor methods


cc [ flag ... ] file... -lzonestat [ libary ... ]
#include <zonestat.h>

int zs_pset_list(zs_usage_t usage, zs_pset_t *psetlist, int num);
zs_pset_t zs_pset_walk(zs_usage_t usage, zs_pset_t pset);
zs_property_t zs_pset_property(zs_pset_t pset, zs_pset_property_t prop);
void zs_pset_total_time(zs_pset_t pset, timestruc_t *ts);
uint64_t zs_pset_total_cpus(zs_pset_t pset);
void zs_pset_used_time(zs_pset_t pset, zs_user_t user, timestruc_t *ts);
uint64_t zs_pset_used_cpus(zs_pset_t pset, zs_user_t user);
uint_t zs_pset_used_pct(zs_pset_t pset, zs_user_t user);


These functions are used to access the processor sets (psets) in the usage object. These psets are the psets which existed at the time when the zs_usage_read was called, and returned the usage object.

By default, the system has a single processor set which contains all cpus. Processor sets can be created by resource pools (pooladm(1M)), the psrset(1M) command, and by the zonecfg(1M) dedicated cpu resource.

The zs_pset_list function returns the number of zs_pset_t objects contained within usage. If psetlist is non-NULL, the psetlist array will be filled with up to num zs_pset_t objects. The psetlist array must be first allocated by the caller. The first pset returned in the array will always be the default pset. The remaining pset will be in alphanumeric ordered by pset name.

The zs_pset_walk function walks the psets contained in usage. If pset is NULL, the first pset is returned. The first pset is always the default pset. Otherwise, the psets are returned in alphanumeric order. NULL will be returned if there are no more psets.

The zs_pset_property function will return the prop property of a pset. See libzonestat(3lib) for a description of the ZS_PSET_PROP_* property codes.

The zs_pset_total_time function sets ts to the total cpu time that has been available in pset. For example, if a pset has 2 online cpus, and zs_open as called 30 seconds before zs_usage_read, then the total time available in the pset is 60 seconds. ts must be allocated by the caller.

The zs_pset_total_cpus function returns the number of online cpus in pset * 100. For instance, if the number of online cpus is 4, the value returned will be 400.

The zs_pset_used_time function sets ts to the total cpu time that has been used in pset, starting at zero from the point when zs_open was first called.

The zs_pset_used_cpus function returns quantity of cpus used by user. The value returned is the number of cpus used * 100. For instance, if user ZS_USER_ZONES (which represents total pset usage by all zones) has used 2.5 cpus worth of cpu time, then the value returned is 250.

The uint_t zs_pset_used_pct function returns the percentage of cpu time used by user. The value returned is the percentage * 100. For example, if user ZS_USER_ALL (representing total cpu usage) is 50%, then the value returned will be 5000.

All ZS_USER_* user codes are described in the libzonestat(3lib) manual page.

Return Values

See Description


If a zs_pset_*() function is called with an invalid user code, the function will abort with abort(3C).


Example 1 Retrieve information about all psets in a usage object.

The following example traverses all psets in a usage object, retrieving information about each pset.

#include <zonestat.h>
extern zs_usage_t usage;        /* assume returned by zs_usage_read() */
zs_pset_t pset;
zs_property_t prop;
char * psetname;
uint64_t online;
uint64_t used;

for (pset = zs_pset_first(usage); pset != NULL;
    pset = zs_pset_next(usage, pset)) {

/* Get psetname */
prop = zs_pset_property(pset, ZS_PSET_PROP_NAME);
psetname = strdup(zs_property_string(prop)));

 * Get number of online cpus, and quantity of cpu used, both in
 * number of cpus * 100.
online = zs_pset_total_cpus(pset);
used = zs_pset_used_cpus(pset, ZS_USER_ALL);


See attributes(5) for descriptions of the following attributes:

Interface Stability

See also

zonestat(1), pooladm(1M) , psrset(1M), rcapadm(1M) , swap(1M), zoneadm(1M) , zonestatd(1M), abort(3C), libpool(3LIB), libzonestat (3LIB), zs_open(3ZONESTAT), zs_property(3ZONESTAT), zs_pset_zone(3ZONESTAT), zs_resource(3ZONESTAT), zs_usage(3ZONESTAT), zs_zone(3ZONESTAT), attributes (5), resource_controls(5)