xref: /titanic_52/usr/src/uts/sun4/vm/vm_dep.h (revision 108322fb1c3ed341aba9c80c9774df0ed9e35768)
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	512
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 extern pgcnt_t auto_lpg_min_physmem;
330 
331 /*
332  * AS_2_BIN macro controls the page coloring policy.
333  * 0 (default) uses various vaddr bits
334  * 1 virtual=paddr
335  * 2 bin hopping
336  */
337 #define	AS_2_BIN(as, seg, vp, addr, bin)				\
338 switch (consistent_coloring) {						\
339 	default:                                                        \
340 		cmn_err(CE_WARN,					\
341 			"AS_2_BIN: bad consistent coloring value");	\
342 		/* assume default algorithm -> continue */		\
343 	case 0: {                                                       \
344 		uint32_t ndx, new;					\
345 		int slew = 0;						\
346                                                                         \
347 		if (vp != NULL && IS_SWAPVP(vp) &&			\
348 			seg->s_ops == &segvn_ops)			\
349 			slew = as_color_bin(as);			\
350                                                                         \
351 		bin = (((uintptr_t)addr >> MMU_PAGESHIFT) +		\
352 			(((uintptr_t)addr >> page_coloring_shift) <<	\
353 			(vac_shift - MMU_PAGESHIFT)) + slew) &		\
354 			page_colors_mask;				\
355                                                                         \
356 		break;                                                  \
357 	}                                                               \
358 	case 1:                                                         \
359 		bin = ((uintptr_t)addr >> MMU_PAGESHIFT) &		\
360 			page_colors_mask;				\
361 		break;                                                  \
362 	case 2: {                                                       \
363 		int cnt = as_color_bin(as);				\
364 		/* make sure physical color aligns with vac color */	\
365 		while ((cnt & vac_colors_mask) !=			\
366 		    addr_to_vcolor(addr)) {				\
367 			cnt++;						\
368 		}                                                       \
369 		bin = cnt = cnt & page_colors_mask;			\
370 		/* update per as page coloring fields */		\
371 		cnt = (cnt + 1) & page_colors_mask;			\
372 		if (cnt == (as_color_start(as) & page_colors_mask)) {	\
373 			cnt = as_color_start(as) = as_color_start(as) + \
374 				PGCLR_LOOPFACTOR;			\
375 		}                                                       \
376 		as_color_bin(as) = cnt & page_colors_mask;		\
377 		break;                                                  \
378 	}								\
379 }									\
380 	ASSERT(bin <= page_colors_mask);
381 
382 /*
383  * cpu private vm data - accessed thru CPU->cpu_vm_data
384  *	vc_pnum_memseg: tracks last memseg visited in page_numtopp_nolock()
385  *	vc_pnext_memseg: tracks last memseg visited in page_nextn()
386  *	vc_kmptr: unaligned kmem pointer for this vm_cpu_data_t
387  *	vc_kmsize: orignal kmem size for this vm_cpu_data_t
388  */
389 
390 typedef struct {
391 	struct memseg	*vc_pnum_memseg;
392 	struct memseg	*vc_pnext_memseg;
393 	void		*vc_kmptr;
394 	size_t		vc_kmsize;
395 } vm_cpu_data_t;
396 
397 /* allocation size to ensure vm_cpu_data_t resides in its own cache line */
398 #define	VM_CPU_DATA_PADSIZE						\
399 	(P2ROUNDUP(sizeof (vm_cpu_data_t), L2CACHE_ALIGN_MAX))
400 
401 /* for boot cpu before kmem is initialized */
402 extern char	vm_cpu_data0[];
403 
404 /*
405  * Function to get an ecache color bin: F(as, cnt, vcolor).
406  * the goal of this function is to:
407  * - to spread a processes' physical pages across the entire ecache to
408  *	maximize its use.
409  * - to minimize vac flushes caused when we reuse a physical page on a
410  *	different vac color than it was previously used.
411  * - to prevent all processes to use the same exact colors and trash each
412  *	other.
413  *
414  * cnt is a bin ptr kept on a per as basis.  As we page_create we increment
415  * the ptr so we spread out the physical pages to cover the entire ecache.
416  * The virtual color is made a subset of the physical color in order to
417  * in minimize virtual cache flushing.
418  * We add in the as to spread out different as.	 This happens when we
419  * initialize the start count value.
420  * sizeof(struct as) is 60 so we shift by 3 to get into the bit range
421  * that will tend to change.  For example, on spitfire based machines
422  * (vcshft == 1) contigous as are spread bu ~6 bins.
423  * vcshft provides for proper virtual color alignment.
424  * In theory cnt should be updated using cas only but if we are off by one
425  * or 2 it is no big deal.
426  * We also keep a start value which is used to randomize on what bin we
427  * start counting when it is time to start another loop. This avoids
428  * contigous allocations of ecache size to point to the same bin.
429  * Why 3? Seems work ok. Better than 7 or anything larger.
430  */
431 #define	PGCLR_LOOPFACTOR 3
432 
433 /*
434  * When a bin is empty, and we can't satisfy a color request correctly,
435  * we scan.  If we assume that the programs have reasonable spatial
436  * behavior, then it will not be a good idea to use the adjacent color.
437  * Using the adjacent color would result in virtually adjacent addresses
438  * mapping into the same spot in the cache.  So, if we stumble across
439  * an empty bin, skip a bunch before looking.  After the first skip,
440  * then just look one bin at a time so we don't miss our cache on
441  * every look. Be sure to check every bin.  Page_create() will panic
442  * if we miss a page.
443  *
444  * This also explains the `<=' in the for loops in both page_get_freelist()
445  * and page_get_cachelist().  Since we checked the target bin, skipped
446  * a bunch, then continued one a time, we wind up checking the target bin
447  * twice to make sure we get all of them bins.
448  */
449 #define	BIN_STEP	20
450 
451 #ifdef VM_STATS
452 struct vmm_vmstats_str {
453 	ulong_t pgf_alloc[MMU_PAGE_SIZES];	/* page_get_freelist */
454 	ulong_t pgf_allocok[MMU_PAGE_SIZES];
455 	ulong_t pgf_allocokrem[MMU_PAGE_SIZES];
456 	ulong_t pgf_allocfailed[MMU_PAGE_SIZES];
457 	ulong_t pgf_allocdeferred;
458 	ulong_t	pgf_allocretry[MMU_PAGE_SIZES];
459 	ulong_t pgc_alloc;			/* page_get_cachelist */
460 	ulong_t pgc_allocok;
461 	ulong_t pgc_allocokrem;
462 	ulong_t	pgc_allocokdeferred;
463 	ulong_t pgc_allocfailed;
464 	ulong_t	pgcp_alloc[MMU_PAGE_SIZES];	/* page_get_contig_pages */
465 	ulong_t	pgcp_allocfailed[MMU_PAGE_SIZES];
466 	ulong_t	pgcp_allocempty[MMU_PAGE_SIZES];
467 	ulong_t	pgcp_allocok[MMU_PAGE_SIZES];
468 	ulong_t	ptcp[MMU_PAGE_SIZES];		/* page_trylock_contig_pages */
469 	ulong_t	ptcpfreethresh[MMU_PAGE_SIZES];
470 	ulong_t	ptcpfailexcl[MMU_PAGE_SIZES];
471 	ulong_t	ptcpfailszc[MMU_PAGE_SIZES];
472 	ulong_t	ptcpfailcage[MMU_PAGE_SIZES];
473 	ulong_t	ptcpok[MMU_PAGE_SIZES];
474 	ulong_t	pgmf_alloc[MMU_PAGE_SIZES];	/* page_get_mnode_freelist */
475 	ulong_t	pgmf_allocfailed[MMU_PAGE_SIZES];
476 	ulong_t	pgmf_allocempty[MMU_PAGE_SIZES];
477 	ulong_t	pgmf_allocok[MMU_PAGE_SIZES];
478 	ulong_t	pgmc_alloc;			/* page_get_mnode_cachelist */
479 	ulong_t	pgmc_allocfailed;
480 	ulong_t	pgmc_allocempty;
481 	ulong_t	pgmc_allocok;
482 	ulong_t	pladd_free[MMU_PAGE_SIZES];	/* page_list_add/sub */
483 	ulong_t	plsub_free[MMU_PAGE_SIZES];
484 	ulong_t	pladd_cache;
485 	ulong_t	plsub_cache;
486 	ulong_t	plsubpages_szcbig;
487 	ulong_t	plsubpages_szc0;
488 	ulong_t	pff_req[MMU_PAGE_SIZES];	/* page_freelist_fill */
489 	ulong_t	pff_demote[MMU_PAGE_SIZES];
490 	ulong_t	pff_coalok[MMU_PAGE_SIZES];
491 	ulong_t ppr_reloc[MMU_PAGE_SIZES];	/* page_relocate */
492 	ulong_t ppr_relocok[MMU_PAGE_SIZES];
493 	ulong_t ppr_relocnoroot[MMU_PAGE_SIZES];
494 	ulong_t ppr_reloc_replnoroot[MMU_PAGE_SIZES];
495 	ulong_t ppr_relocnolock[MMU_PAGE_SIZES];
496 	ulong_t ppr_relocnomem[MMU_PAGE_SIZES];
497 	ulong_t ppr_krelocfail[MMU_PAGE_SIZES];
498 	ulong_t	page_ctrs_coalesce;	/* page coalesce counter */
499 	ulong_t	page_ctrs_cands_skip;	/* candidates useful */
500 	ulong_t	page_ctrs_changed;	/* ctrs changed after locking */
501 	ulong_t	page_ctrs_failed;	/* page_freelist_coalesce failed */
502 	ulong_t	page_ctrs_coalesce_all;	/* page coalesce all counter */
503 	ulong_t	page_ctrs_cands_skip_all; /* candidates useful for all func */
504 };
505 extern struct vmm_vmstats_str vmm_vmstats;
506 #endif	/* VM_STATS */
507 
508 /*
509  * Used to hold off page relocations into the cage until OBP has completed
510  * its boot-time handoff of its resources to the kernel.
511  */
512 extern int page_relocate_ready;
513 
514 /*
515  * cpu/mmu-dependent vm variables may be reset at bootup.
516  */
517 extern uint_t mmu_page_sizes;
518 extern uint_t max_mmu_page_sizes;
519 extern uint_t mmu_hashcnt;
520 extern uint_t max_mmu_hashcnt;
521 extern size_t mmu_ism_pagesize;
522 extern int mmu_exported_pagesize_mask;
523 extern uint_t mmu_exported_page_sizes;
524 extern uint_t szc_2_userszc[];
525 extern uint_t userszc_2_szc[];
526 
527 #define	USERSZC_2_SZC(userszc)	(userszc_2_szc[userszc])
528 #define	SZC_2_USERSZC(szc)	(szc_2_userszc[szc])
529 
530 /*
531  * Platform specific map_pgsz large page hook routines.
532  */
533 extern size_t map_pgszva(struct proc *p, caddr_t addr, size_t len);
534 extern size_t map_pgszheap(struct proc *p, caddr_t addr, size_t len);
535 extern size_t map_pgszstk(struct proc *p, caddr_t addr, size_t len);
536 
537 /*
538  * Platform specific page routines
539  */
540 extern void mach_page_add(page_t **, page_t *);
541 extern void mach_page_sub(page_t **, page_t *);
542 extern uint_t page_get_pagecolors(uint_t);
543 extern void ppcopy_kernel__relocatable(page_t *, page_t *);
544 #define	ppcopy_kernel(p1, p2)	ppcopy_kernel__relocatable(p1, p2)
545 
546 /*
547  * platform specific large pages for kernel heap support
548  */
549 extern size_t get_segkmem_lpsize(size_t lpsize);
550 extern size_t mmu_get_kernel_lpsize(size_t lpsize);
551 extern void mmu_init_kernel_pgsz(struct hat *hat);
552 extern void mmu_init_kcontext();
553 extern uint64_t kcontextreg;
554 
555 #ifdef	__cplusplus
556 }
557 #endif
558 
559 #endif	/* _VM_DEP_H */
560