xref: /onnv-gate/usr/src/cmd/perl/contrib/Sun/Solaris/Lgrp/pod/Lgrp.pod (revision 2685:80399c17fa47)
1*2685Sakolb#
2*2685Sakolb# CDDL HEADER START
3*2685Sakolb#
4*2685Sakolb# The contents of this file are subject to the terms of the
5*2685Sakolb# Common Development and Distribution License (the "License").
6*2685Sakolb# You may not use this file except in compliance with the License.
7*2685Sakolb#
8*2685Sakolb# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*2685Sakolb# or http://www.opensolaris.org/os/licensing.
10*2685Sakolb# See the License for the specific language governing permissions
11*2685Sakolb# and limitations under the License.
12*2685Sakolb#
13*2685Sakolb# When distributing Covered Code, include this CDDL HEADER in each
14*2685Sakolb# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*2685Sakolb# If applicable, add the following below this CDDL HEADER, with the
16*2685Sakolb# fields enclosed by brackets "[]" replaced with your own identifying
17*2685Sakolb# information: Portions Copyright [yyyy] [name of copyright owner]
18*2685Sakolb#
19*2685Sakolb# CDDL HEADER END
20*2685Sakolb#
21*2685Sakolb
22*2685Sakolb#
23*2685Sakolb# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24*2685Sakolb# Use is subject to license terms.
25*2685Sakolb#
26*2685Sakolb# ident	"%Z%%M%	%I%	%E% SMI"
27*2685Sakolb#
28*2685Sakolb
29*2685Sakolb#
30*2685Sakolb# Sun::Solaris::Lgrp documentation.
31*2685Sakolb#
32*2685Sakolb
33*2685Sakolb=head1 NAME
34*2685Sakolb
35*2685SakolbLgrp - Perl interface to Solaris liblgrp library.
36*2685Sakolb
37*2685Sakolb=head1 SYNOPSIS
38*2685Sakolb
39*2685Sakolb  use Sun::Solaris::Lgrp qw(:ALL);
40*2685Sakolb
41*2685Sakolb  # initialize lgroup interface
42*2685Sakolb  my $cookie = lgrp_init(LGRP_VIEW_OS | LGRP_VIEW_CALLER);
43*2685Sakolb  my $l = Sun::Solaris::Lgrp->new(LGRP_VIEW_OS | LGRP_VIEW_CALLER);
44*2685Sakolb
45*2685Sakolb  my $version = lgrp_version(LGRP_VER_CURRENT | LGRP_VER_NONE);
46*2685Sakolb  $version = $l->version(LGRP_VER_CURRENT | LGRP_VER_NONE);
47*2685Sakolb
48*2685Sakolb  $home = lgrp_home(P_PID, P_MYID);
49*2685Sakolb  $home = l->home(P_PID, P_MYID);
50*2685Sakolb
51*2685Sakolb  lgrp_affinity_set(P_PID, $pid, $lgrp,
52*2685Sakolb	LGRP_AFF_STRONG | LGRP_AFF_WEAK | LGRP_AFF_NONE);
53*2685Sakolb  $l->affinity_set(P_PID, $pid, $lgrp,
54*2685Sakolb	LGRP_AFF_STRONG | LGRP_AFF_WEAK | LGRP_AFF_NONE);
55*2685Sakolb
56*2685Sakolb  my $affinity = lgrp_affinity_get(P_PID, $pid, $lgrp);
57*2685Sakolb  $affinity = $l->affinity_get(P_PID, $pid, $lgrp);
58*2685Sakolb
59*2685Sakolb  my $nlgrps = lgrp_nlgrps($cookie);
60*2685Sakolb  $nlgrps = $l->nlgrps();
61*2685Sakolb
62*2685Sakolb  my $root = lgrp_root($cookie);
63*2685Sakolb  $root = l->root();
64*2685Sakolb
65*2685Sakolb  $latency = lgrp_latency($lgrp1, $lgrp2);
66*2685Sakolb  $latency = $l->latency($lgrp1, $lgrp2);
67*2685Sakolb
68*2685Sakolb  my @children = lgrp_children($cookie, $lgrp);
69*2685Sakolb  @children = l->children($lgrp);
70*2685Sakolb
71*2685Sakolb  my @parents = lgrp_parents($cookie, $lgrp);
72*2685Sakolb  @parents = l->parents($lgrp);
73*2685Sakolb
74*2685Sakolb  my @lgrps = lgrp_lgrps($cookie);
75*2685Sakolb  @lgrps = l->lgrps();
76*2685Sakolb
77*2685Sakolb  @lgrps = lgrp_lgrps($cookie, $lgrp);
78*2685Sakolb  @lgrps = l->lgrps($lgrp);
79*2685Sakolb
80*2685Sakolb  my @leaves = lgrp_leaves($cookie);
81*2685Sakolb  @leaves = l->leaves();
82*2685Sakolb
83*2685Sakolb  my $is_leaf = lgrp_isleaf($cookie, $lgrp);
84*2685Sakolb  $is_leaf = $l->is_leaf($lgrp);
85*2685Sakolb
86*2685Sakolb  my @cpus = lgrp_cpus($cookie, $lgrp,
87*2685Sakolb	LGRP_CONTENT_HIERARCHY | LGRP_CONTENT_DIRECT);
88*2685Sakolb  @cpus = l->cpus($lgrp, LGRP_CONTENT_HIERARCHY | LGRP_CONTENT_DIRECT);
89*2685Sakolb
90*2685Sakolb  my $memsize = lgrp_mem_size($cookie, $lgrp,
91*2685Sakolb	LGRP_MEM_SZ_INSTALLED | LGRP_MEM_SZ_FREE,
92*2685Sakolb	LGRP_CONTENT_HIERARCHY | LGRP_CONTENT_DIRECT);
93*2685Sakolb  $memsize = l->mem_size($lgrp,
94*2685Sakolb	LGRP_MEM_SZ_INSTALLED | LGRP_MEM_SZ_FREE,
95*2685Sakolb	LGRP_CONTENT_HIERARCHY | LGRP_CONTENT_DIRECT);
96*2685Sakolb
97*2685Sakolb  my $is_stale = lgrp_cookie_stale($cookie);
98*2685Sakolb  $stale = l->stale();
99*2685Sakolb
100*2685Sakolb  lgrp_fini($cookie);
101*2685Sakolb
102*2685Sakolb  # The following is available for API version greater than 1:
103*2685Sakolb
104*2685Sakolb  my @lgrps = lgrp_resources($cookie, $lgrp, LGRP_RSRC_CPU);
105*2685Sakolb
106*2685Sakolb  # Get latencies from cookie
107*2685Sakolb  $latency = lgrp_latency_cookie($cookie, $from, $to);
108*2685Sakolb
109*2685Sakolb=head1 DESCRIPTION
110*2685Sakolb
111*2685SakolbThis module provides access to the C<liblgrp(3LIB)> library and to various
112*2685Sakolbconstants and functions defined in C<sys/lgrp_sys.h> header file. It provides
113*2685Sakolbboth the procedural and object interface to the library. The procedural
114*2685Sakolbinterface requires (in most cases) passing a transparent cookie around. The
115*2685Sakolbobject interface hides all the cookie manipulations from the user.
116*2685Sakolb
117*2685SakolbFunctions returning scalar value indicate error by returning B<undef>. The
118*2685Sakolbcaller may examine the B<$!> variable to get the C<errno> value.
119*2685Sakolb
120*2685SakolbFunctions returning list value return the number of elements in the list when
121*2685Sakolbcalled in scalar context. In case of error the empty list is return in the array
122*2685Sakolbcontext and B<undef> is returned in the scalar context.
123*2685Sakolb
124*2685Sakolb=head2 CONSTANTS
125*2685Sakolb
126*2685SakolbThe constants are exported with B<:CONSTANTS> or B<:ALL> tags:
127*2685Sakolb
128*2685Sakolb  use Sun::Solaris::Lgrp ':ALL';
129*2685Sakolb
130*2685Sakolbor
131*2685Sakolb
132*2685Sakolb  use Sun::Solaris::Lgrp ':CONSTANTS';
133*2685Sakolb
134*2685SakolbThe following constants are available for use in Perl programs:
135*2685Sakolb
136*2685Sakolb
137*2685Sakolb  LGRP_NONE
138*2685Sakolb
139*2685Sakolb  LGRP_VER_CURRENT
140*2685Sakolb  LGRP_VER_NONE
141*2685Sakolb
142*2685Sakolb  LGRP_VIEW_CALLER
143*2685Sakolb  LGRP_VIEW_OS
144*2685Sakolb
145*2685Sakolb  LGRP_AFF_NONE
146*2685Sakolb  LGRP_AFF_STRONG
147*2685Sakolb  LGRP_AFF_WEAK
148*2685Sakolb
149*2685Sakolb  LGRP_CONTENT_DIRECT
150*2685Sakolb  LGRP_CONTENT_HIERARCHY
151*2685Sakolb
152*2685Sakolb  LGRP_MEM_SZ_FREE
153*2685Sakolb  LGRP_MEM_SZ_INSTALLED
154*2685Sakolb
155*2685Sakolb  LGRP_RSRC_CPU (1)
156*2685Sakolb  LGRP_RSRC_MEM (1)
157*2685Sakolb  LGRP_CONTENT_ALL (1)
158*2685Sakolb  LGRP_LAT_CPU_TO_MEM(1)
159*2685Sakolb
160*2685Sakolb  P_PID
161*2685Sakolb  P_LWPID
162*2685Sakolb  P_MYID
163*2685Sakolb
164*2685Sakolb(1) Available for versions of the liblgrp(3LIB) API greater than 1.
165*2685Sakolb
166*2685Sakolb=head2 functions
167*2685Sakolb
168*2685SakolbA detailed description of each function follows. Since this module is intended
169*2685Sakolbto provide a Perl interface to the routines in L<liblgrp(3LIB)>, a very short
170*2685Sakolbdescription is given for the corresponding functions in this module and a
171*2685Sakolbreference is given to the complete description in the L<liblgrp(3LIB)> man
172*2685Sakolbpages. Any differences or additional functionality in the Perl module are
173*2685Sakolbhighlighted and fully documented here.
174*2685Sakolb
175*2685Sakolb=over
176*2685Sakolb
177*2685Sakolb=item lgrp_init([LGRP_VIEW_CALLER | LGRP_VIEW_OS])
178*2685Sakolb
179*2685SakolbThe function initializes the lgroup interface and takes a snapshot of the lgroup
180*2685Sakolbhierarchy with the given view. Given the view, L<lgrp_init()> returns a cookie
181*2685Sakolbrepresenting this snapshot of the lgroup hierarchy. This cookie should be used
182*2685Sakolbwith other routines in the lgroup interface needing the lgroup hierarchy. The
183*2685SakolbL<lgrp_fini()> function should be called with the cookie when it is no longer
184*2685Sakolbneeded. Unlike L<lgrp_init (3LGRP)>, C<LGRP_VIEW_OS> is assumed as the default if
185*2685Sakolbno view is provided.
186*2685Sakolb
187*2685SakolbUpon successful completion, L<lgrp_init()> returns a cookie. Otherwise it returns
188*2685SakolbB<undef> and sets B<$!> to indicate the error.
189*2685Sakolb
190*2685SakolbSee L<lgrp_init(3LGRP)> for more information.
191*2685Sakolb
192*2685Sakolb=item lgrp_fini($cookie)
193*2685Sakolb
194*2685SakolbThe function takes a cookie, frees the snapshot of the lgroup hierarchy created
195*2685Sakolbby L<lgrp_init()>, and cleans up anything else set up by L<lgrp_init()>. After
196*2685Sakolbthis function is called, the cookie returned by the lgroup interface might no
197*2685Sakolblonger be valid and should not be used.
198*2685Sakolb
199*2685SakolbUpon successful completion, 1 is returned. Otherwise, B<undef> is returned and
200*2685SakolbB<$!> is set to indicate the error.
201*2685Sakolb
202*2685SakolbSee L<lgrp_fini(3LGRP)> for more information.
203*2685Sakolb
204*2685Sakolb=item lgrp_view($cookie)
205*2685Sakolb
206*2685SakolbThe function takes a cookie representing the snapshot of the lgroup hierarchy
207*2685Sakolband returns the snapshot's view of the lgroup hierarchy.
208*2685Sakolb
209*2685SakolbIf the given view is C<LGRP_VIEW_CALLER>, the snapshot contains only the
210*2685Sakolbresources that are available to the caller (such as those with respect to
211*2685Sakolbprocessor sets).  When the view is C<LGRP_VIEW_OS>, the snapshot contains what
212*2685Sakolbis available to the operating system.
213*2685Sakolb
214*2685SakolbUpon succesful completion, the function returns the view for the snapshot of the
215*2685Sakolblgroup hierarchy represented by the given cookie. Otherwise, B<undef> is
216*2685Sakolbreturned and C<$!> is set.
217*2685Sakolb
218*2685SakolbSee L<lgrp_view(3LGRP)> for more information.
219*2685Sakolb
220*2685Sakolb=item lgrp_home($idtype, $id)
221*2685Sakolb
222*2685SakolbReturns the home lgroup for the given process or thread. The B<$idtype> argument
223*2685Sakolbshould be C<P_PID> to specify a process and the B<$id> argument should be its
224*2685Sakolbprocess id. Otherwise, the B<$idtype> argument should be C<P_LWPID> to specify a
225*2685Sakolbthread and the B<$id> argument should be its LWP id. The value C<P_MYID> can be
226*2685Sakolbused for the id argument to specify the current process or thread.
227*2685Sakolb
228*2685SakolbUpon successful completion, C<lgrp_home()> returns the id of the home lgroup of
229*2685Sakolbthe specified process or thread. Otherwise, B<undef> is returned and B<$!> is
230*2685Sakolbset to indicate the error.
231*2685Sakolb
232*2685SakolbSee L<lgrp_home(3LGRP)> for more information.
233*2685Sakolb
234*2685Sakolb=item lgrp_cookie_stale($cookie)
235*2685Sakolb
236*2685SakolbUpon successful completion, the function returns whether the cookie is
237*2685Sakolbstale. Otherwise, it returns B<undef> and sets B<$!> to indicate the error.
238*2685Sakolb
239*2685SakolbThe L<lgrp_cookie_stale()> function will fail with C<EINVAL> if the cookie is
240*2685Sakolbnot valid.
241*2685Sakolb
242*2685SakolbSee L<lgrp_cookie_stale(3LGRP)> for more information.
243*2685Sakolb
244*2685Sakolb=item lgrp_cpus($cookie, $lgrp, $context)
245*2685Sakolb
246*2685SakolbThe function takes a cookie representing a snapshot of the lgroup hierarchy and
247*2685Sakolbreturns the list of CPUs in the lgroup specified by B<$lgrp>. The B<$context>
248*2685Sakolbargument should be set to one of the following values to specify whether the
249*2685Sakolbdirect contents or everything in this lgroup including its children should be
250*2685Sakolbreturned:
251*2685Sakolb
252*2685Sakolb=over
253*2685Sakolb
254*2685Sakolb=item LGRP_CONTENT_HIERARCHY
255*2685Sakolb
256*2685SakolbEverything within this hierarchy.
257*2685Sakolb
258*2685Sakolb=item LGRP_CONTENT_DIRECT
259*2685Sakolb
260*2685SakolbDirectly contained in lgroup.
261*2685Sakolb
262*2685Sakolb=back
263*2685Sakolb
264*2685SakolbWhen called in scalar context, L<lgrp_cpus()> function returns the number of
265*2685SakolbCPUs, contained in the specified lgroup.
266*2685Sakolb
267*2685SakolbIn case of error B<undef> is returned in scalar context and B<$!> is set to
268*2685Sakolbindicate the error. In list context the empty list is returned and B<$!> is set.
269*2685Sakolb
270*2685SakolbSee L<lgrp_cpus(3LGRP)> for more information.
271*2685Sakolb
272*2685Sakolb=item lgrp_children($cookie, $lgrp)
273*2685Sakolb
274*2685SakolbThe function takes a cookie representing a snapshot of the lgroup hierarchy and
275*2685Sakolbreturns the list of lgroups that are children of the specified lgroup.
276*2685Sakolb
277*2685SakolbWhen called in scalar context, L<lgrp_children()> function returns the number of
278*2685Sakolbchildren lgroups for the specified lgroup.
279*2685Sakolb
280*2685SakolbIn case of error B<undef> or empty list is returned and B<$!> is set to indicate
281*2685Sakolbthe error.
282*2685Sakolb
283*2685SakolbSee L<lgrp_children(3LGRP)> for more information.
284*2685Sakolb
285*2685Sakolb=item lgrp_parents($cookie, $lgrp)
286*2685Sakolb
287*2685SakolbThe function takes a cookie representing a snapshot of the lgroup hierarchy and
288*2685Sakolbreturns the list of parent of the specified lgroup.
289*2685Sakolb
290*2685SakolbWhen called in scalar context, L<lgrp_parents()> function returns the number of
291*2685Sakolbparent lgroups for the specified lgroup.
292*2685Sakolb
293*2685SakolbIn case of error B<undef> or empty list is returned and B<$!> is set to indicate
294*2685Sakolbthe error.
295*2685Sakolb
296*2685SakolbSee L<lgrp_parents(3LGRP)> for more information.
297*2685Sakolb
298*2685Sakolb=item lgrp_nlgrps($cookie)
299*2685Sakolb
300*2685SakolbThe function takes a cookie representing a snapshot of the lgroup hierarchy.  It
301*2685Sakolbreturns the number of lgroups in the hierarchy where the number is always at
302*2685Sakolbleast one.
303*2685Sakolb
304*2685SakolbIn case of error B<undef> is returned and B<$!> is set to EINVAL indicatng that
305*2685Sakolbthe cookie is not valid.
306*2685Sakolb
307*2685SakolbSee L<lgrp_nlgrps(3LGRP)> for more information.
308*2685Sakolb
309*2685Sakolb=item lgrp_root($cookie)
310*2685Sakolb
311*2685SakolbThe function returns the root lgroup ID.  In case of error B<undef> is returned
312*2685Sakolband B<$!> is set to EINVAL indicatng that the cookie is not valid.
313*2685Sakolb
314*2685SakolbSee L<lgrp_root(3LGRP)> for more information.
315*2685Sakolb
316*2685Sakolb=item lgrp_mem_size($cookie, $lgrp, $type, $content)
317*2685Sakolb
318*2685SakolbThe function takes a cookie representing a snapshot of the lgroup hierarchy. The
319*2685Sakolbfunction returns the memory size of the given lgroup in bytes. The B<$type>
320*2685Sakolbargument should be set to one of the following values:
321*2685Sakolb
322*2685Sakolb=over
323*2685Sakolb
324*2685Sakolb=item LGRP_MEM_SZ_FREE
325*2685Sakolb
326*2685SakolbFree memory.
327*2685Sakolb
328*2685Sakolb=item LGRP_MEM_SZ_INSTALLED
329*2685Sakolb
330*2685SakolbInstalled memory.
331*2685Sakolb
332*2685Sakolb=back
333*2685Sakolb
334*2685SakolbThe B<$content> argument should be set to one of the following values to specify
335*2685Sakolbwhether the direct contents or everything in this lgroup including its children
336*2685Sakolbshould be returned:
337*2685Sakolb
338*2685Sakolb=over
339*2685Sakolb
340*2685Sakolb=item LGRP_CONTENT_HIERARCHY
341*2685Sakolb
342*2685SakolbEverything within this hierarchy.
343*2685Sakolb
344*2685Sakolb=item LGRP_CONTENT_DIRECT
345*2685Sakolb
346*2685SakolbDirectly contained in lgroup.
347*2685Sakolb
348*2685Sakolb=back
349*2685Sakolb
350*2685SakolbThe total sizes include all the memory in the lgroup including its children,
351*2685Sakolbwhile the others reflect only the memory contained directly in the given lgroup.
352*2685Sakolb
353*2685SakolbUpon successful completion, the size in bytes is returned. Otherwise, B<undef>
354*2685Sakolbis returned and B<$!> is set to indicate the error.
355*2685Sakolb
356*2685SakolbSee L<lgrp_mem_size(3LGRP)> for more information.
357*2685Sakolb
358*2685Sakolb=item lgrp_version([$version])
359*2685Sakolb
360*2685SakolbThe function takes an interface version number, B$version>, as an argument and
361*2685Sakolbreturns an lgroup interface version. The B<$version> argument should be the
362*2685Sakolbvalue of C<LGRP_VER_CURRENT> or C<LGRP_VER_NONE> to find out the current lgroup
363*2685Sakolbinterface version on the running system.
364*2685Sakolb
365*2685SakolbIf B<$version> is still supported by the implementation, then L<lgrp_version()>
366*2685Sakolbreturns the requested version. If C<LGRP_VER_NONE> is returned, the
367*2685Sakolbimplementation cannot support the requested version.
368*2685Sakolb
369*2685SakolbIf B<$version> is C<LGRP_VER_NONE>, L<lgrp_version()> returns the current version of
370*2685Sakolbthe library.
371*2685Sakolb
372*2685SakolbThe following example  tests  whether  the  version  of  the
373*2685Sakolbinterface used by the caller is supported:
374*2685Sakolb
375*2685Sakolb    lgrp_version(LGRP_VER_CURRENT) == LGRP_VER_CURRENT or
376*2685Sakolb    	die("Built with unsupported lgroup interface");
377*2685Sakolb
378*2685SakolbSee L<lgrp_version(3LGRP)> for more information.
379*2685Sakolb
380*2685Sakolb=item lgrp_affinity_set($idtype, $id, $lgrp, $affinity)
381*2685Sakolb
382*2685SakolbThe function sets of LWPs specified by the B<$idtype> and B<$id> arguments have
383*2685Sakolbfor the given lgroup.
384*2685Sakolb
385*2685SakolbThe function sets the affinity that the LWP or set of LWPs specified by $idtype
386*2685Sakolband $id have for the given lgroup. The lgroup affinity can be set to
387*2685SakolbC<LGRP_AFF_STRONG>, C<LGRP_AFF_WEAK>, or C<LGRP_AFF_NONE>.
388*2685Sakolb
389*2685SakolbIf the B<$idtype> is C<P_PID>, the affinity is retrieved for one of the LWPs in
390*2685Sakolbthe process or set for all the LWPs of the process with process id (PID) B<$id>.
391*2685SakolbThe affinity is retrieved or set for the LWP of the current process with LWP id
392*2685Sakolb$id if idtype is C<P_LWPID>. If $id is C<P_MYID>, then the current LWP or
393*2685Sakolbprocess is specified.
394*2685Sakolb
395*2685SakolbThere are different levels of affinity that can be specified by a thread for a
396*2685Sakolbparticuliar lgroup.  The levels of affinity are the following from strongest to
397*2685Sakolbweakest:
398*2685Sakolb
399*2685Sakolb=over
400*2685Sakolb
401*2685Sakolb=item LGRP_AFF_STRONG
402*2685Sakolb
403*2685SakolbStrong affinity.
404*2685Sakolb
405*2685Sakolb=item LGRP_AFF_WEAK
406*2685Sakolb
407*2685SakolbWeak affinity.
408*2685Sakolb
409*2685Sakolb=item LGRP_AFF_NONE
410*2685Sakolb
411*2685SakolbNo affinity.
412*2685Sakolb
413*2685Sakolb=back
414*2685Sakolb
415*2685SakolbUpon successful completion, L<lgrp_affinity_set()> return 1.  Otherwise, it
416*2685Sakolbreturns B<undef> and set B<$!> to indicate the error.
417*2685Sakolb
418*2685SakolbSee L<lgrp_affinity_set(3LGRP)> for more information.
419*2685Sakolb
420*2685Sakolb=item lgrp_affinity_get($idtype, $id, $lgrp)
421*2685Sakolb
422*2685SakolbThe function returns the affinity that the LWP has to a given lgrp. See
423*2685SakolbL<lgrp_affinity_get()> for detailed description.
424*2685Sakolb
425*2685SakolbSee L<lgrp_affinity_get(3LGRP)> for more information.
426*2685Sakolb
427*2685Sakolb=item lgrp_latency_cookie($cookie, $from, $to, [$between=LGRP_LAT_CPU_TO_MEM])
428*2685Sakolb
429*2685SakolbThe function takes a cookie representing a snapshot of the lgroup hierarchy and
430*2685Sakolbreturns the latency value between a hardware resource in the $from lgroup to a
431*2685Sakolbhardware resource in the B<$to> lgroup. If B<$from> is the same lgroup as $to, the
432*2685Sakolblatency value within that lgroup is returned.
433*2685Sakolb
434*2685SakolbThe optional B<between> argument should be set to C<LGRP_LAT_CPU_TO_MEM> to specify
435*2685Sakolbbetween which hardware resources the latency should be measured. Currently the
436*2685Sakolbonly valid value is C<LGRP_LAT_CPU_TO_MEM> which represents latency from CPU to
437*2685Sakolbmemory.
438*2685Sakolb
439*2685SakolbUpon successful completion, lgrp_latency_cookie() return 1. Otherwise, it
440*2685Sakolbreturns B<undef> and set B<$!> to indicate the error. For LGRP API version 1 the
441*2685SakolbL<lgrp_latency_cookie()> is an alias for L<lgrp_latency()>.
442*2685Sakolb
443*2685SakolbSee L<lgrp_latency_cookie(3LGRP)> for more information.
444*2685Sakolb
445*2685Sakolb=item lgrp_latency($from, $to)
446*2685Sakolb
447*2685SakolbThe function is similiar to the L<lgrp_latency_cookie()> function, but returns the
448*2685Sakolblatency between the given lgroups at the given instant in time.  Since lgroups
449*2685Sakolbmay be freed and reallocated, this function may not be able to provide a
450*2685Sakolbconsistent answer across calls.  For that reason, it is recommended that
451*2685SakolbL<lgrp_latency_cookie()> function be used in its place.
452*2685Sakolb
453*2685SakolbSee L<lgrp_latency(3LGRP)> for more information.
454*2685Sakolb
455*2685Sakolb=item lgrp_resources($cookie, $lgrp, $type)
456*2685Sakolb
457*2685SakolbReturn the list of lgroups directly containing resources of the specified type.
458*2685SakolbThe resources are represented by a set of lgroups in which each lgroup directly
459*2685Sakolbcontains CPU and/or memory resources.
460*2685Sakolb
461*2685SakolbThe type can be specified as
462*2685Sakolb
463*2685Sakolb=over
464*2685Sakolb
465*2685Sakolb=item C<LGRP_RSRC_CPU>
466*2685Sakolb
467*2685SakolbCPU resources
468*2685Sakolb
469*2685Sakolb=item C<LGRP_RSRC_MEM>
470*2685Sakolb
471*2685SakolbMemory resources
472*2685Sakolb
473*2685Sakolb=back
474*2685Sakolb
475*2685SakolbIn case of error B<undef> or empty list is returned and B<$!> is set to indicate
476*2685Sakolbthe error.
477*2685Sakolb
478*2685SakolbThis function is only available for API version 2 and will return B<undef> or
479*2685Sakolbempty list for API version 1 and set $! to C<EINVAL>.
480*2685Sakolb
481*2685SakolbSee C<lgrp_resources(3LGRP)> for more information.
482*2685Sakolb
483*2685Sakolb=item lgrp_lgrps($cookie, [$lgrp])
484*2685Sakolb
485*2685SakolbReturns list of all lgroups in a hierarchy starting from $lgrp. If B<$lgrp> is
486*2685Sakolbnot specified, uses the value of lgrp_root($cookie). Returns the empty list on
487*2685Sakolbfailure.
488*2685Sakolb
489*2685SakolbWhen called in scalar context, returns the total number of lgroups in the
490*2685Sakolbsystem.
491*2685Sakolb
492*2685Sakolb=item lgrp_leaves($cookie, [$lgrp])
493*2685Sakolb
494*2685SakolbReturns list of all leaf lgroups in a hierarchy starting from $lgrp. If $lgrp is
495*2685Sakolbnot specified, uses the value of lgrp_root($cookie). Returns B<undef> or empty
496*2685Sakolblist on failure.
497*2685Sakolb
498*2685SakolbWhen called in scalar context, returns the total number of leaf lgroups in the
499*2685Sakolbsystem.
500*2685Sakolb
501*2685Sakolb=item lgrp_isleaf($cookie, $lgrp)
502*2685Sakolb
503*2685SakolbReturns B<True> if $lgrp is leaf (has no children), B<False> otherwise.
504*2685Sakolb
505*2685Sakolb=back
506*2685Sakolb
507*2685Sakolb=head2 Object Methods
508*2685Sakolb
509*2685Sakolb=over
510*2685Sakolb
511*2685Sakolb=item new([$view])
512*2685Sakolb
513*2685SakolbCreates a new Sun::Solaris::Lgrp object. An optional argument is passed to
514*2685SakolbL<lgrp_init()> function. By default uses C<LGRP_VIEW_OS>.
515*2685Sakolb
516*2685Sakolb=item cookie()
517*2685Sakolb
518*2685SakolbReturns a transparent cookie that may be passed to functions accepting cookie.
519*2685Sakolb
520*2685Sakolb=item version([$version])
521*2685Sakolb
522*2685SakolbWithout the argument returns the current version of the L<liblgrp(3LIB)>
523*2685Sakolblibrary. This is a wrapper for L<lgrp_version()> with C<LGRP_VER_NONE> as the
524*2685Sakolbdefault version argument.
525*2685Sakolb
526*2685Sakolb=item stale()
527*2685Sakolb
528*2685SakolbReturns B<T> if the lgroup information in the object is stale, B<F>
529*2685Sakolbotherwise. It is a wrapper for L<lgrp_cookie_stale()>.
530*2685Sakolb
531*2685Sakolb=item view()
532*2685Sakolb
533*2685SakolbReturns the snapshot's view of the lgroup hierarchy. It is a wrapper for
534*2685SakolbL<lgrp_view()>.
535*2685Sakolb
536*2685Sakolb=item root()
537*2685Sakolb
538*2685SakolbReturns the root lgroup. It is a wrapper for L<lgrp_root()>.
539*2685Sakolb
540*2685Sakolb=item children($lgrp)
541*2685Sakolb
542*2685SakolbReturns the list of lgroups that are children of the specified lgroup. This is a
543*2685Sakolbwrapper for L<lgrp_children()>.
544*2685Sakolb
545*2685Sakolb=item parents($lgrp)
546*2685Sakolb
547*2685SakolbReturns the list of lgroups that are parents of the specified lgroup. This is a
548*2685Sakolbwrapper for L<lgrp_parents()>.
549*2685Sakolb
550*2685Sakolb=item nlgrps()
551*2685Sakolb
552*2685SakolbReturns the number of lgroups in the hierarchy. This is a wrapper for
553*2685SakolbL<lgrp_nlgrps()>.
554*2685Sakolb
555*2685Sakolb=item mem_size($lgrp, $type, $content)
556*2685Sakolb
557*2685SakolbReturns the memory size of the given lgroup in bytes. This is a wrapper for
558*2685SakolbL<lgrp_mem_size()>.
559*2685Sakolb
560*2685Sakolb=item cpus($lgrp, $context)
561*2685Sakolb
562*2685SakolbReturns the list of CPUs in the lgroup specified by $lgrp. This is a wrapper for
563*2685SakolbL<lgrp_cpus()>.
564*2685Sakolb
565*2685Sakolb=item resources($lgrp, $type)
566*2685Sakolb
567*2685SakolbReturns the list of lgroups directly containing resources of the specified
568*2685Sakolbtype. This is a wrapper for L<lgrp_resources()>.
569*2685Sakolb
570*2685Sakolb=item home($idtype, $id)
571*2685Sakolb
572*2685SakolbReturns the home lgroup for the given process or thread. This is a wrapper for
573*2685SakolbL<lgrp_home()>.
574*2685Sakolb
575*2685Sakolb=item affinity_get($idtype, $id, $lgrp)
576*2685Sakolb
577*2685SakolbReturns the affinity that the LWP has to a given lgrp. This is a wrapper for
578*2685SakolbL<lgrp_affinity_get()>.
579*2685Sakolb
580*2685Sakolb=item affinity_set($idtype, $id, $lgrp, $affinity)
581*2685Sakolb
582*2685SakolbSets of LWPs specified by the $idtype and $id arguments have for the given lgroup.
583*2685SakolbThis is a wrapper for L<lgrp_affinity_set()>.
584*2685Sakolb
585*2685Sakolb=item lgrps([$lgrp])
586*2685Sakolb
587*2685SakolbReturns list of all lgroups in a hierarchy starting from $lgrp (or the
588*2685SakolbL<lgrp_root()> if $lgrp is not specified). This is a wrapper for L<lgrp_lgrps()>.
589*2685Sakolb
590*2685Sakolb=item leaves([$lgrp])
591*2685Sakolb
592*2685SakolbReturns list of all leaf lgroups in a hierarchy starting from B<$lgrp>. If $lgrp
593*2685Sakolbis not specified, uses the value of lgrp_root(). This is a wrapper for
594*2685SakolbL<lgrp_leaves()>.
595*2685Sakolb
596*2685Sakolb=item isleaf($lgrp)
597*2685Sakolb
598*2685SakolbReturns B<True> if B<$lgrp> is leaf (has no children), B<False> otherwise.
599*2685SakolbThis is a wrapper for L<lgrp_isleaf()>.
600*2685Sakolb
601*2685Sakolb=item latency($from, $to)
602*2685Sakolb
603*2685SakolbReturns the latency value between a hardware resource in the $from lgroup to a
604*2685Sakolbhardware resource in the B<$to> lgroup. It will use L<lgrp_latency()> for
605*2685Sakolbversion 1 of liblgrp(3LIB) and L<lgrp_latency_cookie()> for newer versions.
606*2685Sakolb
607*2685Sakolb=back
608*2685Sakolb
609*2685Sakolb=head2 EXPORTS
610*2685Sakolb
611*2685SakolbBy default nothing is exported from this module. The following tags can be used
612*2685Sakolbto selectively import constants and functions defined in this module:
613*2685Sakolb
614*2685Sakolb=over
615*2685Sakolb
616*2685Sakolb=item :LGRP_CONSTANTS
617*2685Sakolb
618*2685SakolbLGRP_AFF_NONE, LGRP_AFF_STRONG, LGRP_AFF_WEAK, LGRP_CONTENT_DIRECT,
619*2685SakolbLGRP_CONTENT_HIERARCHY, LGRP_MEM_SZ_FREE, LGRP_MEM_SZ_INSTALLED,
620*2685SakolbLGRP_VER_CURRENT, LGRP_VER_NONE, LGRP_VIEW_CALLER, LGRP_VIEW_OS,
621*2685SakolbLGRP_NONE, LGRP_RSRC_CPU, LGRP_RSRC_MEM, LGRP_CONTENT_ALL,
622*2685SakolbLGRP_LAT_CPU_TO_MEM.
623*2685Sakolb
624*2685Sakolb=item :PROC_CONSTANTS
625*2685Sakolb
626*2685SakolbP_PID, P_LWPID P_MYID
627*2685Sakolb
628*2685Sakolb=item :CONSTANTS
629*2685Sakolb
630*2685Sakolb:LGRP_CONSTANTS, :PROC_CONSTANTS
631*2685Sakolb
632*2685Sakolb=item :FUNCTIONS
633*2685Sakolb
634*2685Sakolblgrp_affinity_get(), lgrp_affinity_set(), lgrp_children(), lgrp_cookie_stale(),
635*2685Sakolblgrp_cpus(), lgrp_fini(), lgrp_home(), lgrp_init(), lgrp_latency(),
636*2685Sakolblgrp_latency_cookie(), lgrp_mem_size(), lgrp_nlgrps(), lgrp_parents(),
637*2685Sakolblgrp_root(), lgrp_version(), lgrp_view(), lgrp_resources(),
638*2685Sakolblgrp_lgrps(), lgrp_leaves(), lgrp_isleaf(), lgrp_lgrps(), lgrp_leaves().
639*2685Sakolb
640*2685Sakolb=item :ALL
641*2685Sakolb
642*2685Sakolb:CONSTANTS, :FUNCTIONS
643*2685Sakolb
644*2685Sakolb=back
645*2685Sakolb
646*2685Sakolb=head2 Error values
647*2685Sakolb
648*2685SakolbThe functions in this module return B<undef> or an empty list when an underlying
649*2685Sakolblibrary function fails. The B<$!> is set to provide more information values for
650*2685Sakolbthe error. The following error codes are possible:
651*2685Sakolb
652*2685Sakolb=over
653*2685Sakolb
654*2685Sakolb=item EINVAL
655*2685Sakolb
656*2685SakolbThe value supplied is not valid.
657*2685Sakolb
658*2685Sakolb=item ENOMEM
659*2685Sakolb
660*2685SakolbThere was not enough system memory to complete an operation.
661*2685Sakolb
662*2685Sakolb=item EPERM
663*2685Sakolb
664*2685SakolbThe effective user of the calling process does not have appropriate privileges,
665*2685Sakolband its real or effective user ID does not match the real or effective user ID
666*2685Sakolbof one of the threads.
667*2685Sakolb
668*2685Sakolb=item ESRCH
669*2685Sakolb
670*2685SakolbThe specified  process or thread was not found.
671*2685Sakolb
672*2685Sakolb=back
673*2685Sakolb
674*2685Sakolb=head2 Difference in the API versions
675*2685Sakolb
676*2685SakolbThe C<liblgrp(3LIB)> is versioned. The exact version which was used to compile a
677*2685Sakolbmodule is available through B<lgrp_version> function.
678*2685Sakolb
679*2685SakolbVersion 2 of the lgrpp_user API introduced the following constants and
680*2685Sakolbfunctions, nbot present in version 1:
681*2685Sakolb
682*2685Sakolb=over
683*2685Sakolb
684*2685Sakolb=item C<LGRP_RSRC_CPU> constant
685*2685Sakolb
686*2685Sakolb=item C<LGRP_RSRC_MEM> constant
687*2685Sakolb
688*2685Sakolb=item C<LGRP_CONTENT_ALL> constant
689*2685Sakolb
690*2685Sakolb=item C<LGRP_LAT_CPU_TO_MEM> constant
691*2685Sakolb
692*2685Sakolb=item C<lgrp_resources()> function
693*2685Sakolb
694*2685Sakolb=item C<lgrp_latency_cookie()> function
695*2685Sakolb
696*2685Sakolb=back
697*2685Sakolb
698*2685SakolbThe C<LGRP_RSRC_CPU> and C<LGRP_RSRC_MEM> are not defined for version 1. The
699*2685SakolbL<lgrp_resources()> function is defined for version 1 but always returns empty
700*2685Sakolblist. The L<lgrp_latency_cookie()> function is an alias for lgrp_latency for
701*2685Sakolbversion 1.
702*2685Sakolb
703*2685Sakolb=head1 ATTRIBUTES
704*2685Sakolb
705*2685SakolbSee L<attributes(5)> for descriptions of the following attributes:
706*2685Sakolb
707*2685Sakolb  ___________________________________________________________
708*2685Sakolb |       ATTRIBUTE TYPE        |       ATTRIBUTE VALUE       |
709*2685Sakolb |_____________________________|_____________________________|
710*2685Sakolb | Availability                | SUNWpl5u                    |
711*2685Sakolb |_____________________________|_____________________________|
712*2685Sakolb | Interface Stability         | Unstable                    |
713*2685Sakolb |_____________________________|_____________________________|
714*2685Sakolb
715*2685Sakolb
716*2685Sakolb=head1 SEE ALSO
717*2685Sakolb
718*2685SakolbL<liblgrp(3LIB)>,
719*2685SakolbL<lgrp_affinity_get(3LGRP)>,
720*2685SakolbL<lgrp_affinity_set(3LGRP)>,
721*2685SakolbL<lgrp_children(3LGRP)>,
722*2685SakolbL<lgrp_cookie_stale(3LGRP)>,
723*2685SakolbL<lgrp_cpus(3LGRP)>,
724*2685SakolbL<lgrp_fini(3LGRP)>,
725*2685SakolbL<lgrp_home(3LGRP)>,
726*2685SakolbL<lgrp_init(3LGRP)>,
727*2685SakolbL<lgrp_latency(3LGRP)>,
728*2685SakolbL<lgrp_mem_size(3LGRP)>,
729*2685SakolbL<lgrp_nlgrps(3LGRP)>,
730*2685SakolbL<lgrp_parents(3LGRP)>,
731*2685SakolbL<lgrp_root(3LGRP)>,
732*2685SakolbL<lgrp_version(3LGRP)>,
733*2685SakolbL<lgrp_view(3LGRP)>,
734*2685SakolbL<lgrp_resources(3LGRP)>,
735*2685SakolbL<lgrp_latency_cookie(3LGRP)>,
736*2685SakolbL<attributes(5)>
737*2685Sakolb
738*2685Sakolb=cut
739