xref: /titanic_52/usr/src/uts/sun4/vm/vm_dep.h (revision bdfc6d18da790deeec2e0eb09c625902defe2498)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*
28  * UNIX machine dependent virtual memory support.
29  */
30 
31 #ifndef	_VM_DEP_H
32 #define	_VM_DEP_H
33 
34 #pragma ident	"%Z%%M%	%I%	%E% SMI"
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 #include <vm/hat_sfmmu.h>
41 #include <sys/archsystm.h>
42 #include <sys/memnode.h>
43 
44 #define	GETTICK()	gettick()
45 
46 /*
47  * Per page size free lists. Allocated dynamically.
48  */
49 #define	MAX_MEM_TYPES	2	/* 0 = reloc, 1 = noreloc */
50 #define	MTYPE_RELOC	0
51 #define	MTYPE_NORELOC	1
52 
53 #define	PP_2_MTYPE(pp)	(PP_ISNORELOC(pp) ? MTYPE_NORELOC : MTYPE_RELOC)
54 
55 #define	MTYPE_INIT(mtype, vp, vaddr, flags)				\
56 	mtype = (flags & PG_NORELOC) ? MTYPE_NORELOC : MTYPE_RELOC;
57 
58 /* mtype init for page_get_replacement_page */
59 
60 #define	MTYPE_PGR_INIT(mtype, flags, pp, mnode)				\
61 	mtype = (flags & PG_NORELOC) ? MTYPE_NORELOC : MTYPE_RELOC;
62 
63 #define	MNODETYPE_2_PFN(mnode, mtype, pfnlo, pfnhi)			\
64 	ASSERT(mtype != MTYPE_NORELOC);					\
65 	pfnlo = mem_node_config[mnode].physbase;			\
66 	pfnhi = mem_node_config[mnode].physmax;
67 
68 /*
69  * Internal PG_ flags.
70  */
71 #define	PGI_RELOCONLY	0x10000	/* acts in the opposite sense to PG_NORELOC */
72 #define	PGI_NOCAGE	0x20000	/* indicates Cage is disabled */
73 #define	PGI_PGCPHIPRI	0x40000	/* page_get_contig_page priority allocation */
74 #define	PGI_PGCPSZC0	0x80000	/* relocate base pagesize page */
75 
76 /*
77  * PGI mtype flags - should not overlap PGI flags
78  */
79 #define	PGI_MT_RANGE	0x1000000	/* mtype range */
80 #define	PGI_MT_NEXT	0x2000000	/* get next mtype */
81 
82 extern page_t ***page_freelists[MMU_PAGE_SIZES][MAX_MEM_TYPES];
83 extern page_t ***page_cachelists[MAX_MEM_TYPES];
84 
85 #define	PAGE_FREELISTS(mnode, szc, color, mtype) \
86 	(*(page_freelists[szc][mtype][mnode] + (color)))
87 
88 #define	PAGE_CACHELISTS(mnode, color, mtype) \
89 	(*(page_cachelists[mtype][mnode] + (color)))
90 
91 /*
92  * There are 'page_colors' colors/bins.  Spread them out under a
93  * couple of locks.  There are mutexes for both the page freelist
94  * and the page cachelist.  We want enough locks to make contention
95  * reasonable, but not too many -- otherwise page_freelist_lock() gets
96  * so expensive that it becomes the bottleneck!
97  */
98 #define	NPC_MUTEX	16
99 
100 extern kmutex_t	*fpc_mutex[NPC_MUTEX];
101 extern kmutex_t	*cpc_mutex[NPC_MUTEX];
102 
103 /* Find the bin for the given page if it was of size szc */
104 #define	PP_2_BIN_SZC(pp, szc)                                           \
105 	(((pp->p_pagenum) & page_colors_mask) >>                        \
106 	(hw_page_array[szc].hp_shift - hw_page_array[0].hp_shift))
107 
108 #define	PP_2_BIN(pp)		(PP_2_BIN_SZC(pp, pp->p_szc))
109 
110 #define	PP_2_MEM_NODE(pp)	(PFN_2_MEM_NODE(pp->p_pagenum))
111 
112 #define	PC_BIN_MUTEX(mnode, bin, flags) ((flags & PG_FREE_LIST) ?	\
113 	&fpc_mutex[(bin) & (NPC_MUTEX - 1)][mnode] :			\
114 	&cpc_mutex[(bin) & (NPC_MUTEX - 1)][mnode])
115 
116 #define	FPC_MUTEX(mnode, i)	(&fpc_mutex[i][mnode])
117 #define	CPC_MUTEX(mnode, i)	(&cpc_mutex[i][mnode])
118 
119 #define	PFN_BASE(pfnum, szc)	(pfnum & ~((1 << PAGE_BSZS_SHIFT(szc)) - 1))
120 
121 typedef	char	hpmctr_t;
122 
123 #ifdef DEBUG
124 #define	CHK_LPG(pp, szc)	chk_lpg(pp, szc)
125 extern void	chk_lpg(page_t *, uchar_t);
126 #else
127 #define	CHK_LPG(pp, szc)
128 #endif
129 
130 /*
131  * page list count per mnode and type.
132  */
133 typedef	struct {
134 	pgcnt_t	plc_mt_pgmax;		/* max page cnt */
135 	pgcnt_t plc_mt_clpgcnt;		/* cache list cnt */
136 	pgcnt_t plc_mt_flpgcnt;		/* free list cnt - small pages */
137 	pgcnt_t plc_mt_lgpgcnt;		/* free list cnt - large pages */
138 #ifdef DEBUG
139 	struct {
140 		pgcnt_t plc_mts_pgcnt;	/* per page size count */
141 		int	plc_mts_colors;
142 		pgcnt_t	*plc_mtsc_pgcnt; /* per color bin count */
143 	} plc_mts[MMU_PAGE_SIZES];
144 #endif
145 } plcnt_t[MAX_MEM_NODES][MAX_MEM_TYPES];
146 
147 #ifdef DEBUG
148 
149 #define	PLCNT_SZ(ctrs_sz) {						\
150 	int	szc;							\
151 	for (szc = 0; szc <= mmu_page_sizes; szc++) {			\
152 		int	colors = page_get_pagecolors(szc);		\
153 		ctrs_sz += (max_mem_nodes * MAX_MEM_TYPES *		\
154 		    colors * sizeof (pgcnt_t));				\
155 	}								\
156 }
157 
158 #define	PLCNT_INIT(base) {						\
159 	int	mn, mt, szc, colors;					\
160 	for (szc = 0; szc < mmu_page_sizes; szc++) {			\
161 		colors = page_get_pagecolors(szc);			\
162 		for (mn = 0; mn < max_mem_nodes; mn++) {		\
163 			for (mt = 0; mt < MAX_MEM_TYPES; mt++) {	\
164 				plcnt[mn][mt].plc_mts[szc].	\
165 				    plc_mts_colors = colors;		\
166 				plcnt[mn][mt].plc_mts[szc].	\
167 				    plc_mtsc_pgcnt = (pgcnt_t *)base;	\
168 				base += (colors * sizeof (pgcnt_t));	\
169 			}						\
170 		}							\
171 	}								\
172 }
173 
174 #define	PLCNT_DO(pp, mn, mtype, szc, cnt, flags) {			\
175 	int	bin = PP_2_BIN(pp);					\
176 	if (flags & (PG_LIST_ISINIT | PG_LIST_ISCAGE))			\
177 		atomic_add_long(&plcnt[mn][mtype].plc_mt_pgmax,	\
178 		    cnt);						\
179 	if (flags & PG_CACHE_LIST)					\
180 		atomic_add_long(&plcnt[mn][mtype].plc_mt_clpgcnt, cnt);	\
181 	else if (szc)							\
182 		atomic_add_long(&plcnt[mn][mtype].plc_mt_lgpgcnt, cnt);	\
183 	else								\
184 		atomic_add_long(&plcnt[mn][mtype].plc_mt_flpgcnt, cnt);	\
185 	atomic_add_long(&plcnt[mn][mtype].plc_mts[szc].plc_mts_pgcnt,	\
186 	    cnt);							\
187 	atomic_add_long(&plcnt[mn][mtype].plc_mts[szc].			\
188 	    plc_mtsc_pgcnt[bin], cnt);					\
189 }
190 
191 #else
192 
193 #define	PLCNT_SZ(ctrs_sz)
194 
195 #define	PLCNT_INIT(base)
196 
197 /* PG_FREE_LIST may not be explicitly set in flags for large pages */
198 
199 #define	PLCNT_DO(pp, mn, mtype, szc, cnt, flags) {			\
200 	if (flags & (PG_LIST_ISINIT | PG_LIST_ISCAGE))			\
201 		atomic_add_long(&plcnt[mn][mtype].plc_mt_pgmax, cnt);	\
202 	if (flags & PG_CACHE_LIST)					\
203 		atomic_add_long(&plcnt[mn][mtype].plc_mt_clpgcnt, cnt);	\
204 	else if (szc)							\
205 		atomic_add_long(&plcnt[mn][mtype].plc_mt_lgpgcnt, cnt);	\
206 	else								\
207 		atomic_add_long(&plcnt[mn][mtype].plc_mt_flpgcnt, cnt);	\
208 }
209 
210 #endif
211 
212 #define	PLCNT_INCR(pp, mn, mtype, szc, flags) {				\
213 	long	cnt = (1 << PAGE_BSZS_SHIFT(szc));			\
214 	PLCNT_DO(pp, mn, mtype, szc, cnt, flags);			\
215 }
216 
217 #define	PLCNT_DECR(pp, mn, mtype, szc, flags) {				\
218 	long	cnt = ((-1) << PAGE_BSZS_SHIFT(szc));			\
219 	PLCNT_DO(pp, mn, mtype, szc, cnt, flags);			\
220 }
221 
222 /*
223  * macros to update page list max counts - done when pages transferred
224  * between mtypes (as in kcage_assimilate_page).
225  */
226 #define	PLCNT_MAX_INCR(pp, mn, mtype, szc) {				\
227 	long	cnt = (1 << PAGE_BSZS_SHIFT(szc));			\
228 	atomic_add_long(&plcnt[mn][mtype].plc_mt_pgmax, cnt);		\
229 }
230 
231 #define	PLCNT_MAX_DECR(pp, mn, mtype, szc) {				\
232 	long	cnt = ((-1) << PAGE_BSZS_SHIFT(szc));			\
233 	atomic_add_long(&plcnt[mn][mtype].plc_mt_pgmax, cnt);		\
234 }
235 
236 extern plcnt_t	plcnt;
237 
238 #define	MNODE_PGCNT(mn)							\
239 	(plcnt[mn][MTYPE_RELOC].plc_mt_clpgcnt +			\
240 	    plcnt[mn][MTYPE_NORELOC].plc_mt_clpgcnt +			\
241 	    plcnt[mn][MTYPE_RELOC].plc_mt_flpgcnt +			\
242 	    plcnt[mn][MTYPE_NORELOC].plc_mt_flpgcnt +			\
243 	    plcnt[mn][MTYPE_RELOC].plc_mt_lgpgcnt +			\
244 	    plcnt[mn][MTYPE_NORELOC].plc_mt_lgpgcnt)
245 
246 #define	MNODETYPE_PGCNT(mn, mtype)					\
247 	(plcnt[mn][mtype].plc_mt_clpgcnt +				\
248 	    plcnt[mn][mtype].plc_mt_flpgcnt +				\
249 	    plcnt[mn][mtype].plc_mt_lgpgcnt)
250 
251 /*
252  * macros to loop through the mtype range - MTYPE_START returns -1 in
253  * mtype if no pages in mnode/mtype and possibly NEXT mtype.
254  */
255 #define	MTYPE_START(mnode, mtype, flags) {				\
256 	if (plcnt[mnode][mtype].plc_mt_pgmax == 0) {			\
257 		ASSERT(MNODETYPE_PGCNT(mnode, mtype) == 0);		\
258 		MTYPE_NEXT(mnode, mtype, flags);			\
259 	}								\
260 }
261 
262 /*
263  * if allocation from the RELOC pool failed and there is sufficient cage
264  * memory, attempt to allocate from the NORELOC pool.
265  */
266 #define	MTYPE_NEXT(mnode, mtype, flags) { 				\
267 	if (!(flags & (PG_NORELOC | PGI_NOCAGE | PGI_RELOCONLY)) &&	\
268 	    (kcage_freemem >= kcage_lotsfree)) {			\
269 		if (plcnt[mnode][mtype].plc_mt_pgmax == 0) {		\
270 			ASSERT(MNODETYPE_PGCNT(mnode, mtype) == 0);	\
271 			mtype = -1;					\
272 		} else {						\
273 			mtype = MTYPE_NORELOC;				\
274 			flags |= PG_NORELOC;				\
275 		}							\
276 	} else {							\
277 		mtype = -1;						\
278 	}								\
279 }
280 
281 /*
282  * get the ecache setsize for the current cpu.
283  */
284 #define	CPUSETSIZE()	(cpunodes[CPU->cpu_id].ecache_setsize)
285 
286 extern struct cpu	cpu0;
287 #define	CPU0		&cpu0
288 
289 #define	PAGE_BSZS_SHIFT(szc)	TTE_BSZS_SHIFT(szc)
290 /*
291  * For sfmmu each larger page is 8 times the size of the previous
292  * size page.
293  */
294 #define	FULL_REGION_CNT(rg_szc)	(8)
295 
296 /*
297  * The counter base must be per page_counter element to prevent
298  * races when re-indexing, and the base page size element should
299  * be aligned on a boundary of the given region size.
300  *
301  * We also round up the number of pages spanned by the counters
302  * for a given region to PC_BASE_ALIGN in certain situations to simplify
303  * the coding for some non-performance critical routines.
304  */
305 #define	PC_BASE_ALIGN		((pfn_t)1 << PAGE_BSZS_SHIFT(mmu_page_sizes-1))
306 #define	PC_BASE_ALIGN_MASK	(PC_BASE_ALIGN - 1)
307 
308 extern int ecache_alignsize;
309 #define	L2CACHE_ALIGN		ecache_alignsize
310 #define	L2CACHE_ALIGN_MAX	64
311 
312 extern int consistent_coloring;
313 extern uint_t vac_colors_mask;
314 extern int vac_size;
315 extern int vac_shift;
316 
317 /*
318  * Auto large page selection support variables. Some CPU
319  * implementations may differ from the defaults and will need
320  * to change these.
321  */
322 extern int auto_lpg_tlb_threshold;
323 extern int auto_lpg_minszc;
324 extern int auto_lpg_maxszc;
325 extern size_t auto_lpg_heap_default;
326 extern size_t auto_lpg_stack_default;
327 extern size_t auto_lpg_va_default;
328 extern size_t auto_lpg_remap_threshold;
329 
330 /*
331  * AS_2_BIN macro controls the page coloring policy.
332  * 0 (default) uses various vaddr bits
333  * 1 virtual=paddr
334  * 2 bin hopping
335  */
336 #define	AS_2_BIN(as, seg, vp, addr, bin)				\
337 switch (consistent_coloring) {						\
338 	default:                                                        \
339 		cmn_err(CE_WARN,					\
340 			"AS_2_BIN: bad consistent coloring value");	\
341 		/* assume default algorithm -> continue */		\
342 	case 0: {                                                       \
343 		uint32_t ndx, new;					\
344 		int slew = 0;						\
345                                                                         \
346 		if (vp != NULL && IS_SWAPVP(vp) &&			\
347 			seg->s_ops == &segvn_ops)			\
348 			slew = as_color_bin(as);			\
349                                                                         \
350 		bin = (((uintptr_t)addr >> MMU_PAGESHIFT) +		\
351 			(((uintptr_t)addr >> page_coloring_shift) <<	\
352 			(vac_shift - MMU_PAGESHIFT)) + slew) &		\
353 			page_colors_mask;				\
354                                                                         \
355 		break;                                                  \
356 	}                                                               \
357 	case 1:                                                         \
358 		bin = ((uintptr_t)addr >> MMU_PAGESHIFT) &		\
359 			page_colors_mask;				\
360 		break;                                                  \
361 	case 2: {                                                       \
362 		int cnt = as_color_bin(as);				\
363 		/* make sure physical color aligns with vac color */	\
364 		while ((cnt & vac_colors_mask) !=			\
365 		    addr_to_vcolor(addr)) {				\
366 			cnt++;						\
367 		}                                                       \
368 		bin = cnt = cnt & page_colors_mask;			\
369 		/* update per as page coloring fields */		\
370 		cnt = (cnt + 1) & page_colors_mask;			\
371 		if (cnt == (as_color_start(as) & page_colors_mask)) {	\
372 			cnt = as_color_start(as) = as_color_start(as) + \
373 				PGCLR_LOOPFACTOR;			\
374 		}                                                       \
375 		as_color_bin(as) = cnt & page_colors_mask;		\
376 		break;                                                  \
377 	}								\
378 }									\
379 	ASSERT(bin <= page_colors_mask);
380 
381 /*
382  * cpu private vm data - accessed thru CPU->cpu_vm_data
383  *	vc_pnum_memseg: tracks last memseg visited in page_numtopp_nolock()
384  *	vc_pnext_memseg: tracks last memseg visited in page_nextn()
385  *	vc_kmptr: unaligned kmem pointer for this vm_cpu_data_t
386  */
387 
388 typedef struct {
389 	struct memseg	*vc_pnum_memseg;
390 	struct memseg	*vc_pnext_memseg;
391 	void		*vc_kmptr;
392 } vm_cpu_data_t;
393 
394 /* allocation size to ensure vm_cpu_data_t resides in its own cache line */
395 #define	VM_CPU_DATA_PADSIZE						\
396 	(P2ROUNDUP(sizeof (vm_cpu_data_t), L2CACHE_ALIGN_MAX))
397 
398 /* for boot cpu before kmem is initialized */
399 extern char	vm_cpu_data0[];
400 
401 /*
402  * Function to get an ecache color bin: F(as, cnt, vcolor).
403  * the goal of this function is to:
404  * - to spread a processes' physical pages across the entire ecache to
405  *	maximize its use.
406  * - to minimize vac flushes caused when we reuse a physical page on a
407  *	different vac color than it was previously used.
408  * - to prevent all processes to use the same exact colors and trash each
409  *	other.
410  *
411  * cnt is a bin ptr kept on a per as basis.  As we page_create we increment
412  * the ptr so we spread out the physical pages to cover the entire ecache.
413  * The virtual color is made a subset of the physical color in order to
414  * in minimize virtual cache flushing.
415  * We add in the as to spread out different as.	 This happens when we
416  * initialize the start count value.
417  * sizeof(struct as) is 60 so we shift by 3 to get into the bit range
418  * that will tend to change.  For example, on spitfire based machines
419  * (vcshft == 1) contigous as are spread bu ~6 bins.
420  * vcshft provides for proper virtual color alignment.
421  * In theory cnt should be updated using cas only but if we are off by one
422  * or 2 it is no big deal.
423  * We also keep a start value which is used to randomize on what bin we
424  * start counting when it is time to start another loop. This avoids
425  * contigous allocations of ecache size to point to the same bin.
426  * Why 3? Seems work ok. Better than 7 or anything larger.
427  */
428 #define	PGCLR_LOOPFACTOR 3
429 
430 /*
431  * When a bin is empty, and we can't satisfy a color request correctly,
432  * we scan.  If we assume that the programs have reasonable spatial
433  * behavior, then it will not be a good idea to use the adjacent color.
434  * Using the adjacent color would result in virtually adjacent addresses
435  * mapping into the same spot in the cache.  So, if we stumble across
436  * an empty bin, skip a bunch before looking.  After the first skip,
437  * then just look one bin at a time so we don't miss our cache on
438  * every look. Be sure to check every bin.  Page_create() will panic
439  * if we miss a page.
440  *
441  * This also explains the `<=' in the for loops in both page_get_freelist()
442  * and page_get_cachelist().  Since we checked the target bin, skipped
443  * a bunch, then continued one a time, we wind up checking the target bin
444  * twice to make sure we get all of them bins.
445  */
446 #define	BIN_STEP	20
447 
448 #ifdef VM_STATS
449 struct vmm_vmstats_str {
450 	ulong_t pgf_alloc[MMU_PAGE_SIZES];	/* page_get_freelist */
451 	ulong_t pgf_allocok[MMU_PAGE_SIZES];
452 	ulong_t pgf_allocokrem[MMU_PAGE_SIZES];
453 	ulong_t pgf_allocfailed[MMU_PAGE_SIZES];
454 	ulong_t pgf_allocdeferred;
455 	ulong_t	pgf_allocretry[MMU_PAGE_SIZES];
456 	ulong_t pgc_alloc;			/* page_get_cachelist */
457 	ulong_t pgc_allocok;
458 	ulong_t pgc_allocokrem;
459 	ulong_t	pgc_allocokdeferred;
460 	ulong_t pgc_allocfailed;
461 	ulong_t	pgcp_alloc[MMU_PAGE_SIZES];	/* page_get_contig_pages */
462 	ulong_t	pgcp_allocfailed[MMU_PAGE_SIZES];
463 	ulong_t	pgcp_allocempty[MMU_PAGE_SIZES];
464 	ulong_t	pgcp_allocok[MMU_PAGE_SIZES];
465 	ulong_t	ptcp[MMU_PAGE_SIZES];		/* page_trylock_contig_pages */
466 	ulong_t	ptcpfreethresh[MMU_PAGE_SIZES];
467 	ulong_t	ptcpfailexcl[MMU_PAGE_SIZES];
468 	ulong_t	ptcpfailszc[MMU_PAGE_SIZES];
469 	ulong_t	ptcpfailcage[MMU_PAGE_SIZES];
470 	ulong_t	ptcpok[MMU_PAGE_SIZES];
471 	ulong_t	pgmf_alloc[MMU_PAGE_SIZES];	/* page_get_mnode_freelist */
472 	ulong_t	pgmf_allocfailed[MMU_PAGE_SIZES];
473 	ulong_t	pgmf_allocempty[MMU_PAGE_SIZES];
474 	ulong_t	pgmf_allocok[MMU_PAGE_SIZES];
475 	ulong_t	pgmc_alloc;			/* page_get_mnode_cachelist */
476 	ulong_t	pgmc_allocfailed;
477 	ulong_t	pgmc_allocempty;
478 	ulong_t	pgmc_allocok;
479 	ulong_t	pladd_free[MMU_PAGE_SIZES];	/* page_list_add/sub */
480 	ulong_t	plsub_free[MMU_PAGE_SIZES];
481 	ulong_t	pladd_cache;
482 	ulong_t	plsub_cache;
483 	ulong_t	plsubpages_szcbig;
484 	ulong_t	plsubpages_szc0;
485 	ulong_t	pff_req[MMU_PAGE_SIZES];	/* page_freelist_fill */
486 	ulong_t	pff_demote[MMU_PAGE_SIZES];
487 	ulong_t	pff_coalok[MMU_PAGE_SIZES];
488 	ulong_t ppr_reloc[MMU_PAGE_SIZES];	/* page_relocate */
489 	ulong_t ppr_relocok[MMU_PAGE_SIZES];
490 	ulong_t ppr_relocnoroot[MMU_PAGE_SIZES];
491 	ulong_t ppr_reloc_replnoroot[MMU_PAGE_SIZES];
492 	ulong_t ppr_relocnolock[MMU_PAGE_SIZES];
493 	ulong_t ppr_relocnomem[MMU_PAGE_SIZES];
494 	ulong_t ppr_krelocfail[MMU_PAGE_SIZES];
495 	ulong_t	page_ctrs_coalesce;	/* page coalesce counter */
496 	ulong_t	page_ctrs_cands_skip;	/* candidates useful */
497 	ulong_t	page_ctrs_changed;	/* ctrs changed after locking */
498 	ulong_t	page_ctrs_failed;	/* page_freelist_coalesce failed */
499 	ulong_t	page_ctrs_coalesce_all;	/* page coalesce all counter */
500 	ulong_t	page_ctrs_cands_skip_all; /* candidates useful for all func */
501 };
502 extern struct vmm_vmstats_str vmm_vmstats;
503 #endif	/* VM_STATS */
504 
505 /*
506  * Used to hold off page relocations into the cage until OBP has completed
507  * its boot-time handoff of its resources to the kernel.
508  */
509 extern int page_relocate_ready;
510 
511 /*
512  * cpu/mmu-dependent vm variables may be reset at bootup.
513  */
514 extern uint_t mmu_page_sizes;
515 extern uint_t max_mmu_page_sizes;
516 extern uint_t mmu_hashcnt;
517 extern uint_t max_mmu_hashcnt;
518 extern size_t mmu_ism_pagesize;
519 extern int mmu_exported_pagesize_mask;
520 extern uint_t mmu_exported_page_sizes;
521 extern uint_t szc_2_userszc[];
522 extern uint_t userszc_2_szc[];
523 
524 #define	USERSZC_2_SZC(userszc)	(userszc_2_szc[userszc])
525 #define	SZC_2_USERSZC(szc)	(szc_2_userszc[szc])
526 
527 /*
528  * Platform specific map_pgsz large page hook routines.
529  */
530 extern size_t map_pgszva(struct proc *p, caddr_t addr, size_t len);
531 extern size_t map_pgszheap(struct proc *p, caddr_t addr, size_t len);
532 extern size_t map_pgszstk(struct proc *p, caddr_t addr, size_t len);
533 
534 /*
535  * Platform specific page routines
536  */
537 extern void mach_page_add(page_t **, page_t *);
538 extern void mach_page_sub(page_t **, page_t *);
539 extern uint_t page_get_pagecolors(uint_t);
540 extern void ppcopy_kernel__relocatable(page_t *, page_t *);
541 #define	ppcopy_kernel(p1, p2)	ppcopy_kernel__relocatable(p1, p2)
542 
543 /*
544  * platform specific large pages for kernel heap support
545  */
546 extern size_t get_segkmem_lpsize(size_t lpsize);
547 extern size_t mmu_get_kernel_lpsize(size_t lpsize);
548 extern void mmu_init_kernel_pgsz(struct hat *hat);
549 extern void mmu_init_kcontext();
550 extern uint64_t kcontextreg;
551 
552 #ifdef	__cplusplus
553 }
554 #endif
555 
556 #endif	/* _VM_DEP_H */
557