xref: /titanic_50/usr/src/uts/sun4/os/lgrpplat.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
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 2005 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*7c478bd9Sstevel@tonic-gate 
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #include <sys/cpuvar.h>
31*7c478bd9Sstevel@tonic-gate #include <sys/lgrp.h>
32*7c478bd9Sstevel@tonic-gate #include <sys/memnode.h>
33*7c478bd9Sstevel@tonic-gate #include <sys/mman.h>
34*7c478bd9Sstevel@tonic-gate #include <sys/param.h>
35*7c478bd9Sstevel@tonic-gate #include <sys/systm.h>
36*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
37*7c478bd9Sstevel@tonic-gate #include <vm/seg_spt.h>
38*7c478bd9Sstevel@tonic-gate #include <vm/seg_vn.h>
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate #include <sys/errno.h>
41*7c478bd9Sstevel@tonic-gate #include <sys/kstat.h>
42*7c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h>
43*7c478bd9Sstevel@tonic-gate #include <sys/memlist.h>
44*7c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h>
45*7c478bd9Sstevel@tonic-gate 
46*7c478bd9Sstevel@tonic-gate /*
47*7c478bd9Sstevel@tonic-gate  * Platform-specific support for lgroups common to sun4 based platforms.
48*7c478bd9Sstevel@tonic-gate  *
49*7c478bd9Sstevel@tonic-gate  * Those sun4 platforms wanting default lgroup behavior build with
50*7c478bd9Sstevel@tonic-gate  * MAX_MEM_NODES = 1.  Those sun4 platforms wanting other than default
51*7c478bd9Sstevel@tonic-gate  * lgroup behavior build with MAX_MEM_NODES > 1 and provide unique
52*7c478bd9Sstevel@tonic-gate  * definitions to replace the #pragma weak interfaces.
53*7c478bd9Sstevel@tonic-gate  */
54*7c478bd9Sstevel@tonic-gate 
55*7c478bd9Sstevel@tonic-gate /*
56*7c478bd9Sstevel@tonic-gate  * For now, there are 0 or 1 memnodes per lgroup on sun4 based platforms,
57*7c478bd9Sstevel@tonic-gate  * plus the root lgroup.
58*7c478bd9Sstevel@tonic-gate  */
59*7c478bd9Sstevel@tonic-gate #define	NLGRP	(MAX_MEM_NODES + 1)
60*7c478bd9Sstevel@tonic-gate 
61*7c478bd9Sstevel@tonic-gate /*
62*7c478bd9Sstevel@tonic-gate  * Allocate lgrp and lgrp stat arrays statically.
63*7c478bd9Sstevel@tonic-gate  */
64*7c478bd9Sstevel@tonic-gate struct lgrp_stats lgrp_stats[NLGRP];
65*7c478bd9Sstevel@tonic-gate 
66*7c478bd9Sstevel@tonic-gate static int nlgrps_alloc;
67*7c478bd9Sstevel@tonic-gate static lgrp_t lgrp_space[NLGRP];
68*7c478bd9Sstevel@tonic-gate 
69*7c478bd9Sstevel@tonic-gate /*
70*7c478bd9Sstevel@tonic-gate  * Arrays mapping lgroup handles to memnodes and vice versa.  This helps
71*7c478bd9Sstevel@tonic-gate  * manage a copy-rename operation during DR, which moves memory from one
72*7c478bd9Sstevel@tonic-gate  * board to another without changing addresses/pfns or memnodes.
73*7c478bd9Sstevel@tonic-gate  */
74*7c478bd9Sstevel@tonic-gate int lgrphand_to_memnode[MAX_MEM_NODES];
75*7c478bd9Sstevel@tonic-gate int memnode_to_lgrphand[MAX_MEM_NODES];
76*7c478bd9Sstevel@tonic-gate 
77*7c478bd9Sstevel@tonic-gate static pgcnt_t lgrp_plat_mem_size_default(lgrp_handle_t, lgrp_mem_query_t);
78*7c478bd9Sstevel@tonic-gate int plat_lgrphand_to_mem_node(lgrp_handle_t);
79*7c478bd9Sstevel@tonic-gate lgrp_handle_t plat_mem_node_to_lgrphand(int);
80*7c478bd9Sstevel@tonic-gate void plat_assign_lgrphand_to_mem_node(lgrp_handle_t, int);
81*7c478bd9Sstevel@tonic-gate 
82*7c478bd9Sstevel@tonic-gate /*
83*7c478bd9Sstevel@tonic-gate  * Default sun4 lgroup interfaces which should be overriden
84*7c478bd9Sstevel@tonic-gate  * by platform module.
85*7c478bd9Sstevel@tonic-gate  */
86*7c478bd9Sstevel@tonic-gate extern void plat_lgrp_init(void);
87*7c478bd9Sstevel@tonic-gate extern void plat_lgrp_config(lgrp_config_flag_t, uintptr_t);
88*7c478bd9Sstevel@tonic-gate extern lgrp_handle_t plat_lgrp_cpu_to_hand(processorid_t);
89*7c478bd9Sstevel@tonic-gate extern int plat_lgrp_latency(lgrp_handle_t, lgrp_handle_t);
90*7c478bd9Sstevel@tonic-gate extern lgrp_handle_t plat_lgrp_root_hand(void);
91*7c478bd9Sstevel@tonic-gate 
92*7c478bd9Sstevel@tonic-gate #pragma weak plat_lgrp_init
93*7c478bd9Sstevel@tonic-gate #pragma weak plat_lgrp_config
94*7c478bd9Sstevel@tonic-gate #pragma weak plat_lgrp_cpu_to_hand
95*7c478bd9Sstevel@tonic-gate #pragma weak plat_lgrp_latency
96*7c478bd9Sstevel@tonic-gate #pragma weak plat_lgrp_root_hand
97*7c478bd9Sstevel@tonic-gate 
98*7c478bd9Sstevel@tonic-gate int mpo_disabled = 0;
99*7c478bd9Sstevel@tonic-gate lgrp_handle_t lgrp_default_handle = LGRP_DEFAULT_HANDLE;
100*7c478bd9Sstevel@tonic-gate 
101*7c478bd9Sstevel@tonic-gate void
102*7c478bd9Sstevel@tonic-gate lgrp_plat_init(void)
103*7c478bd9Sstevel@tonic-gate {
104*7c478bd9Sstevel@tonic-gate 	int i;
105*7c478bd9Sstevel@tonic-gate 
106*7c478bd9Sstevel@tonic-gate 	/*
107*7c478bd9Sstevel@tonic-gate 	 * Initialize lookup tables to invalid values so we catch
108*7c478bd9Sstevel@tonic-gate 	 * any illegal use of them.
109*7c478bd9Sstevel@tonic-gate 	 */
110*7c478bd9Sstevel@tonic-gate 	for (i = 0; i < MAX_MEM_NODES; i++) {
111*7c478bd9Sstevel@tonic-gate 		memnode_to_lgrphand[i] = -1;
112*7c478bd9Sstevel@tonic-gate 		lgrphand_to_memnode[i] = -1;
113*7c478bd9Sstevel@tonic-gate 	}
114*7c478bd9Sstevel@tonic-gate 
115*7c478bd9Sstevel@tonic-gate 	if (lgrp_topo_ht_limit() == 1) {
116*7c478bd9Sstevel@tonic-gate 		max_mem_nodes = 1;
117*7c478bd9Sstevel@tonic-gate 		return;
118*7c478bd9Sstevel@tonic-gate 	}
119*7c478bd9Sstevel@tonic-gate 
120*7c478bd9Sstevel@tonic-gate 	if (&plat_lgrp_cpu_to_hand)
121*7c478bd9Sstevel@tonic-gate 		max_mem_nodes = MAX_MEM_NODES;
122*7c478bd9Sstevel@tonic-gate 
123*7c478bd9Sstevel@tonic-gate 	if (&plat_lgrp_init)
124*7c478bd9Sstevel@tonic-gate 		plat_lgrp_init();
125*7c478bd9Sstevel@tonic-gate }
126*7c478bd9Sstevel@tonic-gate 
127*7c478bd9Sstevel@tonic-gate void
128*7c478bd9Sstevel@tonic-gate lgrp_plat_main_init(void)
129*7c478bd9Sstevel@tonic-gate {
130*7c478bd9Sstevel@tonic-gate }
131*7c478bd9Sstevel@tonic-gate 
132*7c478bd9Sstevel@tonic-gate /* ARGSUSED */
133*7c478bd9Sstevel@tonic-gate void
134*7c478bd9Sstevel@tonic-gate lgrp_plat_config(lgrp_config_flag_t flag, uintptr_t arg)
135*7c478bd9Sstevel@tonic-gate {
136*7c478bd9Sstevel@tonic-gate 	if (max_mem_nodes == 1)
137*7c478bd9Sstevel@tonic-gate 		return;
138*7c478bd9Sstevel@tonic-gate 
139*7c478bd9Sstevel@tonic-gate 	if (&plat_lgrp_config) {
140*7c478bd9Sstevel@tonic-gate 		plat_lgrp_config(flag, arg);
141*7c478bd9Sstevel@tonic-gate 	}
142*7c478bd9Sstevel@tonic-gate }
143*7c478bd9Sstevel@tonic-gate 
144*7c478bd9Sstevel@tonic-gate lgrp_handle_t
145*7c478bd9Sstevel@tonic-gate lgrp_plat_cpu_to_hand(processorid_t id)
146*7c478bd9Sstevel@tonic-gate {
147*7c478bd9Sstevel@tonic-gate 	if (lgrp_topo_ht_limit() > 1 && &plat_lgrp_cpu_to_hand)
148*7c478bd9Sstevel@tonic-gate 		return (plat_lgrp_cpu_to_hand(id));
149*7c478bd9Sstevel@tonic-gate 	else
150*7c478bd9Sstevel@tonic-gate 		return (LGRP_DEFAULT_HANDLE);
151*7c478bd9Sstevel@tonic-gate }
152*7c478bd9Sstevel@tonic-gate 
153*7c478bd9Sstevel@tonic-gate /*
154*7c478bd9Sstevel@tonic-gate  * Lgroup interfaces common to all sun4 platforms.
155*7c478bd9Sstevel@tonic-gate  */
156*7c478bd9Sstevel@tonic-gate 
157*7c478bd9Sstevel@tonic-gate /*
158*7c478bd9Sstevel@tonic-gate  * Return the platform handle of the lgroup that contains the physical memory
159*7c478bd9Sstevel@tonic-gate  * corresponding to the given page frame number
160*7c478bd9Sstevel@tonic-gate  */
161*7c478bd9Sstevel@tonic-gate lgrp_handle_t
162*7c478bd9Sstevel@tonic-gate lgrp_plat_pfn_to_hand(pfn_t pfn)
163*7c478bd9Sstevel@tonic-gate {
164*7c478bd9Sstevel@tonic-gate 	int	mnode;
165*7c478bd9Sstevel@tonic-gate 
166*7c478bd9Sstevel@tonic-gate 	if (lgrp_topo_ht_limit() == 1 || max_mem_nodes == 1)
167*7c478bd9Sstevel@tonic-gate 		return (LGRP_DEFAULT_HANDLE);
168*7c478bd9Sstevel@tonic-gate 
169*7c478bd9Sstevel@tonic-gate 	if (pfn > physmax)
170*7c478bd9Sstevel@tonic-gate 		return (LGRP_NULL_HANDLE);
171*7c478bd9Sstevel@tonic-gate 
172*7c478bd9Sstevel@tonic-gate 	mnode = PFN_2_MEM_NODE(pfn);
173*7c478bd9Sstevel@tonic-gate 	return (MEM_NODE_2_LGRPHAND(mnode));
174*7c478bd9Sstevel@tonic-gate }
175*7c478bd9Sstevel@tonic-gate 
176*7c478bd9Sstevel@tonic-gate /*
177*7c478bd9Sstevel@tonic-gate  * Return the maximum number of supported lgroups
178*7c478bd9Sstevel@tonic-gate  */
179*7c478bd9Sstevel@tonic-gate int
180*7c478bd9Sstevel@tonic-gate lgrp_plat_max_lgrps(void)
181*7c478bd9Sstevel@tonic-gate {
182*7c478bd9Sstevel@tonic-gate 	return (NLGRP);
183*7c478bd9Sstevel@tonic-gate }
184*7c478bd9Sstevel@tonic-gate 
185*7c478bd9Sstevel@tonic-gate /*
186*7c478bd9Sstevel@tonic-gate  * Return the number of free pages in an lgroup.
187*7c478bd9Sstevel@tonic-gate  *
188*7c478bd9Sstevel@tonic-gate  * For query of LGRP_MEM_SIZE_FREE, return the number of base pagesize
189*7c478bd9Sstevel@tonic-gate  * pages on freelists.  For query of LGRP_MEM_SIZE_AVAIL, return the
190*7c478bd9Sstevel@tonic-gate  * number of allocatable base pagesize pages corresponding to the
191*7c478bd9Sstevel@tonic-gate  * lgroup (e.g. do not include page_t's, BOP_ALLOC()'ed memory, ..)
192*7c478bd9Sstevel@tonic-gate  * For query of LGRP_MEM_SIZE_INSTALL, return the amount of physical
193*7c478bd9Sstevel@tonic-gate  * memory installed, regardless of whether or not it's usable.
194*7c478bd9Sstevel@tonic-gate  */
195*7c478bd9Sstevel@tonic-gate pgcnt_t
196*7c478bd9Sstevel@tonic-gate lgrp_plat_mem_size(lgrp_handle_t plathand, lgrp_mem_query_t query)
197*7c478bd9Sstevel@tonic-gate {
198*7c478bd9Sstevel@tonic-gate 	int	mnode;
199*7c478bd9Sstevel@tonic-gate 	pgcnt_t	npgs = (pgcnt_t)0;
200*7c478bd9Sstevel@tonic-gate 	extern struct memlist *phys_avail;
201*7c478bd9Sstevel@tonic-gate 	extern struct memlist *phys_install;
202*7c478bd9Sstevel@tonic-gate 
203*7c478bd9Sstevel@tonic-gate 
204*7c478bd9Sstevel@tonic-gate 	if (lgrp_topo_ht_limit() == 1 || max_mem_nodes == 1 || mpo_disabled ||
205*7c478bd9Sstevel@tonic-gate 	    plathand == LGRP_DEFAULT_HANDLE)
206*7c478bd9Sstevel@tonic-gate 		return (lgrp_plat_mem_size_default(plathand, query));
207*7c478bd9Sstevel@tonic-gate 
208*7c478bd9Sstevel@tonic-gate 	if (plathand != LGRP_NULL_HANDLE) {
209*7c478bd9Sstevel@tonic-gate 		mnode = plat_lgrphand_to_mem_node(plathand);
210*7c478bd9Sstevel@tonic-gate 		if (mnode >= 0 && mem_node_config[mnode].exists) {
211*7c478bd9Sstevel@tonic-gate 			switch (query) {
212*7c478bd9Sstevel@tonic-gate 			case LGRP_MEM_SIZE_FREE:
213*7c478bd9Sstevel@tonic-gate 				npgs = mem_node_config[mnode].cursize;
214*7c478bd9Sstevel@tonic-gate 				break;
215*7c478bd9Sstevel@tonic-gate 			case LGRP_MEM_SIZE_AVAIL:
216*7c478bd9Sstevel@tonic-gate 				npgs = mem_node_memlist_pages(mnode,
217*7c478bd9Sstevel@tonic-gate 				    phys_avail);
218*7c478bd9Sstevel@tonic-gate 				break;
219*7c478bd9Sstevel@tonic-gate 			case LGRP_MEM_SIZE_INSTALL:
220*7c478bd9Sstevel@tonic-gate 				npgs = mem_node_memlist_pages(mnode,
221*7c478bd9Sstevel@tonic-gate 				    phys_install);
222*7c478bd9Sstevel@tonic-gate 				break;
223*7c478bd9Sstevel@tonic-gate 			default:
224*7c478bd9Sstevel@tonic-gate 				break;
225*7c478bd9Sstevel@tonic-gate 			}
226*7c478bd9Sstevel@tonic-gate 		}
227*7c478bd9Sstevel@tonic-gate 	}
228*7c478bd9Sstevel@tonic-gate 	return (npgs);
229*7c478bd9Sstevel@tonic-gate }
230*7c478bd9Sstevel@tonic-gate 
231*7c478bd9Sstevel@tonic-gate /*
232*7c478bd9Sstevel@tonic-gate  * Return latency between "from" and "to" lgroups
233*7c478bd9Sstevel@tonic-gate  * If "from" or "to" is LGRP_NONE, then just return latency within other
234*7c478bd9Sstevel@tonic-gate  * lgroup.  This latency number can only be used for relative comparison
235*7c478bd9Sstevel@tonic-gate  * between lgroups on the running system, cannot be used across platforms,
236*7c478bd9Sstevel@tonic-gate  * and may not reflect the actual latency.  It is platform and implementation
237*7c478bd9Sstevel@tonic-gate  * specific, so platform gets to decide its value.
238*7c478bd9Sstevel@tonic-gate  */
239*7c478bd9Sstevel@tonic-gate int
240*7c478bd9Sstevel@tonic-gate lgrp_plat_latency(lgrp_handle_t from, lgrp_handle_t to)
241*7c478bd9Sstevel@tonic-gate {
242*7c478bd9Sstevel@tonic-gate 	if (lgrp_topo_ht_limit() > 1 && &plat_lgrp_latency)
243*7c478bd9Sstevel@tonic-gate 		return (plat_lgrp_latency(from, to));
244*7c478bd9Sstevel@tonic-gate 	else
245*7c478bd9Sstevel@tonic-gate 		return (0);
246*7c478bd9Sstevel@tonic-gate }
247*7c478bd9Sstevel@tonic-gate 
248*7c478bd9Sstevel@tonic-gate /*
249*7c478bd9Sstevel@tonic-gate  * Return platform handle for root lgroup
250*7c478bd9Sstevel@tonic-gate  */
251*7c478bd9Sstevel@tonic-gate lgrp_handle_t
252*7c478bd9Sstevel@tonic-gate lgrp_plat_root_hand(void)
253*7c478bd9Sstevel@tonic-gate {
254*7c478bd9Sstevel@tonic-gate 	if (&plat_lgrp_root_hand)
255*7c478bd9Sstevel@tonic-gate 		return (plat_lgrp_root_hand());
256*7c478bd9Sstevel@tonic-gate 	else
257*7c478bd9Sstevel@tonic-gate 		return (LGRP_DEFAULT_HANDLE);
258*7c478bd9Sstevel@tonic-gate }
259*7c478bd9Sstevel@tonic-gate 
260*7c478bd9Sstevel@tonic-gate /* Internal interfaces */
261*7c478bd9Sstevel@tonic-gate /*
262*7c478bd9Sstevel@tonic-gate  * Return the number of free, allocatable, or installed
263*7c478bd9Sstevel@tonic-gate  * pages in an lgroup
264*7c478bd9Sstevel@tonic-gate  * This is a copy of the MAX_MEM_NODES == 1 version of the routine
265*7c478bd9Sstevel@tonic-gate  * used when MPO is disabled (i.e. single lgroup)
266*7c478bd9Sstevel@tonic-gate  */
267*7c478bd9Sstevel@tonic-gate /* ARGSUSED */
268*7c478bd9Sstevel@tonic-gate static pgcnt_t
269*7c478bd9Sstevel@tonic-gate lgrp_plat_mem_size_default(lgrp_handle_t lgrphand, lgrp_mem_query_t query)
270*7c478bd9Sstevel@tonic-gate {
271*7c478bd9Sstevel@tonic-gate 	extern struct memlist *phys_install;
272*7c478bd9Sstevel@tonic-gate 	extern struct memlist *phys_avail;
273*7c478bd9Sstevel@tonic-gate 	struct memlist *mlist;
274*7c478bd9Sstevel@tonic-gate 	pgcnt_t npgs = 0;
275*7c478bd9Sstevel@tonic-gate 
276*7c478bd9Sstevel@tonic-gate 	switch (query) {
277*7c478bd9Sstevel@tonic-gate 	case LGRP_MEM_SIZE_FREE:
278*7c478bd9Sstevel@tonic-gate 		return ((pgcnt_t)freemem);
279*7c478bd9Sstevel@tonic-gate 	case LGRP_MEM_SIZE_AVAIL:
280*7c478bd9Sstevel@tonic-gate 		memlist_read_lock();
281*7c478bd9Sstevel@tonic-gate 		for (mlist = phys_avail; mlist; mlist = mlist->next)
282*7c478bd9Sstevel@tonic-gate 			npgs += btop(mlist->size);
283*7c478bd9Sstevel@tonic-gate 		memlist_read_unlock();
284*7c478bd9Sstevel@tonic-gate 		return (npgs);
285*7c478bd9Sstevel@tonic-gate 	case LGRP_MEM_SIZE_INSTALL:
286*7c478bd9Sstevel@tonic-gate 		memlist_read_lock();
287*7c478bd9Sstevel@tonic-gate 		for (mlist = phys_install; mlist; mlist = mlist->next)
288*7c478bd9Sstevel@tonic-gate 			npgs += btop(mlist->size);
289*7c478bd9Sstevel@tonic-gate 		memlist_read_unlock();
290*7c478bd9Sstevel@tonic-gate 		return (npgs);
291*7c478bd9Sstevel@tonic-gate 	default:
292*7c478bd9Sstevel@tonic-gate 		return ((pgcnt_t)0);
293*7c478bd9Sstevel@tonic-gate 	}
294*7c478bd9Sstevel@tonic-gate }
295*7c478bd9Sstevel@tonic-gate 
296*7c478bd9Sstevel@tonic-gate /*
297*7c478bd9Sstevel@tonic-gate  * Return the memnode associated with the specified lgroup handle
298*7c478bd9Sstevel@tonic-gate  */
299*7c478bd9Sstevel@tonic-gate int
300*7c478bd9Sstevel@tonic-gate plat_lgrphand_to_mem_node(lgrp_handle_t plathand)
301*7c478bd9Sstevel@tonic-gate {
302*7c478bd9Sstevel@tonic-gate 	int mnode;
303*7c478bd9Sstevel@tonic-gate 
304*7c478bd9Sstevel@tonic-gate 	if (lgrp_topo_ht_limit() == 1 || mpo_disabled || max_mem_nodes == 1)
305*7c478bd9Sstevel@tonic-gate 		return (-1);
306*7c478bd9Sstevel@tonic-gate 
307*7c478bd9Sstevel@tonic-gate 	/*
308*7c478bd9Sstevel@tonic-gate 	 * We should always receive a valid pointer to a platform
309*7c478bd9Sstevel@tonic-gate 	 * handle, as we can not choose the allocation policy in
310*7c478bd9Sstevel@tonic-gate 	 * this layer.
311*7c478bd9Sstevel@tonic-gate 	 */
312*7c478bd9Sstevel@tonic-gate 	ASSERT((int)plathand >= 0 && (int)plathand < max_mem_nodes);
313*7c478bd9Sstevel@tonic-gate 
314*7c478bd9Sstevel@tonic-gate 	mnode = lgrphand_to_memnode[(int)plathand];
315*7c478bd9Sstevel@tonic-gate 	return (mnode);
316*7c478bd9Sstevel@tonic-gate }
317*7c478bd9Sstevel@tonic-gate 
318*7c478bd9Sstevel@tonic-gate lgrp_handle_t
319*7c478bd9Sstevel@tonic-gate plat_mem_node_to_lgrphand(int mnode)
320*7c478bd9Sstevel@tonic-gate {
321*7c478bd9Sstevel@tonic-gate 	if (lgrp_topo_ht_limit() == 1 || mpo_disabled || max_mem_nodes == 1)
322*7c478bd9Sstevel@tonic-gate 		return (lgrp_default_handle);
323*7c478bd9Sstevel@tonic-gate 
324*7c478bd9Sstevel@tonic-gate 	ASSERT(mnode >= 0 && mnode < max_mem_nodes);
325*7c478bd9Sstevel@tonic-gate 	return (memnode_to_lgrphand[mnode]);
326*7c478bd9Sstevel@tonic-gate }
327*7c478bd9Sstevel@tonic-gate 
328*7c478bd9Sstevel@tonic-gate void
329*7c478bd9Sstevel@tonic-gate plat_assign_lgrphand_to_mem_node(lgrp_handle_t plathand, int mnode)
330*7c478bd9Sstevel@tonic-gate {
331*7c478bd9Sstevel@tonic-gate 	if (lgrp_topo_ht_limit() == 1 || mpo_disabled || max_mem_nodes == 1)
332*7c478bd9Sstevel@tonic-gate 		return;
333*7c478bd9Sstevel@tonic-gate 
334*7c478bd9Sstevel@tonic-gate 	ASSERT(plathand < max_mem_nodes);
335*7c478bd9Sstevel@tonic-gate 	ASSERT(mnode >= 0 && mnode < max_mem_nodes);
336*7c478bd9Sstevel@tonic-gate 
337*7c478bd9Sstevel@tonic-gate 	lgrphand_to_memnode[plathand] = mnode;
338*7c478bd9Sstevel@tonic-gate 	memnode_to_lgrphand[mnode] = plathand;
339*7c478bd9Sstevel@tonic-gate }
340*7c478bd9Sstevel@tonic-gate 
341*7c478bd9Sstevel@tonic-gate lgrp_t *
342*7c478bd9Sstevel@tonic-gate lgrp_plat_alloc(lgrp_id_t lgrpid)
343*7c478bd9Sstevel@tonic-gate {
344*7c478bd9Sstevel@tonic-gate 	lgrp_t *lgrp;
345*7c478bd9Sstevel@tonic-gate 
346*7c478bd9Sstevel@tonic-gate 	lgrp = &lgrp_space[nlgrps_alloc++];
347*7c478bd9Sstevel@tonic-gate 	if (lgrpid >= NLGRP || nlgrps_alloc > NLGRP)
348*7c478bd9Sstevel@tonic-gate 		return (NULL);
349*7c478bd9Sstevel@tonic-gate 	return (lgrp);
350*7c478bd9Sstevel@tonic-gate }
351*7c478bd9Sstevel@tonic-gate 
352*7c478bd9Sstevel@tonic-gate /*
353*7c478bd9Sstevel@tonic-gate  * Do any platform specific preparation and/or building of full lgroup topology
354*7c478bd9Sstevel@tonic-gate  */
355*7c478bd9Sstevel@tonic-gate void
356*7c478bd9Sstevel@tonic-gate lgrp_plat_build_topo(void)
357*7c478bd9Sstevel@tonic-gate {
358*7c478bd9Sstevel@tonic-gate }
359*7c478bd9Sstevel@tonic-gate 
360*7c478bd9Sstevel@tonic-gate /*
361*7c478bd9Sstevel@tonic-gate  * Probe memory in each node from current CPU to determine latency topology
362*7c478bd9Sstevel@tonic-gate  */
363*7c478bd9Sstevel@tonic-gate void
364*7c478bd9Sstevel@tonic-gate lgrp_plat_probe(void)
365*7c478bd9Sstevel@tonic-gate {
366*7c478bd9Sstevel@tonic-gate }
367