xref: /illumos-gate/usr/src/cmd/pools/poold/com/sun/solaris/service/locality/LocalityDomain.java (revision 55fea89dcaa64928bed4327112404dcb3e07b79f)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  *
26*7c478bd9Sstevel@tonic-gate  * ident	"%Z%%M%	%I%	%E% SMI"
27*7c478bd9Sstevel@tonic-gate  *
28*7c478bd9Sstevel@tonic-gate  */
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate package com.sun.solaris.service.locality;
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate import java.util.*;
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate import com.sun.solaris.service.pools.*;
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate /**
37*7c478bd9Sstevel@tonic-gate  * A representation of the Locality Groups for a single Solaris
38*7c478bd9Sstevel@tonic-gate  * instance.
39*7c478bd9Sstevel@tonic-gate  */
40*7c478bd9Sstevel@tonic-gate public class LocalityDomain
41*7c478bd9Sstevel@tonic-gate {
42*7c478bd9Sstevel@tonic-gate 	/**
43*7c478bd9Sstevel@tonic-gate 	 * Obtain a Locality Group snapshot based on the view
44*7c478bd9Sstevel@tonic-gate 	 * available to the caller.
45*7c478bd9Sstevel@tonic-gate 	 */
46*7c478bd9Sstevel@tonic-gate 	public static final int LGRP_VIEW_CALLER = 0;
47*7c478bd9Sstevel@tonic-gate 
48*7c478bd9Sstevel@tonic-gate 	/**
49*7c478bd9Sstevel@tonic-gate 	 * Obtain a Locality Group snapshot based on the view
50*7c478bd9Sstevel@tonic-gate 	 * of the Operating System.
51*7c478bd9Sstevel@tonic-gate 	 */
52*7c478bd9Sstevel@tonic-gate 	public static final int LGRP_VIEW_OS = 1;
53*7c478bd9Sstevel@tonic-gate 
54*7c478bd9Sstevel@tonic-gate         static
55*7c478bd9Sstevel@tonic-gate 	{
56*7c478bd9Sstevel@tonic-gate                 System.loadLibrary("jlgrp");
57*7c478bd9Sstevel@tonic-gate         }
58*7c478bd9Sstevel@tonic-gate 
59*7c478bd9Sstevel@tonic-gate 	/**
60*7c478bd9Sstevel@tonic-gate 	 * The view used to create this LocalityDomain.
61*7c478bd9Sstevel@tonic-gate 	 */
62*7c478bd9Sstevel@tonic-gate 	private int view;
63*7c478bd9Sstevel@tonic-gate 
64*7c478bd9Sstevel@tonic-gate 	/**
65*7c478bd9Sstevel@tonic-gate 	 * The cookie which represents the snapshot of locality
66*7c478bd9Sstevel@tonic-gate 	 * information held by the lgrp library.
67*7c478bd9Sstevel@tonic-gate 	 */
68*7c478bd9Sstevel@tonic-gate 	private long cookie;
69*7c478bd9Sstevel@tonic-gate 
70*7c478bd9Sstevel@tonic-gate 	/**
71*7c478bd9Sstevel@tonic-gate 	 * The root LocalityGroup for the LocalityDomain
72*7c478bd9Sstevel@tonic-gate 	 */
73*7c478bd9Sstevel@tonic-gate 	private LocalityGroup root;
74*7c478bd9Sstevel@tonic-gate 
75*7c478bd9Sstevel@tonic-gate 	/**
76*7c478bd9Sstevel@tonic-gate 	 * Cached value of maxLatency.
77*7c478bd9Sstevel@tonic-gate 	 */
78*7c478bd9Sstevel@tonic-gate 	private final int maxLatency;
79*7c478bd9Sstevel@tonic-gate 
80*7c478bd9Sstevel@tonic-gate 	/**
81*7c478bd9Sstevel@tonic-gate 	 * String representation of often used property.
82*7c478bd9Sstevel@tonic-gate 	 */
83*7c478bd9Sstevel@tonic-gate 	private final static String CPU_SYS_ID = "cpu.sys_id";
84*7c478bd9Sstevel@tonic-gate 
85*7c478bd9Sstevel@tonic-gate 	/**
86*7c478bd9Sstevel@tonic-gate 	 * Constructor.
87*7c478bd9Sstevel@tonic-gate 	 *
88*7c478bd9Sstevel@tonic-gate 	 * @param view to use when creating the LocalityDomain.
89*7c478bd9Sstevel@tonic-gate          * @throws Exception if there is a problem initializing the
90*7c478bd9Sstevel@tonic-gate          * lgrp snapshot.
91*7c478bd9Sstevel@tonic-gate 	 */
LocalityDomain(int view)92*7c478bd9Sstevel@tonic-gate 	public LocalityDomain(int view) throws Exception
93*7c478bd9Sstevel@tonic-gate 	{
94*7c478bd9Sstevel@tonic-gate 		this.view = view;
95*7c478bd9Sstevel@tonic-gate 		cookie = jl_init(view);
96*7c478bd9Sstevel@tonic-gate 		root = jl_root();
97*7c478bd9Sstevel@tonic-gate 		/*
98*7c478bd9Sstevel@tonic-gate 		 * The maxLatency calculation is expensive and is used
99*7c478bd9Sstevel@tonic-gate 		 * every time a locality objective is examined. Since
100*7c478bd9Sstevel@tonic-gate 		 * it will never change over the lifetime of a
101*7c478bd9Sstevel@tonic-gate 		 * LocalityDomain, we calculate it once in the
102*7c478bd9Sstevel@tonic-gate 		 * constructor and cache for future use.
103*7c478bd9Sstevel@tonic-gate 		 */
104*7c478bd9Sstevel@tonic-gate 		maxLatency = calcMaxLatency();
105*7c478bd9Sstevel@tonic-gate 	}
106*7c478bd9Sstevel@tonic-gate 
107*7c478bd9Sstevel@tonic-gate         /**
108*7c478bd9Sstevel@tonic-gate          * Reclaim the resource allocated by the C proxy.
109*7c478bd9Sstevel@tonic-gate          *
110*7c478bd9Sstevel@tonic-gate          * @throws Throwable if there is a problem reclaiming the reosurces.
111*7c478bd9Sstevel@tonic-gate          */
finalize()112*7c478bd9Sstevel@tonic-gate         protected void finalize() throws Throwable
113*7c478bd9Sstevel@tonic-gate         {
114*7c478bd9Sstevel@tonic-gate                 try
115*7c478bd9Sstevel@tonic-gate                 {
116*7c478bd9Sstevel@tonic-gate 			close();
117*7c478bd9Sstevel@tonic-gate                 }
118*7c478bd9Sstevel@tonic-gate                 finally
119*7c478bd9Sstevel@tonic-gate                 {
120*7c478bd9Sstevel@tonic-gate                         super.finalize();
121*7c478bd9Sstevel@tonic-gate                 }
122*7c478bd9Sstevel@tonic-gate         }
123*7c478bd9Sstevel@tonic-gate 
124*7c478bd9Sstevel@tonic-gate 	/**
125*7c478bd9Sstevel@tonic-gate 	 * Return the "root" LocalityGroup.
126*7c478bd9Sstevel@tonic-gate 	 */
getRoot()127*7c478bd9Sstevel@tonic-gate 	public LocalityGroup getRoot()
128*7c478bd9Sstevel@tonic-gate 	{
129*7c478bd9Sstevel@tonic-gate 		return (root);
130*7c478bd9Sstevel@tonic-gate 	}
131*7c478bd9Sstevel@tonic-gate 
132*7c478bd9Sstevel@tonic-gate 	/**
133*7c478bd9Sstevel@tonic-gate 	 * Close this LocalityDomain. Resources are reclaimed in the C
134*7c478bd9Sstevel@tonic-gate 	 * proxy and this LocalityDomain should never be used
135*7c478bd9Sstevel@tonic-gate 	 * again. None of the LocalityGroups which are referenced from
136*7c478bd9Sstevel@tonic-gate 	 * this LocalityDomain should be used after this method is
137*7c478bd9Sstevel@tonic-gate 	 * invoked. NB: jl_fini returns a success indicator which is
138*7c478bd9Sstevel@tonic-gate 	 * ignored as we are closing this domain.
139*7c478bd9Sstevel@tonic-gate 	 */
close()140*7c478bd9Sstevel@tonic-gate 	public void close()
141*7c478bd9Sstevel@tonic-gate 	{
142*7c478bd9Sstevel@tonic-gate 		if (cookie != 0) {
143*7c478bd9Sstevel@tonic-gate 			jl_fini();
144*7c478bd9Sstevel@tonic-gate 			cookie = 0;
145*7c478bd9Sstevel@tonic-gate 			root = null;
146*7c478bd9Sstevel@tonic-gate 		}
147*7c478bd9Sstevel@tonic-gate 	}
148*7c478bd9Sstevel@tonic-gate 
149*7c478bd9Sstevel@tonic-gate 	/**
150*7c478bd9Sstevel@tonic-gate 	 * Return a string representation of this instance.
151*7c478bd9Sstevel@tonic-gate 	 */
toString()152*7c478bd9Sstevel@tonic-gate 	public String toString()
153*7c478bd9Sstevel@tonic-gate 	{
154*7c478bd9Sstevel@tonic-gate 		return (root.toString());
155*7c478bd9Sstevel@tonic-gate 	}
156*7c478bd9Sstevel@tonic-gate 
157*7c478bd9Sstevel@tonic-gate 	/**
158*7c478bd9Sstevel@tonic-gate 	 * Return the groups in this domain to which the supplied cpus
159*7c478bd9Sstevel@tonic-gate 	 * belong, excluding the supplied set of groups.
160*7c478bd9Sstevel@tonic-gate 	 *
161*7c478bd9Sstevel@tonic-gate 	 * @param exclude Set of groups to be excluded.
162*7c478bd9Sstevel@tonic-gate 	 * @param cpus List of cpus
163*7c478bd9Sstevel@tonic-gate 	 *
164*7c478bd9Sstevel@tonic-gate 	 * @throws PoolsException if there is an error accessing the
165*7c478bd9Sstevel@tonic-gate 	 * cpu details.
166*7c478bd9Sstevel@tonic-gate 	 */
foreignGroups(Set exclude, List cpus)167*7c478bd9Sstevel@tonic-gate 	public Set foreignGroups(Set exclude, List cpus) throws PoolsException
168*7c478bd9Sstevel@tonic-gate 	{
169*7c478bd9Sstevel@tonic-gate 		Iterator cpuIt = cpus.iterator();
170*7c478bd9Sstevel@tonic-gate 		Set result = new HashSet();
171*7c478bd9Sstevel@tonic-gate 		while (cpuIt.hasNext()) {
172*7c478bd9Sstevel@tonic-gate 			Component comp = (Component) cpuIt.next();
173*7c478bd9Sstevel@tonic-gate 			int id = (int) comp.getLongProperty(CPU_SYS_ID);
174*7c478bd9Sstevel@tonic-gate 			LocalityGroup group = getGroup(id);
175*7c478bd9Sstevel@tonic-gate 			if (group != null && exclude.contains(group) == false)
176*7c478bd9Sstevel@tonic-gate 				result.add(group);
177*7c478bd9Sstevel@tonic-gate 		}
178*7c478bd9Sstevel@tonic-gate 		return (result);
179*7c478bd9Sstevel@tonic-gate 	}
180*7c478bd9Sstevel@tonic-gate 
181*7c478bd9Sstevel@tonic-gate 	/**
182*7c478bd9Sstevel@tonic-gate 	 * Return the locality group which contains the majority of
183*7c478bd9Sstevel@tonic-gate 	 * the cpus in the supplied list. If more than one group
184*7c478bd9Sstevel@tonic-gate 	 * satisfies this criteria, then the choice of group is
185*7c478bd9Sstevel@tonic-gate 	 * deterministic but unspecified.
186*7c478bd9Sstevel@tonic-gate 	 *
187*7c478bd9Sstevel@tonic-gate 	 * @param cpus List of cpus to be examined.
188*7c478bd9Sstevel@tonic-gate 	 *
189*7c478bd9Sstevel@tonic-gate 	 * @throws PoolsException if there is an error accessing the
190*7c478bd9Sstevel@tonic-gate 	 * cpu details.
191*7c478bd9Sstevel@tonic-gate 	 */
getRepresentativeGroup(List cpus)192*7c478bd9Sstevel@tonic-gate 	public LocalityGroup getRepresentativeGroup(List cpus)
193*7c478bd9Sstevel@tonic-gate 	    throws PoolsException
194*7c478bd9Sstevel@tonic-gate 	{
195*7c478bd9Sstevel@tonic-gate 		Iterator cpuIt = cpus.iterator();
196*7c478bd9Sstevel@tonic-gate 		Map grps = new HashMap();
197*7c478bd9Sstevel@tonic-gate 		while (cpuIt.hasNext()) {
198*7c478bd9Sstevel@tonic-gate 			Component comp = (Component) cpuIt.next();
199*7c478bd9Sstevel@tonic-gate 			int id = (int) comp.getLongProperty(CPU_SYS_ID);
200*7c478bd9Sstevel@tonic-gate 			LocalityGroup group = getGroup(id);
201*7c478bd9Sstevel@tonic-gate 			Integer score = (Integer) grps.get(group);
202*7c478bd9Sstevel@tonic-gate 			if (score != null) {
203*7c478bd9Sstevel@tonic-gate 				int iscore = score.intValue() + 1;
204*7c478bd9Sstevel@tonic-gate 				grps.put(group, new Integer(iscore));
205*7c478bd9Sstevel@tonic-gate 			} else {
206*7c478bd9Sstevel@tonic-gate 				grps.put(group, new Integer(1));
207*7c478bd9Sstevel@tonic-gate 			}
208*7c478bd9Sstevel@tonic-gate 		}
209*7c478bd9Sstevel@tonic-gate 		Iterator groupIt = grps.keySet().iterator();
210*7c478bd9Sstevel@tonic-gate 		LocalityGroup centre = null;
211*7c478bd9Sstevel@tonic-gate 		Integer highest = new Integer(0);
212*7c478bd9Sstevel@tonic-gate 		while (groupIt.hasNext()) {
213*7c478bd9Sstevel@tonic-gate 			LocalityGroup cand = (LocalityGroup) groupIt.next();
214*7c478bd9Sstevel@tonic-gate 			Integer value = (Integer) grps.get(cand);
215*7c478bd9Sstevel@tonic-gate 			if (value.intValue() > highest.intValue()) {
216*7c478bd9Sstevel@tonic-gate 				highest = value;
217*7c478bd9Sstevel@tonic-gate 				centre = cand;
218*7c478bd9Sstevel@tonic-gate 			}
219*7c478bd9Sstevel@tonic-gate 		}
220*7c478bd9Sstevel@tonic-gate 		return (centre);
221*7c478bd9Sstevel@tonic-gate 	}
222*7c478bd9Sstevel@tonic-gate 
223*7c478bd9Sstevel@tonic-gate 	/**
224*7c478bd9Sstevel@tonic-gate 	 * Return the maximum latency between the groups in this
225*7c478bd9Sstevel@tonic-gate 	 * domain.
226*7c478bd9Sstevel@tonic-gate 	 *
227*7c478bd9Sstevel@tonic-gate 	 */
calcMaxLatency()228*7c478bd9Sstevel@tonic-gate 	private int calcMaxLatency()
229*7c478bd9Sstevel@tonic-gate 	{
230*7c478bd9Sstevel@tonic-gate 		int max = 0;
231*7c478bd9Sstevel@tonic-gate 
232*7c478bd9Sstevel@tonic-gate 		Set groups = getGroups();
233*7c478bd9Sstevel@tonic-gate 		Iterator outer = groups.iterator();
234*7c478bd9Sstevel@tonic-gate 		while (outer.hasNext()) {
235*7c478bd9Sstevel@tonic-gate 			Iterator inner = groups.iterator();
236*7c478bd9Sstevel@tonic-gate 			LocalityGroup g1 = (LocalityGroup) outer.next();
237*7c478bd9Sstevel@tonic-gate 			while (inner.hasNext()) {
238*7c478bd9Sstevel@tonic-gate 				LocalityGroup g2 = (LocalityGroup) inner.next();
239*7c478bd9Sstevel@tonic-gate 				int latency = g1.getLatency(g2);
240*7c478bd9Sstevel@tonic-gate 				if (latency > max)
241*7c478bd9Sstevel@tonic-gate 					max = latency;
242*7c478bd9Sstevel@tonic-gate 			}
243*7c478bd9Sstevel@tonic-gate 		}
244*7c478bd9Sstevel@tonic-gate 		return (max);
245*7c478bd9Sstevel@tonic-gate 	}
246*7c478bd9Sstevel@tonic-gate 
247*7c478bd9Sstevel@tonic-gate 	/**
248*7c478bd9Sstevel@tonic-gate 	 * Return the maximum possible latency between all locality
249*7c478bd9Sstevel@tonic-gate 	 * groups in this domain.
250*7c478bd9Sstevel@tonic-gate 	 */
getMaxLatency()251*7c478bd9Sstevel@tonic-gate 	public int getMaxLatency()
252*7c478bd9Sstevel@tonic-gate 	{
253*7c478bd9Sstevel@tonic-gate 		return (maxLatency);
254*7c478bd9Sstevel@tonic-gate 	}
255*7c478bd9Sstevel@tonic-gate 
256*7c478bd9Sstevel@tonic-gate 	/**
257*7c478bd9Sstevel@tonic-gate 	 * Return the set of all LocalityGroups for this LocalityDomain.
258*7c478bd9Sstevel@tonic-gate 	 */
getGroups()259*7c478bd9Sstevel@tonic-gate 	public Set getGroups()
260*7c478bd9Sstevel@tonic-gate 	{
261*7c478bd9Sstevel@tonic-gate 		Set groups = new HashSet();
262*7c478bd9Sstevel@tonic-gate 		groups.add(root);
263*7c478bd9Sstevel@tonic-gate 		getGroups(root, groups);
264*7c478bd9Sstevel@tonic-gate 		return (groups);
265*7c478bd9Sstevel@tonic-gate 	}
266*7c478bd9Sstevel@tonic-gate 
267*7c478bd9Sstevel@tonic-gate 	/**
268*7c478bd9Sstevel@tonic-gate 	 * Add all the descendent LocalityGroups for the supplied
269*7c478bd9Sstevel@tonic-gate 	 * group into the supplied set.
270*7c478bd9Sstevel@tonic-gate 	 *
271*7c478bd9Sstevel@tonic-gate 	 * @param group is the group whose descendents are processed.
272*7c478bd9Sstevel@tonic-gate 	 * @param descendents the set to add descendents of group.
273*7c478bd9Sstevel@tonic-gate 	 */
getGroups(LocalityGroup group, Set descendents)274*7c478bd9Sstevel@tonic-gate 	private void getGroups(LocalityGroup group, Set descendents)
275*7c478bd9Sstevel@tonic-gate 	{
276*7c478bd9Sstevel@tonic-gate 		Set children = group.getChildren();
277*7c478bd9Sstevel@tonic-gate 
278*7c478bd9Sstevel@tonic-gate 		if (! children.isEmpty()) {
279*7c478bd9Sstevel@tonic-gate 			Iterator itChild = children.iterator();
280*7c478bd9Sstevel@tonic-gate 			while (itChild.hasNext()) {
281*7c478bd9Sstevel@tonic-gate 				LocalityGroup child = (LocalityGroup) itChild.
282*7c478bd9Sstevel@tonic-gate 				    next();
283*7c478bd9Sstevel@tonic-gate 				getGroups(child, descendents);
284*7c478bd9Sstevel@tonic-gate 			}
285*7c478bd9Sstevel@tonic-gate 			descendents.addAll(children);
286*7c478bd9Sstevel@tonic-gate 		}
287*7c478bd9Sstevel@tonic-gate 	}
288*7c478bd9Sstevel@tonic-gate 
289*7c478bd9Sstevel@tonic-gate 	/**
290*7c478bd9Sstevel@tonic-gate 	 * Return the LocalityGroup containing the supplied CPU
291*7c478bd9Sstevel@tonic-gate 	 * id. Search all LocalityGroups starting at the root group.
292*7c478bd9Sstevel@tonic-gate 	 *
293*7c478bd9Sstevel@tonic-gate 	 * @param cpuid is the sys-id of the CPU to search for.
294*7c478bd9Sstevel@tonic-gate 	 */
getGroup(int cpuid)295*7c478bd9Sstevel@tonic-gate 	public LocalityGroup getGroup(int cpuid)
296*7c478bd9Sstevel@tonic-gate 	{
297*7c478bd9Sstevel@tonic-gate 		LocalityGroup answer = getGroup(root, cpuid);
298*7c478bd9Sstevel@tonic-gate 		return (getGroup(root, cpuid));
299*7c478bd9Sstevel@tonic-gate 	}
300*7c478bd9Sstevel@tonic-gate 
301*7c478bd9Sstevel@tonic-gate 	/**
302*7c478bd9Sstevel@tonic-gate 	 * Return the LocalityGroup containing the supplied CPU
303*7c478bd9Sstevel@tonic-gate 	 * id. Search LocalityGroups starting at the supplied group.
304*7c478bd9Sstevel@tonic-gate 	 *
305*7c478bd9Sstevel@tonic-gate 	 * @param group is the group to start searching from.
306*7c478bd9Sstevel@tonic-gate 	 * @param cpuid is the sys-id of the CPU to search for.
307*7c478bd9Sstevel@tonic-gate 	 */
getGroup(LocalityGroup group, int cpuid)308*7c478bd9Sstevel@tonic-gate 	private LocalityGroup getGroup(LocalityGroup group, int cpuid)
309*7c478bd9Sstevel@tonic-gate 	{
310*7c478bd9Sstevel@tonic-gate 		Set children = group.getChildren();
311*7c478bd9Sstevel@tonic-gate 
312*7c478bd9Sstevel@tonic-gate 		if (children.isEmpty()) {
313*7c478bd9Sstevel@tonic-gate 			int cpus[] = group.getCPUIDs();
314*7c478bd9Sstevel@tonic-gate 
315*7c478bd9Sstevel@tonic-gate 
316*7c478bd9Sstevel@tonic-gate 			for (int i = 0; i < cpus.length; i++)
317*7c478bd9Sstevel@tonic-gate 				if (cpus[i] == cpuid) {
318*7c478bd9Sstevel@tonic-gate 					return (group);
319*7c478bd9Sstevel@tonic-gate 				}
320*7c478bd9Sstevel@tonic-gate 		} else {
321*7c478bd9Sstevel@tonic-gate 			Iterator itGroup = children.iterator();
322*7c478bd9Sstevel@tonic-gate 			while (itGroup.hasNext()) {
323*7c478bd9Sstevel@tonic-gate 				LocalityGroup owner;
324*7c478bd9Sstevel@tonic-gate 				LocalityGroup child = (LocalityGroup) itGroup.
325*7c478bd9Sstevel@tonic-gate 				    next();
326*7c478bd9Sstevel@tonic-gate 				if ((owner = getGroup(child, cpuid)) != null)
327*7c478bd9Sstevel@tonic-gate 					return (owner);
328*7c478bd9Sstevel@tonic-gate 			}
329*7c478bd9Sstevel@tonic-gate 		}
330*7c478bd9Sstevel@tonic-gate 		return (null);
331*7c478bd9Sstevel@tonic-gate 	}
332*7c478bd9Sstevel@tonic-gate 
333*7c478bd9Sstevel@tonic-gate 	/**
334*7c478bd9Sstevel@tonic-gate 	 * Initialise the LocalityDomain with an lgrp snapshot.
335*7c478bd9Sstevel@tonic-gate 	 *
336*7c478bd9Sstevel@tonic-gate 	 * @param view is the type of snapshot to obtain.
337*7c478bd9Sstevel@tonic-gate 	 */
jl_init(int view)338*7c478bd9Sstevel@tonic-gate 	private native long jl_init(int view) throws Exception;
339*7c478bd9Sstevel@tonic-gate 
340*7c478bd9Sstevel@tonic-gate 	/**
341*7c478bd9Sstevel@tonic-gate 	 * Release the lgrp snapshot.
342*7c478bd9Sstevel@tonic-gate 	 */
jl_fini()343*7c478bd9Sstevel@tonic-gate 	private native int jl_fini();
344*7c478bd9Sstevel@tonic-gate 
345*7c478bd9Sstevel@tonic-gate 	/**
346*7c478bd9Sstevel@tonic-gate 	 * Find the root LocalityGroup.
347*7c478bd9Sstevel@tonic-gate 	 */
jl_root()348*7c478bd9Sstevel@tonic-gate 	private native LocalityGroup jl_root();
349*7c478bd9Sstevel@tonic-gate 
350*7c478bd9Sstevel@tonic-gate }
351