From owner-svn-src-all@freebsd.org Tue Feb 6 22:07:00 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 36FFEF0B815; Tue, 6 Feb 2018 22:07:00 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E16548495A; Tue, 6 Feb 2018 22:06:59 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DC2AE1DEE8; Tue, 6 Feb 2018 22:06:59 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w16M6xre035199; Tue, 6 Feb 2018 22:06:59 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w16M6xCS035195; Tue, 6 Feb 2018 22:06:59 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201802062206.w16M6xCS035195@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Tue, 6 Feb 2018 22:06:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r328952 - in head/sys: kern vm X-SVN-Group: head X-SVN-Commit-Author: glebius X-SVN-Commit-Paths: in head/sys: kern vm X-SVN-Commit-Revision: 328952 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Feb 2018 22:07:00 -0000 Author: glebius Date: Tue Feb 6 22:06:59 2018 New Revision: 328952 URL: https://svnweb.freebsd.org/changeset/base/328952 Log: Fix boot_pages calculation for machines that don't have UMA_MD_SMALL_ALLOC. o Call uma_startup1() after initializing kmem, vmem and domains. o Include 8 eight VM startup pages into uma_startup_count() calculation. o Account for vmem_startup() and vm_map_startup() preallocating pages. o Account for extra two allocations done by kmem_init() and vmem_create(). o Hardcode the place of execution of vm_radix_reserve_kva(). Using SYSINIT allowed several other SYSINITs to sneak in before it, thus bumping requirement for amount of boot pages. Modified: head/sys/kern/subr_vmem.c head/sys/vm/vm_init.c head/sys/vm/vm_page.c head/sys/vm/vm_radix.c Modified: head/sys/kern/subr_vmem.c ============================================================================== --- head/sys/kern/subr_vmem.c Tue Feb 6 21:35:41 2018 (r328951) +++ head/sys/kern/subr_vmem.c Tue Feb 6 22:06:59 2018 (r328952) @@ -72,7 +72,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +int vmem_startup_count(void); + #define VMEM_OPTORDER 5 #define VMEM_OPTVALUE (1 << VMEM_OPTORDER) #define VMEM_MAXORDER \ @@ -652,6 +655,16 @@ vmem_bt_alloc(uma_zone_t zone, vm_size_t bytes, int do pause("btalloc", 1); return (NULL); +} + +/* + * How many pages do we need to startup_alloc. + */ +int +vmem_startup_count(void) +{ + + return (howmany(BT_MAXALLOC, UMA_SLAB_SIZE / sizeof(struct vmem_btag))); } #endif Modified: head/sys/vm/vm_init.c ============================================================================== --- head/sys/vm/vm_init.c Tue Feb 6 21:35:41 2018 (r328951) +++ head/sys/vm/vm_init.c Tue Feb 6 22:06:59 2018 (r328952) @@ -93,6 +93,8 @@ __FBSDID("$FreeBSD$"); #include #include +extern void uma_startup1(void); +extern void vm_radix_reserve_kva(void); #if VM_NRESERVLEVEL > 0 #define KVA_QUANTUM (1 << (VM_LEVEL_0_ORDER + PAGE_SHIFT)) @@ -150,7 +152,11 @@ vm_mem_init(dummy) */ vm_set_page_size(); virtual_avail = vm_page_startup(virtual_avail); - + +#ifdef UMA_MD_SMALL_ALLOC + /* Announce page availability to UMA. */ + uma_startup1(); +#endif /* * Initialize other VM packages */ @@ -173,6 +179,12 @@ vm_mem_init(dummy) KVA_QUANTUM); } +#ifndef UMA_MD_SMALL_ALLOC + /* Set up radix zone to use noobj_alloc. */ + vm_radix_reserve_kva(); + /* Announce page availability to UMA. */ + uma_startup1(); +#endif kmem_init_zero_region(); pmap_init(); vm_pager_init(); Modified: head/sys/vm/vm_page.c ============================================================================== --- head/sys/vm/vm_page.c Tue Feb 6 21:35:41 2018 (r328951) +++ head/sys/vm/vm_page.c Tue Feb 6 22:06:59 2018 (r328952) @@ -112,6 +112,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -127,7 +128,7 @@ __FBSDID("$FreeBSD$"); extern int uma_startup_count(int); extern void uma_startup(void *, int); -extern void uma_startup1(void); +extern int vmem_startup_count(void); /* * Associated with page of user-allocatable memory is a @@ -501,12 +502,33 @@ vm_page_startup(vm_offset_t vaddr) /* * Allocate memory for use when boot strapping the kernel memory - * allocator. - * + * allocator. Tell UMA how many zones we are going to create + * before going fully functional. UMA will add its zones. + */ +#ifdef UMA_MD_SMALL_ALLOC + boot_pages = uma_startup_count(0); +#else + /* + * VM startup zones: vmem, vmem_btag, VM OBJECT, RADIX NODE, MAP, + * KMAP ENTRY, MAP ENTRY, VMSPACE. + */ + boot_pages = uma_startup_count(8); + + /* vmem_startup() calls uma_prealloc(). */ + boot_pages += vmem_startup_count(); + /* vm_map_startup() calls uma_prealloc(). */ + boot_pages += howmany(MAX_KMAP, UMA_SLAB_SIZE / sizeof(struct vm_map)); + + /* + * Before going fully functional kmem_init() does allocation + * from "KMAP ENTRY" and vmem_create() does allocation from "vmem". + */ + boot_pages += 2; +#endif + /* * CTFLAG_RDTUN doesn't work during the early boot process, so we must * manually fetch the value. */ - boot_pages = uma_startup_count(0); TUNABLE_INT_FETCH("vm.boot_pages", &boot_pages); new_end = end - (boot_pages * UMA_SLAB_SIZE); new_end = trunc_page(new_end); @@ -739,9 +761,6 @@ vm_page_startup(vm_offset_t vaddr) * can work. */ domainset_zero(); - - /* Announce page availability to UMA. */ - uma_startup1(); return (vaddr); } Modified: head/sys/vm/vm_radix.c ============================================================================== --- head/sys/vm/vm_radix.c Tue Feb 6 21:35:41 2018 (r328951) +++ head/sys/vm/vm_radix.c Tue Feb 6 22:06:59 2018 (r328952) @@ -284,6 +284,7 @@ vm_radix_node_zone_dtor(void *mem, int size __unused, #endif #ifndef UMA_MD_SMALL_ALLOC +void vm_radix_reserve_kva(void); /* * Reserve the KVA necessary to satisfy the node allocation. * This is mandatory in architectures not supporting direct @@ -291,8 +292,8 @@ vm_radix_node_zone_dtor(void *mem, int size __unused, * every node allocation, resulting into deadlocks for consumers already * working with kernel maps. */ -static void -vm_radix_reserve_kva(void *arg __unused) +void +vm_radix_reserve_kva(void) { /* @@ -304,8 +305,6 @@ vm_radix_reserve_kva(void *arg __unused) sizeof(struct vm_radix_node)))) panic("%s: unable to reserve KVA", __func__); } -SYSINIT(vm_radix_reserve_kva, SI_SUB_KMEM, SI_ORDER_THIRD, - vm_radix_reserve_kva, NULL); #endif /*