xref: /freebsd/sys/vm/vm_init.c (revision f0165b1ca68bff74bd6196d796b3fa5b7a732ca2)
160727d8bSWarner Losh /*-
2796df753SPedro F. Giffuni  * SPDX-License-Identifier: (BSD-3-Clause AND MIT-CMU)
351369649SPedro F. Giffuni  *
4df8bae1dSRodney W. Grimes  * Copyright (c) 1991, 1993
5df8bae1dSRodney W. Grimes  *	The Regents of the University of California.  All rights reserved.
6df8bae1dSRodney W. Grimes  *
7df8bae1dSRodney W. Grimes  * This code is derived from software contributed to Berkeley by
8df8bae1dSRodney W. Grimes  * The Mach Operating System project at Carnegie-Mellon University.
9df8bae1dSRodney W. Grimes  *
10df8bae1dSRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
11df8bae1dSRodney W. Grimes  * modification, are permitted provided that the following conditions
12df8bae1dSRodney W. Grimes  * are met:
13df8bae1dSRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
14df8bae1dSRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
15df8bae1dSRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
16df8bae1dSRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
17df8bae1dSRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
18fbbd9655SWarner Losh  * 3. Neither the name of the University nor the names of its contributors
19df8bae1dSRodney W. Grimes  *    may be used to endorse or promote products derived from this software
20df8bae1dSRodney W. Grimes  *    without specific prior written permission.
21df8bae1dSRodney W. Grimes  *
22df8bae1dSRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23df8bae1dSRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24df8bae1dSRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25df8bae1dSRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26df8bae1dSRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27df8bae1dSRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28df8bae1dSRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29df8bae1dSRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30df8bae1dSRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31df8bae1dSRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32df8bae1dSRodney W. Grimes  * SUCH DAMAGE.
33df8bae1dSRodney W. Grimes  *
343c4dd356SDavid Greenman  *	from: @(#)vm_init.c	8.1 (Berkeley) 6/11/93
35df8bae1dSRodney W. Grimes  *
36df8bae1dSRodney W. Grimes  *
37df8bae1dSRodney W. Grimes  * Copyright (c) 1987, 1990 Carnegie-Mellon University.
38df8bae1dSRodney W. Grimes  * All rights reserved.
39df8bae1dSRodney W. Grimes  *
40df8bae1dSRodney W. Grimes  * Authors: Avadis Tevanian, Jr., Michael Wayne Young
41df8bae1dSRodney W. Grimes  *
42df8bae1dSRodney W. Grimes  * Permission to use, copy, modify and distribute this software and
43df8bae1dSRodney W. Grimes  * its documentation is hereby granted, provided that both the copyright
44df8bae1dSRodney W. Grimes  * notice and this permission notice appear in all copies of the
45df8bae1dSRodney W. Grimes  * software, derivative works or modified versions, and any portions
46df8bae1dSRodney W. Grimes  * thereof, and that both notices appear in supporting documentation.
47df8bae1dSRodney W. Grimes  *
48df8bae1dSRodney W. Grimes  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
49df8bae1dSRodney W. Grimes  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
50df8bae1dSRodney W. Grimes  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
51df8bae1dSRodney W. Grimes  *
52df8bae1dSRodney W. Grimes  * Carnegie Mellon requests users of this software to return to
53df8bae1dSRodney W. Grimes  *
54df8bae1dSRodney W. Grimes  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
55df8bae1dSRodney W. Grimes  *  School of Computer Science
56df8bae1dSRodney W. Grimes  *  Carnegie Mellon University
57df8bae1dSRodney W. Grimes  *  Pittsburgh PA 15213-3890
58df8bae1dSRodney W. Grimes  *
59df8bae1dSRodney W. Grimes  * any improvements or extensions that they make and grant Carnegie the
60df8bae1dSRodney W. Grimes  * rights to redistribute these changes.
61df8bae1dSRodney W. Grimes  */
62df8bae1dSRodney W. Grimes 
63df8bae1dSRodney W. Grimes /*
64df8bae1dSRodney W. Grimes  *	Initialize the Virtual Memory subsystem.
65df8bae1dSRodney W. Grimes  */
66df8bae1dSRodney W. Grimes 
67874651b1SDavid E. O'Brien #include <sys/cdefs.h>
68874651b1SDavid E. O'Brien __FBSDID("$FreeBSD$");
69874651b1SDavid E. O'Brien 
70df8bae1dSRodney W. Grimes #include <sys/param.h>
712b14f991SJulian Elischer #include <sys/kernel.h>
72fb919e4dSMark Murray #include <sys/lock.h>
73fb919e4dSMark Murray #include <sys/proc.h>
7489f6b863SAttilio Rao #include <sys/rwlock.h>
755df87b21SJeff Roberson #include <sys/malloc.h>
76f5fca0d8SKris Kennaway #include <sys/sysctl.h>
7705f0fdd2SPoul-Henning Kamp #include <sys/systm.h>
78cebde069SMike Silbersack #include <sys/selinfo.h>
7921fae961SJeff Roberson #include <sys/smp.h>
80cebde069SMike Silbersack #include <sys/pipe.h>
81219d632cSMatthew Dillon #include <sys/bio.h>
82219d632cSMatthew Dillon #include <sys/buf.h>
835f518366SJeff Roberson #include <sys/vmem.h>
847a469c8eSJeff Roberson #include <sys/vmmeter.h>
85df8bae1dSRodney W. Grimes 
86df8bae1dSRodney W. Grimes #include <vm/vm.h>
87219d632cSMatthew Dillon #include <vm/vm_param.h>
88219d632cSMatthew Dillon #include <vm/vm_kern.h>
89efeaf95aSDavid Greenman #include <vm/vm_object.h>
90df8bae1dSRodney W. Grimes #include <vm/vm_page.h>
917a469c8eSJeff Roberson #include <vm/vm_phys.h>
92e2068d0bSJeff Roberson #include <vm/vm_pagequeue.h>
93efeaf95aSDavid Greenman #include <vm/vm_map.h>
9424a1cce3SDavid Greenman #include <vm/vm_pager.h>
95efeaf95aSDavid Greenman #include <vm/vm_extern.h>
96df8bae1dSRodney W. Grimes 
97ae941b1bSGleb Smirnoff extern void	uma_startup1(void);
98f7d35785SGleb Smirnoff extern void	uma_startup2(void);
99ae941b1bSGleb Smirnoff extern void	vm_radix_reserve_kva(void);
1007a469c8eSJeff Roberson 
1017a469c8eSJeff Roberson #if VM_NRESERVLEVEL > 0
1027a469c8eSJeff Roberson #define	KVA_QUANTUM	(1 << (VM_LEVEL_0_ORDER + PAGE_SHIFT))
1037a469c8eSJeff Roberson #else
1047a469c8eSJeff Roberson 	/* On non-superpage architectures want large import sizes. */
1057a469c8eSJeff Roberson #define	KVA_QUANTUM	(PAGE_SIZE * 1024)
1067a469c8eSJeff Roberson #endif
1070fca57b8SThomas Moestl long physmem;
1080fca57b8SThomas Moestl 
109df8bae1dSRodney W. Grimes /*
1102b14f991SJulian Elischer  * System initialization
1112b14f991SJulian Elischer  */
11211caded3SAlfred Perlstein static void vm_mem_init(void *);
113237fdd78SRobert Watson SYSINIT(vm_mem, SI_SUB_VM, SI_ORDER_FIRST, vm_mem_init, NULL);
1142b14f991SJulian Elischer 
1152b14f991SJulian Elischer /*
1165df87b21SJeff Roberson  * Import kva into the kernel arena.
1175df87b21SJeff Roberson  */
1185df87b21SJeff Roberson static int
1195df87b21SJeff Roberson kva_import(void *unused, vmem_size_t size, int flags, vmem_addr_t *addrp)
1205df87b21SJeff Roberson {
1215df87b21SJeff Roberson 	vm_offset_t addr;
1225df87b21SJeff Roberson 	int result;
1235df87b21SJeff Roberson 
1247a469c8eSJeff Roberson 	KASSERT((size % KVA_QUANTUM) == 0,
1257a469c8eSJeff Roberson 	    ("kva_import: Size %jd is not a multiple of %d",
1267a469c8eSJeff Roberson 	    (intmax_t)size, (int)KVA_QUANTUM));
1275df87b21SJeff Roberson 	addr = vm_map_min(kernel_map);
128edb572a3SJohn Baldwin 	result = vm_map_find(kernel_map, NULL, 0, &addr, size, 0,
1295aa60b6fSJohn Baldwin 	    VMFS_SUPER_SPACE, VM_PROT_ALL, VM_PROT_ALL, MAP_NOFAULT);
1305df87b21SJeff Roberson 	if (result != KERN_SUCCESS)
1315df87b21SJeff Roberson                 return (ENOMEM);
1325df87b21SJeff Roberson 
1335df87b21SJeff Roberson 	*addrp = addr;
1345df87b21SJeff Roberson 
1355df87b21SJeff Roberson 	return (0);
1365df87b21SJeff Roberson }
1375df87b21SJeff Roberson 
1380766f278SJonathan T. Looney #if VM_NRESERVLEVEL > 0
1390766f278SJonathan T. Looney /*
1400766f278SJonathan T. Looney  * Import a superpage from the normal kernel arena into the special
1410766f278SJonathan T. Looney  * arena for allocations with different permissions.
1420766f278SJonathan T. Looney  */
1430766f278SJonathan T. Looney static int
1440766f278SJonathan T. Looney kernel_rwx_alloc(void *arena, vmem_size_t size, int flags, vmem_addr_t *addrp)
1450766f278SJonathan T. Looney {
1460766f278SJonathan T. Looney 
1470766f278SJonathan T. Looney 	KASSERT((size % KVA_QUANTUM) == 0,
1480766f278SJonathan T. Looney 	    ("kernel_rwx_alloc: Size %jd is not a multiple of %d",
1490766f278SJonathan T. Looney 	    (intmax_t)size, (int)KVA_QUANTUM));
1500766f278SJonathan T. Looney 	return (vmem_xalloc(arena, size, KVA_QUANTUM, 0, 0, VMEM_ADDR_MIN,
1510766f278SJonathan T. Looney 	    VMEM_ADDR_MAX, flags, addrp));
1520766f278SJonathan T. Looney }
1530766f278SJonathan T. Looney #endif
1540766f278SJonathan T. Looney 
1555df87b21SJeff Roberson /*
156df8bae1dSRodney W. Grimes  *	vm_init initializes the virtual memory system.
157df8bae1dSRodney W. Grimes  *	This is done only by the first cpu up.
158df8bae1dSRodney W. Grimes  *
159df8bae1dSRodney W. Grimes  *	The start and end address of physical memory is passed in.
160df8bae1dSRodney W. Grimes  */
1612b14f991SJulian Elischer /* ARGSUSED*/
1622b14f991SJulian Elischer static void
163d841aaa7SBruce Evans vm_mem_init(dummy)
164d841aaa7SBruce Evans 	void *dummy;
165df8bae1dSRodney W. Grimes {
1667a469c8eSJeff Roberson 	int domain;
1675df87b21SJeff Roberson 
168df8bae1dSRodney W. Grimes 	/*
1690d94caffSDavid Greenman 	 * Initializes resident memory structures. From here on, all physical
1700d94caffSDavid Greenman 	 * memory is accounted for, and we use only virtual addresses.
171df8bae1dSRodney W. Grimes 	 */
17226f9a767SRodney W. Grimes 	vm_set_page_size();
173889eb0fcSAlan Cox 	virtual_avail = vm_page_startup(virtual_avail);
174e7841165SDag-Erling Smørgrav 
175ae941b1bSGleb Smirnoff #ifdef	UMA_MD_SMALL_ALLOC
176ae941b1bSGleb Smirnoff 	/* Announce page availability to UMA. */
177ae941b1bSGleb Smirnoff 	uma_startup1();
178ae941b1bSGleb Smirnoff #endif
179df8bae1dSRodney W. Grimes 	/*
180df8bae1dSRodney W. Grimes 	 * Initialize other VM packages
181df8bae1dSRodney W. Grimes 	 */
1825f518366SJeff Roberson 	vmem_startup();
183a316d390SJohn Dyson 	vm_object_init();
184df8bae1dSRodney W. Grimes 	vm_map_startup();
185df8bae1dSRodney W. Grimes 	kmem_init(virtual_avail, virtual_end);
1865df87b21SJeff Roberson 
1875df87b21SJeff Roberson 	/*
1885df87b21SJeff Roberson 	 * Initialize the kernel_arena.  This can grow on demand.
1895df87b21SJeff Roberson 	 */
1905df87b21SJeff Roberson 	vmem_init(kernel_arena, "kernel arena", 0, 0, PAGE_SIZE, 0, 0);
1917a469c8eSJeff Roberson 	vmem_set_import(kernel_arena, kva_import, NULL, NULL, KVA_QUANTUM);
1927a469c8eSJeff Roberson 
1930766f278SJonathan T. Looney #if VM_NRESERVLEVEL > 0
1940766f278SJonathan T. Looney 	/*
1950766f278SJonathan T. Looney 	 * In an architecture with superpages, maintain a separate arena
1960766f278SJonathan T. Looney 	 * for allocations with permissions that differ from the "standard"
1970766f278SJonathan T. Looney 	 * read/write permissions used for memory in the kernel_arena.
1980766f278SJonathan T. Looney 	 */
1990766f278SJonathan T. Looney 	kernel_rwx_arena = vmem_create("kernel rwx arena", 0, 0, PAGE_SIZE,
2000766f278SJonathan T. Looney 	    0, M_WAITOK);
2010766f278SJonathan T. Looney 	vmem_set_import(kernel_rwx_arena, kernel_rwx_alloc,
2020766f278SJonathan T. Looney 	    (vmem_release_t *)vmem_xfree, kernel_arena, KVA_QUANTUM);
2030766f278SJonathan T. Looney #endif
2040766f278SJonathan T. Looney 
2057a469c8eSJeff Roberson 	for (domain = 0; domain < vm_ndomains; domain++) {
2067a469c8eSJeff Roberson 		vm_dom[domain].vmd_kernel_arena = vmem_create(
2077a469c8eSJeff Roberson 		    "kernel arena domain", 0, 0, PAGE_SIZE, 0, M_WAITOK);
2087a469c8eSJeff Roberson 		vmem_set_import(vm_dom[domain].vmd_kernel_arena,
2097a469c8eSJeff Roberson 		    (vmem_import_t *)vmem_alloc, NULL, kernel_arena,
2107a469c8eSJeff Roberson 		    KVA_QUANTUM);
2110766f278SJonathan T. Looney #if VM_NRESERVLEVEL > 0
2120766f278SJonathan T. Looney 		vm_dom[domain].vmd_kernel_rwx_arena = vmem_create(
2130766f278SJonathan T. Looney 		    "kernel rwx arena domain", 0, 0, PAGE_SIZE, 0, M_WAITOK);
2140766f278SJonathan T. Looney 		vmem_set_import(vm_dom[domain].vmd_kernel_rwx_arena,
2150766f278SJonathan T. Looney 		    kernel_rwx_alloc, (vmem_release_t *)vmem_xfree,
2160766f278SJonathan T. Looney 		    vm_dom[domain].vmd_kernel_arena, KVA_QUANTUM);
2170766f278SJonathan T. Looney #endif
2187a469c8eSJeff Roberson 	}
2195df87b21SJeff Roberson 
220ae941b1bSGleb Smirnoff #ifndef	UMA_MD_SMALL_ALLOC
221ae941b1bSGleb Smirnoff 	/* Set up radix zone to use noobj_alloc. */
222ae941b1bSGleb Smirnoff 	vm_radix_reserve_kva();
223ae941b1bSGleb Smirnoff #endif
224f7d35785SGleb Smirnoff 	/* Announce full page availability to UMA. */
225f7d35785SGleb Smirnoff 	uma_startup2();
2265df87b21SJeff Roberson 	kmem_init_zero_region();
227bdb93eb2SAlan Cox 	pmap_init();
228df8bae1dSRodney W. Grimes 	vm_pager_init();
229df8bae1dSRodney W. Grimes }
230219d632cSMatthew Dillon 
231219d632cSMatthew Dillon void
232219d632cSMatthew Dillon vm_ksubmap_init(struct kva_md_info *kmi)
233219d632cSMatthew Dillon {
234219d632cSMatthew Dillon 	vm_offset_t firstaddr;
235219d632cSMatthew Dillon 	caddr_t v;
236219d632cSMatthew Dillon 	vm_size_t size = 0;
237447b3772SPeter Wemm 	long physmem_est;
238219d632cSMatthew Dillon 	vm_offset_t minaddr;
239219d632cSMatthew Dillon 	vm_offset_t maxaddr;
240219d632cSMatthew Dillon 
241219d632cSMatthew Dillon 	/*
242219d632cSMatthew Dillon 	 * Allocate space for system data structures.
243219d632cSMatthew Dillon 	 * The first available kernel virtual address is in "v".
244219d632cSMatthew Dillon 	 * As pages of kernel virtual memory are allocated, "v" is incremented.
245219d632cSMatthew Dillon 	 * As pages of memory are allocated and cleared,
246219d632cSMatthew Dillon 	 * "firstaddr" is incremented.
247219d632cSMatthew Dillon 	 */
248219d632cSMatthew Dillon 
249219d632cSMatthew Dillon 	/*
250219d632cSMatthew Dillon 	 * Make two passes.  The first pass calculates how much memory is
251219d632cSMatthew Dillon 	 * needed and allocates it.  The second pass assigns virtual
252219d632cSMatthew Dillon 	 * addresses to the various data structures.
253219d632cSMatthew Dillon 	 */
254219d632cSMatthew Dillon 	firstaddr = 0;
255219d632cSMatthew Dillon again:
256219d632cSMatthew Dillon 	v = (caddr_t)firstaddr;
257219d632cSMatthew Dillon 
258219d632cSMatthew Dillon 	/*
259219d632cSMatthew Dillon 	 * Discount the physical memory larger than the size of kernel_map
260219d632cSMatthew Dillon 	 * to avoid eating up all of KVA space.
261219d632cSMatthew Dillon 	 */
262*f0165b1cSKonstantin Belousov 	physmem_est = lmin(physmem, btoc(vm_map_max(kernel_map) -
263*f0165b1cSKonstantin Belousov 	    vm_map_min(kernel_map)));
264219d632cSMatthew Dillon 
265219d632cSMatthew Dillon 	v = kern_vfs_bio_buffer_alloc(v, physmem_est);
266219d632cSMatthew Dillon 
267219d632cSMatthew Dillon 	/*
268219d632cSMatthew Dillon 	 * End of first pass, size has been calculated so allocate memory
269219d632cSMatthew Dillon 	 */
270219d632cSMatthew Dillon 	if (firstaddr == 0) {
271857961d9SRobert Drehmel 		size = (vm_size_t)v;
272edb2994aSAndrew Gallatin #ifdef VM_FREELIST_DMA32
273edb2994aSAndrew Gallatin 		/*
274edb2994aSAndrew Gallatin 		 * Try to protect 32-bit DMAable memory from the largest
275edb2994aSAndrew Gallatin 		 * early alloc of wired mem.
276edb2994aSAndrew Gallatin 		 */
277db7c2a48SAlan Cox 		firstaddr = kmem_alloc_attr(size, M_ZERO | M_NOWAIT,
278db7c2a48SAlan Cox 		    (vm_paddr_t)1 << 32, ~(vm_paddr_t)0, VM_MEMATTR_DEFAULT);
279edb2994aSAndrew Gallatin 		if (firstaddr == 0)
280edb2994aSAndrew Gallatin #endif
28183a90bffSAlan Cox 			firstaddr = kmem_malloc(size, M_ZERO | M_WAITOK);
282219d632cSMatthew Dillon 		if (firstaddr == 0)
283219d632cSMatthew Dillon 			panic("startup: no room for tables");
284219d632cSMatthew Dillon 		goto again;
285219d632cSMatthew Dillon 	}
286219d632cSMatthew Dillon 
287219d632cSMatthew Dillon 	/*
288219d632cSMatthew Dillon 	 * End of second pass, addresses have been assigned
289219d632cSMatthew Dillon 	 */
290219d632cSMatthew Dillon 	if ((vm_size_t)((char *)v - firstaddr) != size)
291219d632cSMatthew Dillon 		panic("startup: table size inconsistency");
292219d632cSMatthew Dillon 
2935df87b21SJeff Roberson 	/*
2945df87b21SJeff Roberson 	 * Allocate the clean map to hold all of the paging and I/O virtual
2955df87b21SJeff Roberson 	 * memory.
2965df87b21SJeff Roberson 	 */
2975f518366SJeff Roberson 	size = (long)nbuf * BKVASIZE + (long)nswbuf * MAXPHYS +
2985f518366SJeff Roberson 	    (long)bio_transient_maxcnt * MAXPHYS;
2995df87b21SJeff Roberson 	kmi->clean_sva = firstaddr = kva_alloc(size);
3005df87b21SJeff Roberson 	kmi->clean_eva = firstaddr + size;
3015f518366SJeff Roberson 
3025df87b21SJeff Roberson 	/*
3035df87b21SJeff Roberson 	 * Allocate the buffer arena.
30421fae961SJeff Roberson 	 *
30521fae961SJeff Roberson 	 * Enable the quantum cache if we have more than 4 cpus.  This
30621fae961SJeff Roberson 	 * avoids lock contention at the expense of some fragmentation.
3075df87b21SJeff Roberson 	 */
3085f518366SJeff Roberson 	size = (long)nbuf * BKVASIZE;
3095df87b21SJeff Roberson 	kmi->buffer_sva = firstaddr;
3105f518366SJeff Roberson 	kmi->buffer_eva = kmi->buffer_sva + size;
3115f518366SJeff Roberson 	vmem_init(buffer_arena, "buffer arena", kmi->buffer_sva, size,
31221fae961SJeff Roberson 	    PAGE_SIZE, (mp_ncpus > 4) ? BKVASIZE * 8 : 0, 0);
3135df87b21SJeff Roberson 	firstaddr += size;
3145f518366SJeff Roberson 
3155df87b21SJeff Roberson 	/*
3165df87b21SJeff Roberson 	 * Now swap kva.
3175df87b21SJeff Roberson 	 */
3185df87b21SJeff Roberson 	swapbkva = firstaddr;
3195f518366SJeff Roberson 	size = (long)nswbuf * MAXPHYS;
3205df87b21SJeff Roberson 	firstaddr += size;
3215f518366SJeff Roberson 
3225df87b21SJeff Roberson 	/*
3235df87b21SJeff Roberson 	 * And optionally transient bio space.
3245df87b21SJeff Roberson 	 */
3257db07e1cSKonstantin Belousov 	if (bio_transient_maxcnt != 0) {
3265f518366SJeff Roberson 		size = (long)bio_transient_maxcnt * MAXPHYS;
3275f518366SJeff Roberson 		vmem_init(transient_arena, "transient arena",
3285df87b21SJeff Roberson 		    firstaddr, size, PAGE_SIZE, 0, 0);
3295df87b21SJeff Roberson 		firstaddr += size;
3307db07e1cSKonstantin Belousov 	}
3315df87b21SJeff Roberson 	if (firstaddr != kmi->clean_eva)
3325df87b21SJeff Roberson 		panic("Clean map calculation incorrect");
3335df87b21SJeff Roberson 
3345df87b21SJeff Roberson 	/*
335ec492b13SMark Johnston 	 * Allocate the pageable submaps.  We may cache an exec map entry per
336ec492b13SMark Johnston 	 * CPU, so we therefore need to reserve space for at least ncpu+1
337ec492b13SMark Johnston 	 * entries to avoid deadlock.  The exec map is also used by some image
338ec492b13SMark Johnston 	 * activators, so we leave a fixed number of pages for their use.
3395df87b21SJeff Roberson 	 */
340ec492b13SMark Johnston #ifdef __LP64__
341ec492b13SMark Johnston 	exec_map_entries = 8 * mp_ncpus;
342ec492b13SMark Johnston #else
3438d65cba2SMark Johnston 	exec_map_entries = 2 * mp_ncpus + 4;
344ec492b13SMark Johnston #endif
345ec492b13SMark Johnston 	exec_map_entry_size = round_page(PATH_MAX + ARG_MAX);
346219d632cSMatthew Dillon 	exec_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr,
347ec492b13SMark Johnston 	    exec_map_entries * exec_map_entry_size + 64 * PAGE_SIZE, FALSE);
3483202ed75SAlan Cox 	pipe_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr, maxpipekva,
3493202ed75SAlan Cox 	    FALSE);
350219d632cSMatthew Dillon }
351