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