From owner-svn-src-all@freebsd.org Wed Feb 7 16:46:23 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 E4CAAF1404C; Wed, 7 Feb 2018 16:46:22 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (glebi.us [96.95.210.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "cell.glebi.us", Issuer "cell.glebi.us" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 7BCCF72126; Wed, 7 Feb 2018 16:46:21 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (localhost [127.0.0.1]) by cell.glebi.us (8.15.2/8.15.2) with ESMTPS id w17GkKt1013064 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 7 Feb 2018 08:46:20 -0800 (PST) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebi.us (8.15.2/8.15.2/Submit) id w17GkJVn013063; Wed, 7 Feb 2018 08:46:19 -0800 (PST) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebi.us: glebius set sender to glebius@FreeBSD.org using -f Date: Wed, 7 Feb 2018 08:46:19 -0800 From: Gleb Smirnoff To: Peter Holm Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r328916 - in head/sys: kern vm Message-ID: <20180207164619.GK1063@FreeBSD.org> References: <20180206113017.GA25428@x2.osted.lan> <20180206182839.GB1063@FreeBSD.org> <20180206193430.GA36054@x2.osted.lan> <20180206221555.GC1063@FreeBSD.org> <20180206225244.GA40529@x2.osted.lan> <20180206230635.GE1063@FreeBSD.org> <20180206232521.GA41396@x2.osted.lan> <20180207004213.GG1063@FreeBSD.org> <20180207004549.GH1063@FreeBSD.org> <20180207064617.GA49792@x2.osted.lan> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="5gxpn/Q6ypwruk0T" Content-Disposition: inline In-Reply-To: <20180207064617.GA49792@x2.osted.lan> User-Agent: Mutt/1.9.3 (2018-01-21) 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: Wed, 07 Feb 2018 16:46:23 -0000 --5gxpn/Q6ypwruk0T Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Feb 07, 2018 at 07:46:17AM +0100, Peter Holm wrote: P> On Tue, Feb 06, 2018 at 04:45:49PM -0800, Gleb Smirnoff wrote: P> > On Tue, Feb 06, 2018 at 04:42:13PM -0800, Gleb Smirnoff wrote: P> > T> Hi Peter, P> > T> P> > T> can you please try this patch? In either case success P> > T> or not, please provide me with dmesg. Thanks a lot! P> > P> > Sorry, patch was missing one file. 99.9% this is a no-op, P> > but better use full patch. Let's do one more attempt. I found where I miss one keg. -- Gleb Smirnoff --5gxpn/Q6ypwruk0T Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="boot_pages.diff" Index: sys/kern/subr_vmem.c =================================================================== --- sys/kern/subr_vmem.c (revision 328955) +++ sys/kern/subr_vmem.c (working copy) @@ -667,7 +667,8 @@ int vmem_startup_count(void) { - return (howmany(BT_MAXALLOC, UMA_SLAB_SIZE / sizeof(struct vmem_btag))); + return (howmany(BT_MAXALLOC, + UMA_SLAB_SPACE / sizeof(struct vmem_btag))); } #endif Index: sys/vm/uma_core.c =================================================================== --- sys/vm/uma_core.c (revision 328955) +++ sys/vm/uma_core.c (working copy) @@ -96,6 +96,7 @@ __FBSDID("$FreeBSD$"); #ifdef DEBUG_MEMGUARD #include #endif +#define DIAGNOSTIC /* * This is the zone and keg from which all zones are spawned. @@ -1796,28 +1797,40 @@ uma_startup_count(int zones) zsize = sizeof(struct uma_zone) + (sizeof(struct uma_cache) * (mp_maxid + 1)) + (sizeof(struct uma_zone_domain) * vm_ndomains); + printf("ksize %d zsize %d slab %lu\n", ksize, zsize, sizeof(struct uma_slab)); - /* Memory for the zone of zones and zone of kegs. */ + /* + * Memory for the zone of kegs and its keg, + * and for zone of zones. + */ pages = howmany(roundup(zsize, CACHE_LINE_SIZE) * 2 + roundup(ksize, CACHE_LINE_SIZE), PAGE_SIZE); + printf("boot_pages master %d\n", pages); zones += UMA_BOOT_ZONES; - /* Memory for startup zones, UMA and VM, ... */ + /* Memory for the rest of startup zones, UMA and VM, ... */ if (zsize > UMA_SLAB_SIZE) pages += zones * howmany(zsize, UMA_SLAB_SIZE); else - pages += howmany(zones, UMA_SLAB_SIZE / zsize); + pages += howmany(zones, UMA_SLAB_SPACE / zsize); + printf("boot_pages zones %d\n", pages); - /* ... and their kegs. */ - pages += howmany(zones, UMA_SLAB_SIZE / ksize); + /* ... and their kegs. Note that zone of zones allocates a keg! */ + pages += howmany(zones + 1, UMA_SLAB_SPACE / ksize); + printf("boot_pages kegs %d\n", pages); /* - * Take conservative approach that every zone - * is going to allocate hash. + * Most of startup zones are not going to be offpages, that's + * why we use UMA_SLAB_SPACE instead of UMA_SLAB_SIZE in all + * calculations. Some large bucket zones will be offpage, and + * thus will allocate hashes. We take conservative approach + * and assume that all zones may allocate hash. This may give + * us some positive imprecision, usually an extra single page. */ - pages += howmany(zones, UMA_SLAB_SIZE / + pages += howmany(zones, UMA_SLAB_SPACE / (sizeof(struct slabhead *) * UMA_HASH_SIZE_INIT)); + printf("boot_pages hash %d\n", pages); return (pages); } Index: sys/vm/uma_int.h =================================================================== --- sys/vm/uma_int.h (revision 328955) +++ sys/vm/uma_int.h (working copy) @@ -138,6 +138,11 @@ #define UMA_MAX_WASTE 10 /* + * Size of memory in a not offpage slab available for actual items. + */ +#define UMA_SLAB_SPACE (UMA_SLAB_SIZE - sizeof(struct uma_slab)) + +/* * I doubt there will be many cases where this is exceeded. This is the initial * size of the hash table for uma_slabs that are managed off page. This hash * does expand by powers of two. Currently it doesn't get smaller. Index: sys/vm/vm_page.c =================================================================== --- sys/vm/vm_page.c (revision 328955) +++ sys/vm/vm_page.c (working copy) @@ -518,8 +518,11 @@ vm_page_startup(vm_offset_t vaddr) /* vmem_startup() calls uma_prealloc(). */ boot_pages += vmem_startup_count(); + printf("boot_pages vmem %d\n", boot_pages); /* vm_map_startup() calls uma_prealloc(). */ - boot_pages += howmany(MAX_KMAP, UMA_SLAB_SIZE / sizeof(struct vm_map)); + boot_pages += howmany(MAX_KMAP, + UMA_SLAB_SPACE / sizeof(struct vm_map)); + printf("boot_pages kmap %d\n", boot_pages); /* * Before going fully functional kmem_init() does allocation --5gxpn/Q6ypwruk0T--