xref: /titanic_44/usr/src/uts/sun4/vm/vm_dep.h (revision 28167c24ba5be8b7c1d05e02d053f4a55cd21cc9)
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 2006 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_CACHE_LIST)					\
177 		atomic_add_long(&plcnt[mn][mtype].plc_mt_clpgcnt, cnt);	\
178 	else if (szc)							\
179 		atomic_add_long(&plcnt[mn][mtype].plc_mt_lgpgcnt, cnt);	\
180 	else								\
181 		atomic_add_long(&plcnt[mn][mtype].plc_mt_flpgcnt, cnt);	\
182 	atomic_add_long(&plcnt[mn][mtype].plc_mts[szc].plc_mts_pgcnt,	\
183 	    cnt);							\
184 	atomic_add_long(&plcnt[mn][mtype].plc_mts[szc].			\
185 	    plc_mtsc_pgcnt[bin], cnt);					\
186 }
187 
188 #else
189 
190 #define	PLCNT_SZ(ctrs_sz)
191 
192 #define	PLCNT_INIT(base)
193 
194 /* PG_FREE_LIST may not be explicitly set in flags for large pages */
195 
196 #define	PLCNT_DO(pp, mn, mtype, szc, cnt, flags) {			\
197 	if (flags & PG_CACHE_LIST)					\
198 		atomic_add_long(&plcnt[mn][mtype].plc_mt_clpgcnt, cnt);	\
199 	else if (szc)							\
200 		atomic_add_long(&plcnt[mn][mtype].plc_mt_lgpgcnt, cnt);	\
201 	else								\
202 		atomic_add_long(&plcnt[mn][mtype].plc_mt_flpgcnt, cnt);	\
203 }
204 
205 #endif
206 
207 #define	PLCNT_INCR(pp, mn, mtype, szc, flags) {				\
208 	long	cnt = (1 << PAGE_BSZS_SHIFT(szc));			\
209 	PLCNT_DO(pp, mn, mtype, szc, cnt, flags);			\
210 }
211 
212 #define	PLCNT_DECR(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 /*
218  * macros to update page list max counts - done when pages transferred
219  * from RELOC to NORELOC mtype (kcage_init or kcage_assimilate_page).
220  */
221 
222 #define	PLCNT_XFER_NORELOC(pp) {					\
223 	long	cnt = (1 << PAGE_BSZS_SHIFT((pp)->p_szc));		\
224 	int	mn = PP_2_MEM_NODE(pp);					\
225 	atomic_add_long(&plcnt[mn][MTYPE_NORELOC].plc_mt_pgmax, cnt);	\
226 	atomic_add_long(&plcnt[mn][MTYPE_RELOC].plc_mt_pgmax, -cnt);	\
227 }
228 
229 /*
230  * macro to modify the page list max counts when memory is added to
231  * the page lists during startup (add_physmem) or during a DR operation
232  * when memory is added (kphysm_add_memory_dynamic) or deleted
233  * (kphysm_del_cleanup).
234  */
235 #define	PLCNT_MODIFY_MAX(pfn, cnt) {					\
236 	int	mn = PFN_2_MEM_NODE(pfn);				\
237 	atomic_add_long(&plcnt[mn][MTYPE_RELOC].plc_mt_pgmax, (cnt));	\
238 }
239 
240 extern plcnt_t	plcnt;
241 
242 #define	MNODE_PGCNT(mn)							\
243 	(plcnt[mn][MTYPE_RELOC].plc_mt_clpgcnt +			\
244 	    plcnt[mn][MTYPE_NORELOC].plc_mt_clpgcnt +			\
245 	    plcnt[mn][MTYPE_RELOC].plc_mt_flpgcnt +			\
246 	    plcnt[mn][MTYPE_NORELOC].plc_mt_flpgcnt +			\
247 	    plcnt[mn][MTYPE_RELOC].plc_mt_lgpgcnt +			\
248 	    plcnt[mn][MTYPE_NORELOC].plc_mt_lgpgcnt)
249 
250 #define	MNODETYPE_PGCNT(mn, mtype)					\
251 	(plcnt[mn][mtype].plc_mt_clpgcnt +				\
252 	    plcnt[mn][mtype].plc_mt_flpgcnt +				\
253 	    plcnt[mn][mtype].plc_mt_lgpgcnt)
254 
255 /*
256  * macros to loop through the mtype range - MTYPE_START returns -1 in
257  * mtype if no pages in mnode/mtype and possibly NEXT mtype.
258  */
259 #define	MTYPE_START(mnode, mtype, flags) {				\
260 	if (plcnt[mnode][mtype].plc_mt_pgmax == 0) {			\
261 		ASSERT(MNODETYPE_PGCNT(mnode, mtype) == 0);		\
262 		MTYPE_NEXT(mnode, mtype, flags);			\
263 	}								\
264 }
265 
266 /*
267  * if allocation from the RELOC pool failed and there is sufficient cage
268  * memory, attempt to allocate from the NORELOC pool.
269  */
270 #define	MTYPE_NEXT(mnode, mtype, flags) { 				\
271 	if (!(flags & (PG_NORELOC | PGI_NOCAGE | PGI_RELOCONLY)) &&	\
272 	    (kcage_freemem >= kcage_lotsfree)) {			\
273 		if (plcnt[mnode][mtype].plc_mt_pgmax == 0) {		\
274 			ASSERT(MNODETYPE_PGCNT(mnode, mtype) == 0);	\
275 			mtype = -1;					\
276 		} else {						\
277 			mtype = MTYPE_NORELOC;				\
278 			flags |= PG_NORELOC;				\
279 		}							\
280 	} else {							\
281 		mtype = -1;						\
282 	}								\
283 }
284 
285 /*
286  * get the ecache setsize for the current cpu.
287  */
288 #define	CPUSETSIZE()	(cpunodes[CPU->cpu_id].ecache_setsize)
289 
290 extern struct cpu	cpu0;
291 #define	CPU0		&cpu0
292 
293 #define	PAGE_BSZS_SHIFT(szc)	TTE_BSZS_SHIFT(szc)
294 /*
295  * For sfmmu each larger page is 8 times the size of the previous
296  * size page.
297  */
298 #define	FULL_REGION_CNT(rg_szc)	(8)
299 
300 /*
301  * The counter base must be per page_counter element to prevent
302  * races when re-indexing, and the base page size element should
303  * be aligned on a boundary of the given region size.
304  *
305  * We also round up the number of pages spanned by the counters
306  * for a given region to PC_BASE_ALIGN in certain situations to simplify
307  * the coding for some non-performance critical routines.
308  */
309 #define	PC_BASE_ALIGN		((pfn_t)1 << PAGE_BSZS_SHIFT(mmu_page_sizes-1))
310 #define	PC_BASE_ALIGN_MASK	(PC_BASE_ALIGN - 1)
311 
312 extern int ecache_alignsize;
313 #define	L2CACHE_ALIGN		ecache_alignsize
314 #define	L2CACHE_ALIGN_MAX	512
315 
316 extern int consistent_coloring;
317 extern uint_t vac_colors_mask;
318 extern int vac_size;
319 extern int vac_shift;
320 
321 /*
322  * Auto large page selection support variables. Some CPU
323  * implementations may differ from the defaults and will need
324  * to change these.
325  */
326 extern int auto_lpg_tlb_threshold;
327 extern int auto_lpg_minszc;
328 extern int auto_lpg_maxszc;
329 extern size_t auto_lpg_heap_default;
330 extern size_t auto_lpg_stack_default;
331 extern size_t auto_lpg_va_default;
332 extern size_t auto_lpg_remap_threshold;
333 extern pgcnt_t auto_lpg_min_physmem;
334 
335 /*
336  * AS_2_BIN macro controls the page coloring policy.
337  * 0 (default) uses various vaddr bits
338  * 1 virtual=paddr
339  * 2 bin hopping
340  */
341 #define	AS_2_BIN(as, seg, vp, addr, bin)				\
342 switch (consistent_coloring) {						\
343 	default:                                                        \
344 		cmn_err(CE_WARN,					\
345 			"AS_2_BIN: bad consistent coloring value");	\
346 		/* assume default algorithm -> continue */		\
347 	case 0: {                                                       \
348 		uint32_t ndx, new;					\
349 		int slew = 0;						\
350                                                                         \
351 		if (vp != NULL && IS_SWAPVP(vp) &&			\
352 			seg->s_ops == &segvn_ops)			\
353 			slew = as_color_bin(as);			\
354                                                                         \
355 		bin = (((uintptr_t)addr >> MMU_PAGESHIFT) +		\
356 			(((uintptr_t)addr >> page_coloring_shift) <<	\
357 			(vac_shift - MMU_PAGESHIFT)) + slew) &		\
358 			page_colors_mask;				\
359                                                                         \
360 		break;                                                  \
361 	}                                                               \
362 	case 1:                                                         \
363 		bin = ((uintptr_t)addr >> MMU_PAGESHIFT) &		\
364 			page_colors_mask;				\
365 		break;                                                  \
366 	case 2: {                                                       \
367 		int cnt = as_color_bin(as);				\
368 		/* make sure physical color aligns with vac color */	\
369 		while ((cnt & vac_colors_mask) !=			\
370 		    addr_to_vcolor(addr)) {				\
371 			cnt++;						\
372 		}                                                       \
373 		bin = cnt = cnt & page_colors_mask;			\
374 		/* update per as page coloring fields */		\
375 		cnt = (cnt + 1) & page_colors_mask;			\
376 		if (cnt == (as_color_start(as) & page_colors_mask)) {	\
377 			cnt = as_color_start(as) = as_color_start(as) + \
378 				PGCLR_LOOPFACTOR;			\
379 		}                                                       \
380 		as_color_bin(as) = cnt & page_colors_mask;		\
381 		break;                                                  \
382 	}								\
383 }									\
384 	ASSERT(bin <= page_colors_mask);
385 
386 /*
387  * cpu private vm data - accessed thru CPU->cpu_vm_data
388  *	vc_pnum_memseg: tracks last memseg visited in page_numtopp_nolock()
389  *	vc_pnext_memseg: tracks last memseg visited in page_nextn()
390  *	vc_kmptr: unaligned kmem pointer for this vm_cpu_data_t
391  *	vc_kmsize: orignal kmem size for this vm_cpu_data_t
392  */
393 
394 typedef struct {
395 	struct memseg	*vc_pnum_memseg;
396 	struct memseg	*vc_pnext_memseg;
397 	void		*vc_kmptr;
398 	size_t		vc_kmsize;
399 } vm_cpu_data_t;
400 
401 /* allocation size to ensure vm_cpu_data_t resides in its own cache line */
402 #define	VM_CPU_DATA_PADSIZE						\
403 	(P2ROUNDUP(sizeof (vm_cpu_data_t), L2CACHE_ALIGN_MAX))
404 
405 /* for boot cpu before kmem is initialized */
406 extern char	vm_cpu_data0[];
407 
408 /*
409  * Function to get an ecache color bin: F(as, cnt, vcolor).
410  * the goal of this function is to:
411  * - to spread a processes' physical pages across the entire ecache to
412  *	maximize its use.
413  * - to minimize vac flushes caused when we reuse a physical page on a
414  *	different vac color than it was previously used.
415  * - to prevent all processes to use the same exact colors and trash each
416  *	other.
417  *
418  * cnt is a bin ptr kept on a per as basis.  As we page_create we increment
419  * the ptr so we spread out the physical pages to cover the entire ecache.
420  * The virtual color is made a subset of the physical color in order to
421  * in minimize virtual cache flushing.
422  * We add in the as to spread out different as.	 This happens when we
423  * initialize the start count value.
424  * sizeof(struct as) is 60 so we shift by 3 to get into the bit range
425  * that will tend to change.  For example, on spitfire based machines
426  * (vcshft == 1) contigous as are spread bu ~6 bins.
427  * vcshft provides for proper virtual color alignment.
428  * In theory cnt should be updated using cas only but if we are off by one
429  * or 2 it is no big deal.
430  * We also keep a start value which is used to randomize on what bin we
431  * start counting when it is time to start another loop. This avoids
432  * contigous allocations of ecache size to point to the same bin.
433  * Why 3? Seems work ok. Better than 7 or anything larger.
434  */
435 #define	PGCLR_LOOPFACTOR 3
436 
437 /*
438  * When a bin is empty, and we can't satisfy a color request correctly,
439  * we scan.  If we assume that the programs have reasonable spatial
440  * behavior, then it will not be a good idea to use the adjacent color.
441  * Using the adjacent color would result in virtually adjacent addresses
442  * mapping into the same spot in the cache.  So, if we stumble across
443  * an empty bin, skip a bunch before looking.  After the first skip,
444  * then just look one bin at a time so we don't miss our cache on
445  * every look. Be sure to check every bin.  Page_create() will panic
446  * if we miss a page.
447  *
448  * This also explains the `<=' in the for loops in both page_get_freelist()
449  * and page_get_cachelist().  Since we checked the target bin, skipped
450  * a bunch, then continued one a time, we wind up checking the target bin
451  * twice to make sure we get all of them bins.
452  */
453 #define	BIN_STEP	20
454 
455 #ifdef VM_STATS
456 struct vmm_vmstats_str {
457 	ulong_t pgf_alloc[MMU_PAGE_SIZES];	/* page_get_freelist */
458 	ulong_t pgf_allocok[MMU_PAGE_SIZES];
459 	ulong_t pgf_allocokrem[MMU_PAGE_SIZES];
460 	ulong_t pgf_allocfailed[MMU_PAGE_SIZES];
461 	ulong_t pgf_allocdeferred;
462 	ulong_t	pgf_allocretry[MMU_PAGE_SIZES];
463 	ulong_t pgc_alloc;			/* page_get_cachelist */
464 	ulong_t pgc_allocok;
465 	ulong_t pgc_allocokrem;
466 	ulong_t	pgc_allocokdeferred;
467 	ulong_t pgc_allocfailed;
468 	ulong_t	pgcp_alloc[MMU_PAGE_SIZES];	/* page_get_contig_pages */
469 	ulong_t	pgcp_allocfailed[MMU_PAGE_SIZES];
470 	ulong_t	pgcp_allocempty[MMU_PAGE_SIZES];
471 	ulong_t	pgcp_allocok[MMU_PAGE_SIZES];
472 	ulong_t	ptcp[MMU_PAGE_SIZES];		/* page_trylock_contig_pages */
473 	ulong_t	ptcpfreethresh[MMU_PAGE_SIZES];
474 	ulong_t	ptcpfailexcl[MMU_PAGE_SIZES];
475 	ulong_t	ptcpfailszc[MMU_PAGE_SIZES];
476 	ulong_t	ptcpfailcage[MMU_PAGE_SIZES];
477 	ulong_t	ptcpok[MMU_PAGE_SIZES];
478 	ulong_t	pgmf_alloc[MMU_PAGE_SIZES];	/* page_get_mnode_freelist */
479 	ulong_t	pgmf_allocfailed[MMU_PAGE_SIZES];
480 	ulong_t	pgmf_allocempty[MMU_PAGE_SIZES];
481 	ulong_t	pgmf_allocok[MMU_PAGE_SIZES];
482 	ulong_t	pgmc_alloc;			/* page_get_mnode_cachelist */
483 	ulong_t	pgmc_allocfailed;
484 	ulong_t	pgmc_allocempty;
485 	ulong_t	pgmc_allocok;
486 	ulong_t	pladd_free[MMU_PAGE_SIZES];	/* page_list_add/sub */
487 	ulong_t	plsub_free[MMU_PAGE_SIZES];
488 	ulong_t	pladd_cache;
489 	ulong_t	plsub_cache;
490 	ulong_t	plsubpages_szcbig;
491 	ulong_t	plsubpages_szc0;
492 	ulong_t	pff_req[MMU_PAGE_SIZES];	/* page_freelist_fill */
493 	ulong_t	pff_demote[MMU_PAGE_SIZES];
494 	ulong_t	pff_coalok[MMU_PAGE_SIZES];
495 	ulong_t ppr_reloc[MMU_PAGE_SIZES];	/* page_relocate */
496 	ulong_t ppr_relocok[MMU_PAGE_SIZES];
497 	ulong_t ppr_relocnoroot[MMU_PAGE_SIZES];
498 	ulong_t ppr_reloc_replnoroot[MMU_PAGE_SIZES];
499 	ulong_t ppr_relocnolock[MMU_PAGE_SIZES];
500 	ulong_t ppr_relocnomem[MMU_PAGE_SIZES];
501 	ulong_t ppr_krelocfail[MMU_PAGE_SIZES];
502 	ulong_t	page_ctrs_coalesce;	/* page coalesce counter */
503 	ulong_t	page_ctrs_cands_skip;	/* candidates useful */
504 	ulong_t	page_ctrs_changed;	/* ctrs changed after locking */
505 	ulong_t	page_ctrs_failed;	/* page_freelist_coalesce failed */
506 	ulong_t	page_ctrs_coalesce_all;	/* page coalesce all counter */
507 	ulong_t	page_ctrs_cands_skip_all; /* candidates useful for all func */
508 };
509 extern struct vmm_vmstats_str vmm_vmstats;
510 #endif	/* VM_STATS */
511 
512 /*
513  * Used to hold off page relocations into the cage until OBP has completed
514  * its boot-time handoff of its resources to the kernel.
515  */
516 extern int page_relocate_ready;
517 
518 /*
519  * cpu/mmu-dependent vm variables may be reset at bootup.
520  */
521 extern uint_t mmu_page_sizes;
522 extern uint_t max_mmu_page_sizes;
523 extern uint_t mmu_hashcnt;
524 extern uint_t max_mmu_hashcnt;
525 extern size_t mmu_ism_pagesize;
526 extern int mmu_exported_pagesize_mask;
527 extern uint_t mmu_exported_page_sizes;
528 extern uint_t szc_2_userszc[];
529 extern uint_t userszc_2_szc[];
530 
531 #define	USERSZC_2_SZC(userszc)	(userszc_2_szc[userszc])
532 #define	SZC_2_USERSZC(szc)	(szc_2_userszc[szc])
533 
534 /*
535  * Platform specific map_pgsz large page hook routines.
536  */
537 extern size_t map_pgszva(struct proc *p, caddr_t addr, size_t len);
538 extern size_t map_pgszheap(struct proc *p, caddr_t addr, size_t len);
539 extern size_t map_pgszstk(struct proc *p, caddr_t addr, size_t len);
540 
541 /*
542  * Platform specific page routines
543  */
544 extern void mach_page_add(page_t **, page_t *);
545 extern void mach_page_sub(page_t **, page_t *);
546 extern uint_t page_get_pagecolors(uint_t);
547 extern void ppcopy_kernel__relocatable(page_t *, page_t *);
548 #define	ppcopy_kernel(p1, p2)	ppcopy_kernel__relocatable(p1, p2)
549 
550 /*
551  * platform specific large pages for kernel heap support
552  */
553 extern size_t get_segkmem_lpsize(size_t lpsize);
554 extern size_t mmu_get_kernel_lpsize(size_t lpsize);
555 extern void mmu_init_kernel_pgsz(struct hat *hat);
556 extern void mmu_init_kcontext();
557 extern uint64_t kcontextreg;
558 
559 #ifdef	__cplusplus
560 }
561 #endif
562 
563 #endif	/* _VM_DEP_H */
564