Memory and Thread Placement Optimization Developer's Guide

Exit Print View

Updated: July 2014
 
 

Functions in the Solaris::lgrp Module

lgrp_init([LGRP_VIEW_CALLER | LGRP_VIEW_OS])

This function initializes the lgroup interface and takes a snapshot of the lgroup hierarchy with the given view. Given the view, the lgrp_init() function returns a cookie that represents this snapshot of the lgroup hierarchy. Use this cookie with the other routines in the lgroup interface that require the lgroup hierarchy. Call the lgrp_fini() function with this cookie when the system no longer needs the hierarchy snapshot. Unlike the lgrp_init(3LGRP) function, this function assumes a value of LGRP_VIEW_OS as the default if the system provides no view. This function returns a cookie upon successful completion. If the lgrp_init function does not complete successfully, it returns a value of undef and sets $! to indicate the error. See the man page for the lgrp_init(3LGRP) function for more information.

lgrp_fini($cookie)

This function takes a cookie, frees the snapshot of the lgroup hierarchy that the lgrp_init() function created, and cleans up anything else that the lgrp_init() function set up. After calling this function, do not use the cookie that the lgroup interface returns. This function returns 1 upon successful completion. If the lgrp_fini function does not complete successfully, it returns a value of undef and sets $! to indicate the error. See the man page for the lgrp_fini(3LGRP) function for more information.

lgrp_view($cookie)

This function takes a cookie that represents the snapshot of the lgroup hierarchy and returns the snapshot's view of the lgroup hierarchy. If the given view is LGRP_VIEW_CALLER, the snapshot contains only the resources that are available to the caller. When the view is LGRP_VIEW_OS, the snapshot contains the resources that are available to the operating system. This function returns the view for the snapshot of the lgroup hierarchy that is represented by the given cookie upon successful completion. If the lgrp_view function does not complete successfully, it returns a value of undef and sets $! to indicate the error. See the man page for the lgrp_view(3LGRP) function for more information.

lgrp_home($idtype, $id)

This function returns the home lgroup for the given process or thread. To specify a process, give the $idtype argument the value P_PID and give the $id argument the value of the process id. To specify a thread, give the $idtype argument the value P_LWPID and give the $id argument the value of the thread's LWP id. To specify the current process or thread, give the $id argument the value P_MYID. This function returns the id of the home lgroup of the specified process or thread upon successful completion. If the lgrp_home function does not complete successfully, it returns a value of undef and sets $! to indicate the error. See the man page for the lgrp_home(3LGRP) function for more information.

lgrp_cookie_stale($cookie)

This function returns the staleness status of the specified cookie upon successful completion. If the lgrp_cookie_stale function does not complete successfully, it returns a value of undef and sets $! to indicate the error. This function fails and returns EINVAL if the cookie is not valid. See the man page for the lgrp_cookie_stale(3LGRP) function for more information.

lgrp_cpus($cookie, $lgrp, $context)

This function takes a cookie that represents a snapshot of the lgroup hierarchy and returns the list of CPUs that are in the lgroup that is specified by the $lgrp argument. Give the $context argument the value LGRP_CONTENT_HIERARCHY to make the lgrp_cpus() function return the list of all the CPUs that are in the specified lgroup, including child lgroups. Give the $context() argument the value LGRP_CONTENT_DIRECT to make the lgrp_cpus() function return the list of CPUs that are directly contained in the specified lgroup. This function returns the number of CPUs that are in the specified lgroup when you call it in a scalar context. If the lgrp_cpus function does not complete successfully when you call it in a scalar context, it returns a value of undef and sets $! to indicate the error. If the lgrp_cpus function does not complete successfully when you call it in a list context, it returns the empty list and sets $! to indicate the error. See the man page for the lgrp_cpus(3LGRP) function for more information.

lgrp_children($cookie, $lgrp)

This function takes a cookie that represents a snapshot of the lgroup hierarchy and returns the list of lgroups that are children of the specified lgroup. When called in scalar context, the lgrp_children() function returns the number of children lgroups for the specified lgroup when you call it in a scalar context. If the lgrp_children function does not complete successfully when you call it in a scalar context, it returns a value of undef and sets $! to indicate the error. If the lgrp_children function does not complete successfully when you call it in a list context, it returns the empty list and sets $! to indicate the error. See the man page for the lgrp_children(3LGRP) function for more information.

lgrp_parents($cookie, $lgrp)

This function takes a cookie that represents a snapshot of the lgroup hierarchy and returns the list of parent groups of the specified lgroup. When called in scalar context, the lgrp_parents() function returns the number of parent lgroups for the specified lgroup when you call it in a scalar context. If the lgrp_parents function does not complete successfully when you call it in a scalar context, it returns a value of undef and sets $! to indicate the error. If the lgrp_parents function does not complete successfully when you call it in a list context, it returns the empty list and sets $! to indicate the error. See the man page for the lgrp_parents(3LGRP) function for more information.

lgrp_nlgrps($cookie)

This function takes a cookie that represents a snapshot of the lgroup hierarchy. It returns the number of lgroups in the hierarchy. This number is always at least one. If the lgrp_nlgrps function does not complete successfully, it returns a value of undef and sets the value of $! to EINVAL to indicate that the cookie is invalid. See the man page for the lgrp_nlgrps(3LGRP) function for more information.

lgrp_root($cookie)

This function returns the ID of the root lgroup. If the lgrp_root function does not complete successfully, it returns a value of undef and sets the value of $! to EINVAL to indicate that the cookie is invalid. See the man page for the lgrp_root(3LGRP) function for more information.

lgrp_mem_size($cookie, $lgrp, $type, $content)

This function takes a cookie that represents a snapshot of the lgroup hierarchy. The function returns the memory size of the given lgroup in bytes. Set the value of the $type argument to LGRP_MEM_SZ_FREE to have the lgrp_mem_size() function return the amount of free memory. Set the value of the $type argument to LGRP_MEM_SZ_INSTALLED to have the lgrp_mem_size() function return the amount of installed memory. Set the value of the $content argument to LGRP_CONTENT_HIERARCHY to have the lgrp_mem_size() function return results for the specified lgroup and each of its child lgroups. Set the value of the $content argument to LGRP_CONTENT_DIRECT to have the lgrp_mem_size() function return results for the specified lgroup only. This function returns the memory size in bytes upon successful completion, the size in bytes is returned. If the lgrp_mem_size function does not complete successfully, it returns a value of undef and sets $! to indicate the error. See the man page for the lgrp_mem_size(3LGRP) function for more information.

lgrp_version([VERSION])

This function takes an interface version number as the value of the VERSION argument and returns an lgroup interface version. To discover the current lgroup interface version, pass the value of LGRP_VER_CURRENT or LGRP_VER_NONE in the VERSION argument. The lgrp_version() function returns the requested version if the system supports that version. The lgrp_version() function returns LGRP_VER_NONE if the system does not supports the request version. The lgrp_version() function returns the current version of the library when you call the function with LGRP_VER_NONE as the value of the VERSION argument. This code fragment tests whether the version of the interface used by the caller is supported:

lgrp_version(LGRP_VER_CURRENT) == LGRP_VER_CURRENT or
             die("Built with unsupported lgroup interface");

See the man page for the lgrp_version(3LGRP) function for more information.

lgrp_affinity_set($idtype, $id, $lgrp, $affinity)

This function sets the affinity that the LWPs you specify with the $idtype and $id arguments have for the given lgroup. You can set the lgroup affinity to LGRP_AFF_STRONG, LGRP_AFF_WEAK, or LGRP_AFF_NONE. When the value of the $idtype argument is P_PID, this function sets the affinity for all the LWPs of the process with the process id specified in the $id argument. The lgrp_affinity_set() function sets the affinity for the LWP of the current process with LWP id $id when the value of the $idtype argument is P_LWPID. You can specify the current LWP or process by assigning the $id argument a value of P_MYID. This function returns 1 upon successful completion. If the lgrp_affinity_set function does not complete successfully, it returns a value of undef and sets $! to indicate the error. See the man page for the lgrp_affinity_set(3LGRP) function for more information.

lgrp_affinity_get($idtype, $id, $lgrp)

This function retrieves the affinity that the LWPs you specify with the $idtype and $id arguments have for the given lgroup. When the value of the $idtype argument is P_PID, this function retrieves the affinity for one of the LWPs in the process. The lgrp_affinity_get() function retrieves the affinity for the LWP of the current process with LWP id $id when the value of the $idtype argument is P_LWPID. You can specify the current LWP or process by assigning the $id argument a value of P_MYID. This function returns 1 upon successful completion. If the lgrp_affinity_get function does not complete successfully, it returns a value of undef and sets $! to indicate the error. See the man page for the lgrp_affinity_get(3LGRP) function for more information.

lgrp_latency_cookie($cookie, $from, $to, [$between=LGRP_LAT_CPU_TO_MEM])()

This function takes a cookie that represents a snapshot of the lgroup hierarchy and returns the latency value between a hardware resource in the $from lgroup to a hardware resource in the $to lgroup. This function returns the latency value within a given lgroup when the values of the $from and $to arguments are identical. Set the value of the optional $between argument to LGRP_LAT_CPU_TO_MEM to specify the hardware resources to measure the latency between. LGRP_LAT_CPU_TO_MEM represents the latency from CPU to memory and is the only valid value for this argument in this release. This function returns 1 upon successful completion. If the lgrp_latency_cookie function does not complete successfully, it returns a value of undef and sets $! to indicate the error. See the man page for the lgrp_latency_cookie(3LGRP) function for more information.

lgrp_latency($from, $to)()

The function is similar to the lgrp_latency_cookie() function, but returns the latency between the given lgroups at the given instant in time. Because the system dynamically reallocates and frees lgroups, this function's results are not always consistent across calls. This function is deprecated. Use the lgrp_latency_cookie() function instead. See the man page for the lgrp_latency(3LGRP) function for more information.

lgrp_resources($cookie, $lgrp, $type)()

This function is only available for version 2 of the API. When you call this function with version 1 of the API, the lgrp_resources() function returns undef or the empty list and sets the value of $! to EINVAL. This function returns the list of lgroups that directly contain the specified type of resources. The resources are represented by a set of lgroups in which each lgroup directly contains CPU and/or memory resources. To specify CPU resources, set the value of the $type argument to LGRP_RSRC_CPU. To specify memory resources, set the value of the $type argument to LGRP_RSRC_MEM. If the lgrp_resources function does not complete successfully, it returns a value of undef or the empty list and sets $! to indicate the error. See the man page for the lgrp_resources(3LGRP) function for more information.

lgrp_lgrps($cookie, [$lgrp])()

This function returns the list of all of the lgroups in a hierarchy, starting from the lgroup specified in the $lgrp argument. This function uses the value returned by the lgrp_root($cookie) function when the $lgrp argument has no value. The lgrp_lgrps() function returns the empty list on failure. This function returns the total number of lgroups in the system when you call it in a scalar context.

lgrp_leaves($cookie, [$lgrp])()

This function returns the list of all leaf lgroups in a hierarchy that starts from the lgroup specified in the $lgrp argument. This function uses the value returned by the lgrp_root($cookie) function when the $lgrp argument has no value. The lgrp_leaves() function returns undef or the empty list on failure. This function returns the total number of leaf lgroups in the system when you call it in a scalar context.

lgrp_isleaf($cookie, $lgrp)()

This function returns True if the lgroup specified by the value of the $lgrp argument is a leaf lgroup. Leaf lgroups have no children. The lgrp_isleaf() function returns False if the specified lgroup is not a leaf lgroup.