From owner-freebsd-current@FreeBSD.ORG Fri Feb 1 13:25:44 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id A80306C4 for ; Fri, 1 Feb 2013 13:25:44 +0000 (UTC) (envelope-from andre@freebsd.org) Received: from c00l3r.networx.ch (c00l3r.networx.ch [62.48.2.2]) by mx1.freebsd.org (Postfix) with ESMTP id 806E4706 for ; Fri, 1 Feb 2013 13:25:42 +0000 (UTC) Received: (qmail 42730 invoked from network); 1 Feb 2013 14:45:21 -0000 Received: from unknown (HELO [62.48.0.94]) ([62.48.0.94]) (envelope-sender ) by c00l3r.networx.ch (qmail-ldap-1.03) with SMTP for ; 1 Feb 2013 14:45:21 -0000 Message-ID: <510BC24D.2090406@freebsd.org> Date: Fri, 01 Feb 2013 14:25:33 +0100 From: Andre Oppermann User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 MIME-Version: 1.0 To: freebsd-current@freebsd.org Subject: Cleanup and untangling of kernel VM initialization Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: alc@freebsd.org, kib@freebsd.org X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Feb 2013 13:25:44 -0000 As an outcome of the recent problems with auto-sizing and auto-tuning of the various kernel subsystems and related memory structures I've taken a closer look at the whole KVM inner working and initialization process. I've found the VM and KVM initialization to be somewhat obscure and stuck half-way between the old 4.4BSD way and our modern SYSINIT concept. While trying to understand all the steps I started to move things around, into their own units and converted them to use SYSINITs. The result is a patch that cleans up the majority of initialization process, removes bitrot and moves it into the modern world order: http://people.freebsd.org/~andre/kernel_init_mem-20130201.diff The changes in particular are: Move large parts of vm/vm_init.c to SYSINIT()s and de-magic old-style kernel vm initialization. Move vm_ksubmap_init(), bufinit() and vm_pager_bufferinit() from machdep.c to SYSINIT's. It was duplicated among all architectures which means that is wasn't architecture specific. Centralize definition of virtual_avail and virtual_end from the architectures pmap.h to vm_extern.h. Move various initializations from kern/subr_param.c to where it is actually used and SYSINIT() in particular vm_pager (pager_map / nswbuf), vm_kern (kernel_map), swap_pager (maxswzone), sys_pipe (pipe_map / maxpipekva), vfs_bio (buffer_map / nbuf), kern_exec (exec_map / exec_map_entries), kern_malloc (kmem_map), kern_timeout (callwheel, ncallout). Move subsystem initializations from init_main.c to SYSINIT()s. Add sysctl's to give detailed information on all kernel vm_maps and sub maps Remove unused struct kva_md_info. Rebase auto-sizing of limits on the available KVM/kmem_map instead of physical memory. Depending on the kernel and architecture configuration these two can be very different. Comments and reviews appreciated. For committing it'll be broken into meaningful and functional pieces with an appropriate commit message each. I've tested on amd64. Feedback from other architectures welcome. Especially for powerpc where I had to modify the minidump routine slighly to avoid dumping of buffer_map memory. -- Andre