Re: Cleanup and untangling of kernel VM initialization

From: Alan Cox <alc_at_rice.edu>
Date: Fri, 01 Feb 2013 11:09:52 -0600
On 02/01/2013 07:25, Andre Oppermann wrote:
> 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.
>

I think vm/pmap.h would be more appropriate place than vm/vm_extern.h. 
These variables have only been used for communication between the pmap
and the machine-independent layer at initialization time.

>  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.
>

It is used by assertions that block people from writing code that uses
the wrong pmap functions for mapping pages into the buffer and pager maps.

>  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.
>

I would really like to see the issues with the current auto-sizing code
addressed before any of the stylistic changes or en-masse conversions to
SYSINIT()s are considered.  In particular, can we please start with the
patch that moves the pipe_map initialization?  After that, I think that
we should revisit tunable_mbinit() and "maxmbufmem".

> 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.
>
Received on Fri Feb 01 2013 - 16:17:06 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:34 UTC